repositories / dotfiles

dotfiles

bugabingas dorkfiles

owned by bugabinga

build: add mise root tasks

e25f9ad95a1f7336145cac07d0305365815945f6

Oliver Jan Krylow <oliver@bugabinga.net> ·

unsigned

Browse filesCompare with HEAD

Changed files (4)

+255 / −9 text lines

Diff layout

AGENTS.md

Modified

+8 / −9 text lines

44Preserve unrelated dirty work.
55Check `git status --short` before edits.
66Prefer repo paths (`pi/agent/...`) over `$HOME` paths.
7Use Nushell-aware commands; `justfile` recipes run with `nu --commands` unless recipe has its own shebang.
7Use `mise` tasks; task shell is Nushell via `mise.toml`.
88Never print decrypted secrets.
99Do not delete noisy research/cache/untracked files unless explicitly asked.
5959Safe checks:
6161```sh
62just check
63just pre-commit
62mise run check
63mise run pre-commit
6464```
6666Heavy integration:
6868```sh
69just test
70just test fedora
69mise run test
70mise run test fedora
7171```
7373HOME/system mutating; only run after explicit user request:
7575```sh
76just link
77just unlink
78just setup
79just services
76mise run link
77mise run unlink
78mise run setup
8079java bootstripper.java clean
8180```

mise.toml

Added
new file mode 100644

+70 / −0 text lines

1[settings]
2unix_default_inline_shell_args = "nu -c"
3windows_default_inline_shell_args = "nu -c"
4
5[tasks.default]
6description = "List tasks"
7run = "mise tasks ls"
8
9[tasks.link]
10description = "Initialize crypto, install hooks, verify, and link dorkfiles into HOME"
11run = "java bootstripper.java bootstrap"
13[tasks.nugu-shaders]
14description = "Compile checked-in Quickshell shaders from source"
15run = [
16 "mkdir quickshell/nuguland/shaders",
17 "/usr/lib/qt6/bin/qsb --glsl 330 --hlsl 50 --msl 12 -o quickshell/nuguland/shaders/aurora.frag.qsb quickshell/nuguland/shaders/aurora.frag",
18]
20[tasks.check]
21description = "Verify crypto filters, hooks, staged secrets, and symlink manifests"
22run = "java bootstripper.java check"
24[tasks.clean]
25description = "Remove managed dorkfiles links from HOME"
26run = "java bootstripper.java clean"
28[tasks.pre-commit]
29description = "Run the same checks as the Git pre-commit hook"
30run = "java bootstripper.java pre-commit"
32[tasks.test]
33description = "Run Podman integration test for all symlink manifests"
34usage = '''
35arg "[hostname]" default="desktop"
36'''
37run = 'java ./scripts/dotfiles_integration_test.java "{{usage.hostname}}"'
39[tasks.init-crypto]
40description = "Create initial crypto salt"
41run = "java bootstripper.java init-crypto"
43[tasks.hooks]
44description = "Install Git hooks"
45run = "java bootstripper.java install-hooks"
47[tasks.unlink]
48description = "Remove managed dorkfiles links from HOME"
49run = "java bootstripper.java clean"
51[tasks.setup]
52description = "Initial setup: link dorkfiles and fix permissions"
53depends = ["link", "fix-permissions"]
55[tasks.import-winget]
56description = "Install previously exported winget apps"
57run = "winget import C:/Users/okr/Tools/winget_installed_apps.json"
59[tasks.fix-permissions]
60description = "Fix local file permissions"
61run = "java scripts/fix_permissions.java"
63[tasks.vcs-remote]
64description = "Set dorkfiles origin to vcs.bugabinga.net"
65run = [
66 "git remote remove origin",
67 "git remote add origin git@vcs.bugabinga.net:dotfiles.git",
68 "git fetch",
69 "git branch --set-upstream-to=origin/trunk trunk",
70]

scripts/dotfiles_integration_test.java

Added
new file mode 100644

+167 / −0 text lines

