repositories / dotfiles

dotfiles

bugabingas dorkfiles

owned by bugabinga

fix dorkfiles link rules

97d57e6fa625788e8136a9f51e6b7fb3c6b0a002

Oliver Jan Krylow <oliver@bugabinga.net> ·

unsigned

Browse filesCompare with HEAD

Changed files (4)

bootstripper.java

Modified
7 7 import java.nio.file.Files;
8 8 import java.nio.file.LinkOption;
9 9 import java.nio.file.Path;
10 -import java.nio.file.attribute.PosixFilePermission;
11 10 import java.nio.file.attribute.PosixFilePermissions;
12 11 import java.security.SecureRandom;
13 12 import java.util.ArrayList;
14 13 import java.util.Arrays;
14 +import java.time.LocalDateTime;
15 +import java.time.format.DateTimeFormatter;
15 16 import java.util.Base64;
16 17 import java.util.HashSet;
17 18 import java.util.List;
18 -import java.util.Set;
19 19 import java.util.regex.Pattern;
20 20 import java.util.stream.Collectors;
21 21 import javax.crypto.SecretKeyFactory;
34 34 private final static int salt_bytes = 32;
35 35 private final static int derived_key_bits = 512;
36 36 private final static int pbkdf2_iterations = 310_000;
37 + private final static List<String> warnings = new ArrayList<>();
38 + private final static List<String> errors = new ArrayList<>();
38 40 public static void main(String[] arguments) throws Throwable {
39 41 var command = "bootstrap";
90 92 check(root);
91 93 var symlinks_file = symlinks_file(root);
92 94 create_symlinks(root, symlinks_file);
95 + print_attention(false);
95 98 static boolean is_command(String argument) {
275 278 static void check(Path root) throws Throwable {
276 279 var secrets = read_secrets(root);
277 - if (secrets.isEmpty())
278 - return;
279 - check_filter(root);
280 - check_attributes(root, secrets);
281 - check_key_not_tracked(root);
282 - check_staged_secrets(root, secrets);
280 + if (!secrets.isEmpty()) {
281 + check_filter(root);
282 + check_attributes(root, secrets);
283 + check_key_not_tracked(root);
284 + check_staged_secrets(root, secrets);
283 286 check_symlink_sources(root);
284 - check_no_tresor_refs(root);
285 287 check_staged_plaintext_patterns(root);
286 288 log("OK bootstripper check passed.");
291 + static void check_staged_plaintext_patterns(Path root) throws Throwable {
292 + var diff = run(root, List.of("git", "diff", "--cached", "-U0"), null, false).text();
293 + var patterns = List.of(
294 + Pattern.compile("gh[pousr]_[A-Za-z0-9_]{20,}"),
295 + Pattern.compile("github_personal_access_token\\s*\\\":\\s*\\\"[^<G][^\\\"]+\\\""),
296 + Pattern.compile("oauth_(access|refresh)_token\\s*=\\s*\\S+"),
297 + Pattern.compile("Authorization\\s*[:=]\\s*Bearer\\s+[A-Za-z0-9._-]{20,}", Pattern.CASE_INSENSITIVE));
298 + for (var pattern : patterns) {
299 + var matcher = pattern.matcher(diff);
300 + if (matcher.find())
301 + throw fail("Potential plaintext secret in staged diff.");
289 305 static void check_filter(Path root) throws Throwable {
290 306 var clean = run(root, List.of("git", "config", "--local", "--get", "filter." + filter_name + ".clean"), null, false).text().strip();
291 307 var smudge = run(root, List.of("git", "config", "--local", "--get", "filter." + filter_name + ".smudge"), null, false).text().strip();
335 351 try (var stream = Files.list(root)) {
336 352 var files = stream.filter(path -> path.getFileName().toString().endsWith(".symlinks")).collect(Collectors.toList());
337 353 for (var file : files) {
354 + var targets = new HashSet<Path>();
338 355 var lines = Files.readAllLines(file);
339 356 String source = null;
357 + var source_line = 0;
340 358 var line_number = 0;
341 359 for (var raw : lines) {
342 360 line_number++;
345 363 continue;
346 364 if (source == null) {
347 365 source = line;
366 + source_line = line_number;
348 367 continue;
350 369 var source_path = root.resolve(source);
351 370 if (!Files.exists(source_path, LinkOption.NOFOLLOW_LINKS))
352 - throw fail("Missing symlink source: {0}:{1}: {2}", file.getFileName(), line_number - 1, source);
371 + throw fail("Missing symlink source: {0}:{1}: {2}", file.getFileName(), source_line, source);
372 + var target_path = expand_target(line).normalize();
373 + if (!targets.add(target_path))
374 + throw fail("Duplicate symlink target: {0}:{1}: {2}", file.getFileName(), line_number, line);
353 375 source = null;
355 377 if (source != null)
361 - static void check_no_tresor_refs(Path root) throws IOException {
362 - try (var stream = Files.list(root)) {
363 - var files = stream.filter(path -> path.getFileName().toString().endsWith(".symlinks")).collect(Collectors.toList());
364 - for (var file : files) {
365 - var line_number = 0;
366 - for (var line : Files.readAllLines(file)) {
367 - line_number++;
368 - if (line.strip().startsWith("tresor/"))
369 - throw new IllegalStateException("tresor reference remains: " + file.getFileName() + ":" + line_number);
370 - }
371 - }
372 - }
373 - }
375 - static void check_staged_plaintext_patterns(Path root) throws Throwable {
376 - var diff = run(root, List.of("git", "diff", "--cached", "-U0"), null, false).text();
377 - var patterns = List.of(
378 - Pattern.compile("gh[pousr]_[A-Za-z0-9_]{20,}"),
379 - Pattern.compile("github_personal_access_token\\s*\\\":\\s*\\\"[^<G][^\\\"]+\\\""),
380 - Pattern.compile("oauth_(access|refresh)_token\\s*=\\s*\\S+"),
381 - Pattern.compile("Authorization\\s*[:=]\\s*Bearer\\s+[A-Za-z0-9._-]{20,}", Pattern.CASE_INSENSITIVE));
382 - for (var pattern : patterns) {
383 - var matcher = pattern.matcher(diff);
384 - if (matcher.find())
385 - throw fail("Potential plaintext secret in staged diff.");
386 - }
387 - }
389 383 static Path symlinks_file(Path root) throws Throwable {
390 384 var hostname = hostname();
391 385 var manifest = symlinks_manifest(root, hostname);
453 447 var target_path = expand_target(target);
454 448 if (Files.exists(target_path, LinkOption.NOFOLLOW_LINKS)) {
455 449 if (Files.isSymbolicLink(target_path)) {
456 - var actual = target_path.toRealPath();
457 - var expected = source_path.toRealPath();
458 - if (actual.equals(expected)) {
459 - log("\nOK {0} -> {1}.", emphasize_global(target_path.toString()), emphasize_local(source_path.toString()));
460 - return;
450 + if (!Files.exists(target_path)) {
451 + log("\nRELINK {0}: broken symlink.", emphasize_global(target_path.toString()));
452 + remove_owned_symlink(target_path);
453 + } else {
454 + var actual = target_path.toRealPath();
455 + var expected = source_path.toRealPath();
456 + if (actual.equals(expected)) {
457 + log("\nOK {0} -> {1}.", emphasize_global(target_path.toString()), emphasize_local(source_path.toString()));
458 + return;
460 + if (!actual.startsWith(root.toRealPath()))
461 + throw fail("Target symlink points outside dorkfiles: {0} -> {1}. Move it manually.", target_path, actual);
462 + log("\nRELINK {0}: {1} -> {2}.", emphasize_global(target_path.toString()), emphasize_local(actual.toString()), emphasize_local(expected.toString()));
463 + remove_owned_symlink(target_path);
462 - log("\nRELINK {0}: {1} -> {2}.", emphasize_global(target_path.toString()), emphasize_local(actual.toString()), emphasize_local(expected.toString()));
463 - Files.delete(target_path);
464 465 } else if (Files.exists(target_path)) {
465 466 var actual = target_path.toRealPath();
466 467 var expected = source_path.toRealPath();
468 469 log("\nOK {0} resolves to {1}.", emphasize_global(target_path.toString()), emphasize_local(source_path.toString()));
469 470 return;
471 - throw fail("Target exists but is not a symlink: {0}. Move it away or run clean first.", target_path);
472 + var backup = sibling_backup_path(target_path);
473 + var message = format("BACKUP {0} TO {1}.", target_path, backup);
474 + log("\n{0}", message);
475 + warn(message);
476 + Files.move(target_path, backup);
472 477 } else {
473 478 log("\nNOPE {0} exists, but it points into nirvana. Removing broken link!", target_path.toString());
474 479 Files.delete(target_path);
481 486 Files.createSymbolicLink(target_path, source_path);
489 + static void remove_owned_symlink(Path target_path) throws Throwable {
490 + if (!win32) {
491 + Files.delete(target_path);
492 + return;
494 + var retired = sibling_path(target_path, "replaced");
495 + Files.move(target_path, retired);
496 + try {
497 + Files.delete(retired);
498 + } catch (IOException error) {
499 + log("WIN32 kept retired link for later cleanup: {0}", retired);
503 + static Path sibling_backup_path(Path target_path) throws Throwable {
504 + return sibling_path(target_path, "backup");
507 + static Path sibling_path(Path target_path, String kind) throws Throwable {
508 + var stamp = DateTimeFormatter.ofPattern("yyyyMMdd-HHmmss").format(LocalDateTime.now());
509 + var base = target_path.resolveSibling(target_path.getFileName() + ".dorkfiles-" + kind + "-" + stamp);
510 + var candidate = base;
511 + var suffix = 1;
512 + while (Files.exists(candidate, LinkOption.NOFOLLOW_LINKS)) {
513 + candidate = Path.of(base + "." + suffix);
514 + suffix++;
516 + return candidate;
484 519 static Path expand_target(String target) {
485 520 var home = System.getProperty("user.home");
486 521 if ("~".equals(target))
561 596 return "\033[3m" + message + "\033[0m";
599 + static void warn(String message) {
600 + warnings.add(message);
603 + static void error(String message) {
604 + errors.add(message);
607 + static void print_attention(boolean fatal) {
608 + if (warnings.isEmpty() && errors.isEmpty())
609 + return;
610 + var color = fatal || !errors.isEmpty() ? "\033[31m" : "\033[33m";
611 + System.out.println();
612 + System.out.println(color + "ATTENTION");
613 + for (var warning : warnings)
614 + System.out.println("- " + warning);
615 + for (var error : errors)
616 + System.out.println("- " + error);
617 + System.out.println("\033[0m");
564 620 static Throwable fail(String message, Object... arguments) {
565 - log(message, arguments);
621 + error(format(message, arguments));
566 622 return fail();
569 625 static Throwable fail() {
626 + print_attention(true);
570 627 System.exit(-1);
571 628 return new Throwable("use 'throw fail()' for control flow");

desktop.symlinks

Modified
88 88 wezterm
89 89 ~/.config/wezterm
91 -tmux
92 -~/.config/tmux
94 91 ghostty
95 92 ~/.config/ghostty
124 121 pueue/pueued.service
125 122 ~/.config/systemd/user/pueued.service
124 +pueue/pueued.service
125 +~/.config/systemd/user/default.target.wants/pueued.service
127 127 wezterm/systemd/wezterm-mux-server.service
128 128 ~/.config/systemd/user/wezterm-mux-server.service
130 +wezterm/systemd/wezterm-mux-server.service
131 +~/.config/systemd/user/default.target.wants/wezterm-mux-server.service
130 133 psd/psd.conf
131 134 ~/.config/psd/psd.conf
136 +systemd/user/psd.service
137 +~/.config/systemd/user/psd.service
139 +systemd/user/psd.service
140 +~/.config/systemd/user/default.target.wants/psd.service

justfile

Modified
1 -set shell := ["nu", "--commands"]
3 -default:
4 - @just --list
6 -# initialize crypto, install hooks, verify, link dorkfiles into HOME
7 -link: nugu-linux-console nugu-hypr
8 - java bootstripper.java bootstrap
10 -# build generated files needed by linked shell config
11 -nugu-linux-console:
12 - just --justfile nugu/justfile --working-directory nugu linux-console
14 -nugu-hypr:
15 - just --justfile nugu/justfile --working-directory nugu hypr
17 -# verify crypto filters, hooks, and staged secrets
18 -check:
19 - java bootstripper.java check
21 -clean:
22 - java bootstripper.java clean
24 -# run the same checks as the Git pre-commit hook
25 -pre-commit:
26 - java bootstripper.java pre-commit
28 -# integration test in ephemeral rootless Podman Linux; fresh system deps: git + java
29 -# tests every *.symlinks manifest; primary hostname printed first for quick failure context
30 -test hostname="desktop":
31 - #!/usr/bin/env bash
32 - set -euo pipefail
34 - root="$(git rev-parse --show-toplevel)"
35 - key="$root/.git/dotfiles-aes.key"
36 - image="registry.fedoraproject.org/fedora:latest"
37 - container="dotfiles-integration-$(date +%Y%m%d%H%M%S)-$$"
39 - if [ ! -r "$key" ]; then
40 - echo "missing $key"
41 - exit 1
42 - fi
44 - trap 'podman rm -f "$container" >/dev/null 2>&1 || true' EXIT
46 - echo "container=$container"
47 - podman run --name "$container" --rm -i --hostname "{{hostname}}" \
48 - -e PRIMARY_HOSTNAME="{{hostname}}" \
49 - -v "$root:/src:ro" \
50 - -v "$key:/dotfiles-aes.key:ro" \
51 - "$image" bash -s <<'CONTAINER'
52 - set -euo pipefail
54 - ok() { echo "ok:$1"; }
55 - fail() { echo "FAIL:$1"; exit 1; }
57 - target_path() {
58 - local home="$1"
59 - local target="$2"
60 - if [[ "$target" == ~* ]]; then
61 - printf '%s%s\n' "$home" "${target:1}"
62 - else
63 - printf '%s\n' "$target"
64 - fi
65 - }
67 - targets_for() {
68 - awk '
69 - { sub(/\r$/, "") }
70 - NF == 0 { next }
71 - source == "" { source = $0; next }
72 - { print $0; source = "" }
73 - END { if (source != "") exit 2 }
74 - ' "$1"
75 - }
77 - run_manifest() {
78 - local host="$1"
79 - local manifest="$host.symlinks"
80 - local home="/tmp/home-$host"
81 - local bootstrap_log="/tmp/bootstrap-$host.log"
82 - local check_log="/tmp/check-$host.log"
83 - local clean_log="/tmp/clean-$host.log"
85 - echo "manifest=$manifest"
86 - rm -rf "$home"
87 - mkdir -p "$home"
89 - HOSTNAME="$host" java -Duser.home="$home" bootstripper.java bootstrap >"$bootstrap_log" 2>&1 || {
90 - echo "FAIL:bootstrap:$host"
91 - tail -120 "$bootstrap_log"
92 - exit 1
93 - }
94 - ok "bootstrap:$host"
96 - HOSTNAME="$host" java -Duser.home="$home" bootstripper.java check >"$check_log" 2>&1 || {
97 - echo "FAIL:check:$host"
98 - cat "$check_log"
99 - exit 1
100 - }
101 - ok "check:$host"
103 - while IFS= read -r target; do
104 - local path
105 - path="$(target_path "$home" "$target")"
106 - test -L "$path" || fail "link:$host:$target"
107 - done < <(targets_for "$manifest")
108 - ok "links:$host"
110 - HOSTNAME="$host" java -Duser.home="$home" bootstripper.java clean >"$clean_log" 2>&1 || {
111 - echo "FAIL:clean:$host"
112 - cat "$clean_log"
113 - exit 1
114 - }
115 - ok "clean:$host"
116 - }
118 - fresh_crypto_smoke() {
119 - local repo=/tmp/fresh-crypto
120 - rm -rf "$repo" /tmp/fresh-crypto-home
121 - mkdir -p "$repo/tools" /tmp/fresh-crypto-home
122 - cp bootstripper.java "$repo/"
123 - cp tools/aes.java "$repo/tools/"
124 - cd "$repo"
125 - git init --quiet
126 - printf 'secret.txt\n' > .secrets
127 - printf 'dummy.txt\n~/dummy.txt\n' > mini.symlinks
128 - printf 'not a real secret\n' > secret.txt
129 - printf 'dummy\n' > dummy.txt
131 - DOTFILES_AES_PASSPHRASE=test java bootstripper.java init-crypto >/tmp/fresh-init.log 2>&1 || { cat /tmp/fresh-init.log; fail fresh-init; }
132 - DOTFILES_AES_PASSPHRASE=test java bootstripper.java check >/tmp/fresh-check-1.log 2>&1 || { cat /tmp/fresh-check-1.log; fail fresh-check-1; }
133 - git add .dotfiles-aes-salt .secrets bootstripper.java tools/aes.java mini.symlinks dummy.txt secret.txt
134 - DOTFILES_AES_PASSPHRASE=test java bootstripper.java check >/tmp/fresh-check-2.log 2>&1 || { cat /tmp/fresh-check-2.log; fail fresh-check-2; }
135 - git show :secret.txt | head -c 6 | grep -qx DFAES1 || fail fresh-staged-encrypted
136 - HOSTNAME=mini DOTFILES_AES_PASSPHRASE=test java -Duser.home=/tmp/fresh-crypto-home bootstripper.java bootstrap >/tmp/fresh-bootstrap.log 2>&1 || { cat /tmp/fresh-bootstrap.log; fail fresh-bootstrap; }
137 - test -L /tmp/fresh-crypto-home/dummy.txt || fail fresh-link
138 - HOSTNAME=mini DOTFILES_AES_PASSPHRASE=test java -Duser.home=/tmp/fresh-crypto-home bootstripper.java clean >/tmp/fresh-clean.log 2>&1 || { cat /tmp/fresh-clean.log; fail fresh-clean; }
139 - ok fresh-crypto
140 - }
142 - printf 'rootless='
143 - awk 'NR == 1 { print ($1 == 0 && $2 != 0) ? "yes" : "unknown" }' /proc/self/uid_map
145 - if ! dnf -qy --setopt=install_weak_deps=False install git-core java-latest-openjdk-headless >/tmp/dnf.log 2>&1; then
146 - cat /tmp/dnf.log
147 - fail deps
148 - fi
149 - ok deps
150 - git --version
151 - java -version 2>&1 | sed -n '1p'
153 - mkdir -p /root/work
154 - git config --global --add safe.directory /src
155 - git clone --quiet --no-local /src /root/work/dotfiles || fail clone
156 - install -m 600 /dotfiles-aes.key /root/work/dotfiles/.git/dotfiles-aes.key
157 - cd /root/work/dotfiles
159 - java bootstripper.java install-hooks >/tmp/install-hooks.log 2>&1 || { cat /tmp/install-hooks.log; fail install-hooks; }
160 - test -x .git/hooks/pre-commit || fail hook-executable
161 - grep -qx 'exec java bootstripper.java pre-commit' .git/hooks/pre-commit || fail hook-content
162 - ok install-hooks
164 - git show HEAD:nushell/secrets.nu | head -c 6 | grep -qx DFAES1 || fail committed-encrypted
165 - ok committed-encrypted
167 - mapfile -t hosts < <(find . -maxdepth 1 -name '*.symlinks' -printf '%f\n' | sed 's/\.symlinks$//' | sort)
168 - printf 'primary-manifest=%s.symlinks\n' "$PRIMARY_HOSTNAME"
169 - printf 'manifests=%s\n' "${hosts[*]}"
171 - for host in "${hosts[@]}"; do
172 - run_manifest "$host"
173 - done
174 - ok "symlink-manifests:${#hosts[@]}"
176 - if head -c 6 nushell/secrets.nu | grep -qx DFAES1; then
177 - fail worktree-still-encrypted
178 - fi
179 - ok worktree-decrypted
181 - java bootstripper.java pre-commit >/tmp/precommit.log 2>&1 || { echo FAIL:pre-commit; cat /tmp/precommit.log; exit 1; }
182 - grep -q 'Skipping gitleaks: command not found' /tmp/precommit.log || fail gitleaks-optional
183 - ok pre-commit
185 - fresh_crypto_smoke
187 - echo RESULT:ok
188 - CONTAINER
190 -# create initial crypto salt
191 -init-crypto:
192 - java bootstripper.java init-crypto
194 -# install Git hooks
195 -hooks:
196 - java bootstripper.java install-hooks
198 -# enable some user systemd services
199 -services:
200 - nu enable_user_services.nu
202 -# remove links to dorkfiles from HOME
203 -unlink:
204 - java bootstripper.java clean
206 -# typically the initial git remote for the dotfiles repo is https
207 -# this command changes the remote to ssh
208 -ssh-remote:
209 - git remote rm origin
210 - git remote add origin git@github.com:bugabinga/dotfiles.git
211 - git fetch
212 - git branch --set-upstream-to=origin/trunk trunk
214 -# initial setup: link dotfiles, enable services, fix permissions
215 -setup: link services fix_permissions
217 -# install previously exported winget apps. see topgrade config for exports.
218 -import_winget:
219 - winget import C:/Users/okr/Tools/winget_installed_apps.json
221 -# fix some file permissions
222 -fix_permissions:
223 - let firefox_profile = ('~/.mozilla/firefox/qrza8u52.default-release' | path expand); if ($firefox_profile | path exists) { chmod 700 $firefox_profile }
1 +set shell := ["nu", "--commands"]
3 +default:
4 + @just --list
6 +# initialize crypto, install hooks, verify, link dorkfiles into HOME
7 +link:
8 + java bootstripper.java bootstrap
10 +# compile checked-in Quickshell shaders from source
11 +nugu-shaders:
12 + mkdir quickshell/nuguland/shaders
13 + /usr/lib/qt6/bin/qsb --glsl 330 --hlsl 50 --msl 12 -o quickshell/nuguland/shaders/aurora.frag.qsb quickshell/nuguland/shaders/aurora.frag
15 +# verify crypto filters, hooks, and staged secrets
16 +check:
17 + java bootstripper.java check
19 +clean:
20 + java bootstripper.java clean
22 +# run the same checks as the Git pre-commit hook
23 +pre-commit:
24 + java bootstripper.java pre-commit
26 +# integration test in ephemeral rootless Podman Linux; fresh system deps: git + java
27 +# tests every *.symlinks manifest; primary hostname printed first for quick failure context
28 +test hostname="desktop":
29 + #!/usr/bin/env bash
30 + set -euo pipefail
32 + root="$(git rev-parse --show-toplevel)"
33 + key="$root/.git/dotfiles-aes.key"
34 + image="registry.fedoraproject.org/fedora:latest"
35 + container="dotfiles-integration-$(date +%Y%m%d%H%M%S)-$$"
37 + if [ ! -r "$key" ]; then
38 + echo "missing $key"
39 + exit 1
40 + fi
42 + trap 'podman rm -f "$container" >/dev/null 2>&1 || true' EXIT
44 + echo "container=$container"
45 + podman run --name "$container" --rm -i --hostname "{{hostname}}" \
46 + -e PRIMARY_HOSTNAME="{{hostname}}" \
47 + -v "$root:/src:ro" \
48 + -v "$key:/dotfiles-aes.key:ro" \
49 + "$image" bash -s <<'CONTAINER'
50 + set -euo pipefail
52 + ok() { echo "ok:$1"; }
53 + fail() { echo "FAIL:$1"; exit 1; }
55 + target_path() {
56 + local home="$1"
57 + local target="$2"
58 + if [[ "$target" == ~* ]]; then
59 + printf '%s%s\n' "$home" "${target:1}"
60 + else
61 + printf '%s\n' "$target"
62 + fi
63 + }
65 + targets_for() {
66 + awk '
67 + { sub(/\r$/, "") }
68 + NF == 0 { next }
69 + source == "" { source = $0; next }
70 + { print $0; source = "" }
71 + END { if (source != "") exit 2 }
72 + ' "$1"
73 + }
75 + run_manifest() {
76 + local host="$1"
77 + local manifest="$host.symlinks"
78 + local home="/tmp/home-$host"
79 + local bootstrap_log="/tmp/bootstrap-$host.log"
80 + local check_log="/tmp/check-$host.log"
81 + local clean_log="/tmp/clean-$host.log"
83 + echo "manifest=$manifest"
84 + rm -rf "$home"
85 + mkdir -p "$home"
87 + HOSTNAME="$host" java -Duser.home="$home" bootstripper.java bootstrap >"$bootstrap_log" 2>&1 || {
88 + echo "FAIL:bootstrap:$host"
89 + tail -120 "$bootstrap_log"
90 + exit 1
91 + }
92 + ok "bootstrap:$host"
94 + HOSTNAME="$host" java -Duser.home="$home" bootstripper.java check >"$check_log" 2>&1 || {
95 + echo "FAIL:check:$host"
96 + cat "$check_log"
97 + exit 1
98 + }
99 + ok "check:$host"
101 + while IFS= read -r target; do
102 + local path
103 + path="$(target_path "$home" "$target")"
104 + test -L "$path" || fail "link:$host:$target"
105 + done < <(targets_for "$manifest")
106 + ok "links:$host"
108 + HOSTNAME="$host" java -Duser.home="$home" bootstripper.java clean >"$clean_log" 2>&1 || {
109 + echo "FAIL:clean:$host"
110 + cat "$clean_log"
111 + exit 1
113 + ok "clean:$host"
116 + fresh_crypto_smoke() {
117 + local repo=/tmp/fresh-crypto
118 + rm -rf "$repo" /tmp/fresh-crypto-home
119 + mkdir -p "$repo/tools" /tmp/fresh-crypto-home
120 + cp bootstripper.java "$repo/"
121 + cp tools/aes.java "$repo/tools/"
122 + cd "$repo"
123 + git init --quiet
124 + printf 'secret.txt\n' > .secrets
125 + printf 'dummy.txt\n~/dummy.txt\n' > mini.symlinks
126 + printf 'not a real secret\n' > secret.txt
127 + printf 'dummy\n' > dummy.txt
129 + DOTFILES_AES_PASSPHRASE=test java bootstripper.java init-crypto >/tmp/fresh-init.log 2>&1 || { cat /tmp/fresh-init.log; fail fresh-init; }
130 + DOTFILES_AES_PASSPHRASE=test java bootstripper.java check >/tmp/fresh-check-1.log 2>&1 || { cat /tmp/fresh-check-1.log; fail fresh-check-1; }
131 + git add .dotfiles-aes-salt .secrets bootstripper.java tools/aes.java mini.symlinks dummy.txt secret.txt
132 + DOTFILES_AES_PASSPHRASE=test java bootstripper.java check >/tmp/fresh-check-2.log 2>&1 || { cat /tmp/fresh-check-2.log; fail fresh-check-2; }
133 + git show :secret.txt | head -c 6 | grep -qx DFAES1 || fail fresh-staged-encrypted
134 + HOSTNAME=mini DOTFILES_AES_PASSPHRASE=test java -Duser.home=/tmp/fresh-crypto-home bootstripper.java bootstrap >/tmp/fresh-bootstrap.log 2>&1 || { cat /tmp/fresh-bootstrap.log; fail fresh-bootstrap; }
135 + test -L /tmp/fresh-crypto-home/dummy.txt || fail fresh-link
136 + HOSTNAME=mini DOTFILES_AES_PASSPHRASE=test java -Duser.home=/tmp/fresh-crypto-home bootstripper.java clean >/tmp/fresh-clean.log 2>&1 || { cat /tmp/fresh-clean.log; fail fresh-clean; }
137 + ok fresh-crypto
140 + printf 'rootless='
141 + awk 'NR == 1 { print ($1 == 0 && $2 != 0) ? "yes" : "unknown" }' /proc/self/uid_map
143 + if ! dnf -qy --setopt=install_weak_deps=False install git-core java-latest-openjdk-headless >/tmp/dnf.log 2>&1; then
144 + cat /tmp/dnf.log
145 + fail deps
146 + fi
147 + ok deps
148 + git --version
149 + java -version 2>&1 | sed -n '1p'
151 + mkdir -p /root/work
152 + git config --global --add safe.directory /src
153 + git clone --quiet --no-local /src /root/work/dotfiles || fail clone
154 + install -m 600 /dotfiles-aes.key /root/work/dotfiles/.git/dotfiles-aes.key
155 + cd /root/work/dotfiles
157 + java bootstripper.java install-hooks >/tmp/install-hooks.log 2>&1 || { cat /tmp/install-hooks.log; fail install-hooks; }
158 + test -x .git/hooks/pre-commit || fail hook-executable
159 + grep -qx 'exec java bootstripper.java pre-commit' .git/hooks/pre-commit || fail hook-content
160 + ok install-hooks
162 + git show HEAD:nushell/secrets.nu | head -c 6 | grep -qx DFAES1 || fail committed-encrypted
163 + ok committed-encrypted
165 + mapfile -t hosts < <(find . -maxdepth 1 -name '*.symlinks' -printf '%f\n' | sed 's/\.symlinks$//' | sort)
166 + printf 'primary-manifest=%s.symlinks\n' "$PRIMARY_HOSTNAME"
167 + printf 'manifests=%s\n' "${hosts[*]}"
169 + for host in "${hosts[@]}"; do
170 + run_manifest "$host"
171 + done
172 + ok "symlink-manifests:${#hosts[@]}"
174 + if head -c 6 nushell/secrets.nu | grep -qx DFAES1; then
175 + fail worktree-still-encrypted
176 + fi
177 + ok worktree-decrypted
179 + java bootstripper.java pre-commit >/tmp/precommit.log 2>&1 || { echo FAIL:pre-commit; cat /tmp/precommit.log; exit 1; }
180 + ok pre-commit
182 + fresh_crypto_smoke
184 + echo RESULT:ok
185 + CONTAINER
187 +# create initial crypto salt
188 +init-crypto:
189 + java bootstripper.java init-crypto
191 +# install Git hooks
192 +hooks:
193 + java bootstripper.java install-hooks
195 +# remove links to dorkfiles from HOME
196 +unlink:
197 + java bootstripper.java clean
199 +# typically the initial git remote for the dotfiles repo is https
200 +# this command changes the remote to ssh
201 +ssh-remote:
202 + git remote rm origin
203 + git remote add origin git@github.com:bugabinga/dotfiles.git
204 + git fetch
205 + git branch --set-upstream-to=origin/trunk trunk
207 +# initial setup: link dotfiles, fix permissions
208 +setup: link fix_permissions
210 +# install previously exported winget apps. see topgrade config for exports.
211 +import_winget:
212 + winget import C:/Users/okr/Tools/winget_installed_apps.json
214 +# fix some file permissions
215 +fix_permissions:
216 + let firefox_profile = ('~/.mozilla/firefox/qrza8u52.default-release' | path expand); if ($firefox_profile | path exists) { chmod 700 $firefox_profile }

systemd/user/psd.service

Added
new file mode 100644
1 +[Unit]
2 +Description=Profile-sync-daemon
3 +Documentation=man:psd(1) man:profile-sync-daemon(1)
4 +Wants=psd-resync.timer
5 +RequiresMountsFor=/home/
6 +After=winbindd.service
8 +[Service]
9 +Slice=background.slice
10 +Type=oneshot
11 +RemainAfterExit=yes
12 +ExecStart=/usr/bin/profile-sync-daemon startup
13 +ExecStartPost=/usr/bin/profile-sync-daemon resync
14 +ExecStop=/usr/bin/profile-sync-daemon unsync
15 +Environment=LAUNCHED_BY_SYSTEMD=1
17 +[Install]
18 +WantedBy=default.target