1import java.io.*;
2import java.nio.file.*;
3import java.time.*;
4import java.util.*;
5import java.util.stream.*;
6
7public class dotfiles_integration_test {
8 static Path root;
9
10 public static void main(String[] args) throws Exception {
11 if (args.length > 0 && args[0].equals("--inside")) inside(args.length > 1 ? args[1] : "desktop");
12 else host(args.length > 0 ? args[0] : "desktop");
13 }
15 static void host(String hostname) throws Exception {
16 root = Path.of(run(null, "git", "rev-parse", "--show-toplevel").trim());
17 var key = root.resolve(".git/dotfiles-aes.key");
18 if (!Files.isReadable(key)) fail("missing " + key);
19 var container = "dotfiles-integration-" + LocalDateTime.now() + "-" + ProcessHandle.current().pid();
20 container = container.replaceAll("[^A-Za-z0-9_.-]", "-");
21 try {
22 run(null, "podman", "run", "--name", container, "--rm", "-d", "--hostname", hostname,
23 "-e", "PRIMARY_HOSTNAME=" + hostname,
24 "-v", root + ":/src:ro", "-v", key + ":/dotfiles-aes.key:ro",
25 "registry.fedoraproject.org/fedora:latest", "sleep", "infinity");
26 run(null, "podman", "exec", container, "dnf", "-qy", "--setopt=install_weak_deps=False", "install", "git-core", "java-latest-openjdk-devel");
27 run(null, "podman", "exec", container, "git", "config", "--global", "--add", "safe.directory", "/src");
28 run(null, "podman", "exec", container, "mkdir", "-p", "/root/work");
29 run(null, "podman", "exec", container, "git", "clone", "--quiet", "--no-local", "/src", "/root/work/dotfiles");
30 run(null, "podman", "exec", container, "install", "-m", "600", "/dotfiles-aes.key", "/root/work/dotfiles/.git/dotfiles-aes.key");
31 run(null, "podman", "exec", "-w", "/root/work/dotfiles", container, "javac", "-d", "/tmp/dotfiles-test-classes", "/src/scripts/dotfiles_integration_test.java");
32 run(null, "podman", "exec", "-w", "/root/work/dotfiles", container, "java", "-cp", "/tmp/dotfiles-test-classes", "dotfiles_integration_test", "--inside", hostname);
33 } finally {
34 runAllowFail(null, "podman", "rm", "-f", container);
35 }
36 }
38 static void inside(String primaryHostname) throws Exception {
39 root = Path.of(".").toAbsolutePath().normalize();
40 System.out.println("rootless=" + rootless());
41 ok("deps");
42 System.out.println(run(root, "git", "--version").trim());
43 System.out.println(run(root, "java", "-version").lines().findFirst().orElse("java"));
45 run(root, "java", "bootstripper.java", "install-hooks");
46 if (!Files.isExecutable(root.resolve(".git/hooks/pre-commit"))) fail("hook-executable");
47 if (!Files.readString(root.resolve(".git/hooks/pre-commit")).contains("exec java bootstripper.java pre-commit")) fail("hook-content");
48 ok("install-hooks");
50 if (!run(root, "git", "show", "HEAD:nushell/secrets.nu").startsWith("DFAES1")) fail("committed-encrypted");
51 ok("committed-encrypted");
53 var hosts = new ArrayList<String>();
54 try (var s = Files.list(root)) {
55 s.filter(p -> p.getFileName().toString().endsWith(".symlinks"))
56 .map(p -> p.getFileName().toString().replaceFirst("\\.symlinks$", ""))
57 .sorted().forEach(hosts::add);
58 }
59 System.out.println("primary-manifest=" + primaryHostname + ".symlinks");
60 System.out.println("manifests=" + String.join(" ", hosts));
61 for (var host : hosts) runManifest(host);
62 ok("symlink-manifests:" + hosts.size());
64 if (Files.readString(root.resolve("nushell/secrets.nu")).startsWith("DFAES1")) fail("worktree-still-encrypted");
65 ok("worktree-decrypted");
67 run(root, "java", "bootstripper.java", "pre-commit");
68 ok("pre-commit");
70 freshCryptoSmoke();
71 System.out.println("RESULT:ok");
72 }
74 static void runManifest(String host) throws Exception {
75 var manifest = root.resolve(host + ".symlinks");
76 var home = Path.of("/tmp/home-" + host);
77 System.out.println("manifest=" + manifest.getFileName());
78 deleteTree(home);
79 Files.createDirectories(home);
80 var env = Map.of("HOSTNAME", host);
81 run(root, env, "java", "-Duser.home=" + home, "bootstripper.java", "bootstrap");
82 ok("bootstrap:" + host);
83 run(root, env, "java", "-Duser.home=" + home, "bootstripper.java", "check");
84 ok("check:" + host);
85 forEachMapping(manifest, (source, target) -> {
86 var path = targetPath(home, target);
87 if (!Files.isSymbolicLink(path)) throw new RuntimeException("FAIL:link:" + host + ":" + target);
88 });
89 ok("links:" + host);
90 run(root, env, "java", "-Duser.home=" + home, "bootstripper.java", "clean");
91 ok("clean:" + host);
92 }
94 static void freshCryptoSmoke() throws Exception {
95 var repo = Path.of("/tmp/fresh-crypto");
96 var home = Path.of("/tmp/fresh-crypto-home");
97 deleteTree(repo); deleteTree(home);
98 Files.createDirectories(repo.resolve("tools"));
99 Files.createDirectories(home);
100 Files.copy(root.resolve("bootstripper.java"), repo.resolve("bootstripper.java"));
101 Files.copy(root.resolve("tools/aes.java"), repo.resolve("tools/aes.java"));
102 Files.writeString(repo.resolve(".secrets"), "secret.txt\n");
103 Files.writeString(repo.resolve("mini.symlinks"), "dummy.txt\n~/dummy.txt\n");
104 Files.writeString(repo.resolve("secret.txt"), "not a real secret\n");
105 Files.writeString(repo.resolve("dummy.txt"), "dummy\n");
106 run(repo, "git", "init", "--quiet");
107 var env = Map.of("DOTFILES_AES_PASSPHRASE", "test");
108 run(repo, env, "java", "bootstripper.java", "init-crypto");
109 run(repo, env, "java", "bootstripper.java", "check");
110 run(repo, env, "git", "add", ".dotfiles-aes-salt", ".secrets", "bootstripper.java", "tools/aes.java", "mini.symlinks", "dummy.txt", "secret.txt");
111 run(repo, env, "java", "bootstripper.java", "check");
112 if (!run(repo, "git", "show", ":secret.txt").startsWith("DFAES1")) fail("fresh-staged-encrypted");
113 var env2 = new HashMap<>(env); env2.put("HOSTNAME", "mini");
114 run(repo, env2, "java", "-Duser.home=" + home, "bootstripper.java", "bootstrap");
115 if (!Files.isSymbolicLink(home.resolve("dummy.txt"))) fail("fresh-link");
116 run(repo, env2, "java", "-Duser.home=" + home, "bootstripper.java", "clean");
117 ok("fresh-crypto");
118 }
120 interface Mapping { void accept(String source, String target) throws Exception; }
121 static void forEachMapping(Path manifest, Mapping mapping) throws Exception {
122 String source = null;
123 for (var raw : Files.readAllLines(manifest)) {
124 var line = raw.strip();
125 if (line.isEmpty()) continue;
126 if (source == null) source = line;
127 else { mapping.accept(source, line); source = null; }
128 }
129 if (source != null) fail("missing target after " + source);
130 }
132 static Path targetPath(Path home, String target) {
133 return target.startsWith("~/") ? home.resolve(target.substring(2)) : Path.of(target);
134 }
136 static String rootless() throws IOException {
137 var p = Path.of("/proc/self/uid_map");
138 if (!Files.exists(p)) return "unknown";
139 var parts = Files.readString(p).trim().split("\\s+");
140 return parts.length >= 2 && parts[0].equals("0") && !parts[1].equals("0") ? "yes" : "unknown";
141 }
143 static void deleteTree(Path p) throws IOException {
144 if (!Files.exists(p)) return;
145 try (var s = Files.walk(p)) {
146 for (var x : s.sorted(Comparator.reverseOrder()).toList()) Files.deleteIfExists(x);
147 }
148 }
150 static void ok(String what) { System.out.println("ok:" + what); }
151 static void fail(String what) { throw new RuntimeException("FAIL:" + what); }
153 static String run(Path dir, String... cmd) throws Exception { return run(dir, Map.of(), cmd); }
154 static String run(Path dir, Map<String, String> env, String... cmd) throws Exception {
155 var pb = new ProcessBuilder(cmd);
156 if (dir != null) pb.directory(dir.toFile());
157 pb.environment().putAll(env);
158 var p = pb.redirectErrorStream(true).start();
159 var out = new String(p.getInputStream().readAllBytes());
160 var code = p.waitFor();
161 if (code != 0) throw new RuntimeException(String.join(" ", cmd) + "\n" + out);
162 return out;
163 }
164 static void runAllowFail(Path dir, String... cmd) {
165 try { run(dir, cmd); } catch (Exception ignored) {}
166 }
167}

scripts/fix_permissions.java

Added
new file mode 100644

+10 / −0 text lines

1import java.nio.file.*;
2import java.util.*;
3
4public class fix_permissions {
5 public static void main(String[] args) throws Exception {
6 if (!System.getProperty("os.name").toLowerCase(Locale.ROOT).contains("linux")) return;
7 var profile = Path.of(System.getProperty("user.home"), ".mozilla/firefox/qrza8u52.default-release");
8 if (Files.exists(profile)) new ProcessBuilder("chmod", "700", profile.toString()).inheritIO().start().waitFor();
9 }
10}