From 260de21b6a1496babf7e8c7f18a1e1a6f7a7cac1 Mon Sep 17 00:00:00 2001 From: Claude Date: Thu, 16 Apr 2026 21:57:33 +0000 Subject: [PATCH 1/4] fix(ci): make shell-inline-check iterate lines in order and drop dolt inline script The awk check used `for (i in lines)` which has undefined iteration order, so continuation lines were often checked before the bash-delegate line, producing false positives on every multi-line `home.activation` block. Iterate 1..n so the bash-call gate flips before its continuations are seen. Also extract the dolt startScript to an external start.sh referenced via pkgs.replaceVars, matching the pattern used by obsidian/docker services. --- home-manager/services/dolt/default.nix | 32 +++++++------------------- home-manager/services/dolt/start.sh | 24 +++++++++++++++++++ scripts/check-nix-inline-scripts.sh | 6 ++--- 3 files changed, 35 insertions(+), 27 deletions(-) create mode 100644 home-manager/services/dolt/start.sh diff --git a/home-manager/services/dolt/default.nix b/home-manager/services/dolt/default.nix index 350628085..608c00711 100644 --- a/home-manager/services/dolt/default.nix +++ b/home-manager/services/dolt/default.nix @@ -11,30 +11,14 @@ let repoDir = "${homeDir}/dotfiles"; beadsDir = "${repoDir}/.beads"; enabled = isKyber || isGalactica; - startScript = pkgs.writeShellScript "dotfiles-dolt-start.sh" '' - set -euo pipefail - - mkdir -p "${beadsDir}" - - if [ -d "${beadsDir}/dolt" ] && [ ! -L "${beadsDir}/dolt" ]; then - if [ -e "${beadsDir}/df" ]; then - echo "Refusing to migrate ${beadsDir}/dolt because ${beadsDir}/df already exists" >&2 - exit 1 - fi - - mv -f "${beadsDir}/dolt" "${beadsDir}/df" - fi - - if [ -d "${beadsDir}/df" ]; then - ln -sfn df "${beadsDir}/dolt" - fi - - exec "${pkgs.dolt}/bin/dolt" sql-server \ - -H 127.0.0.1 \ - -P 3307 \ - --data-dir "${beadsDir}" \ - --loglevel info - ''; + startScript = pkgs.writeShellScript "dotfiles-dolt-start.sh" ( + builtins.readFile ( + pkgs.replaceVars ./start.sh { + inherit beadsDir; + inherit (pkgs) dolt; + } + ) + ); in lib.mkIf enabled { launchd.agents.dolt = lib.mkIf pkgs.stdenv.isDarwin { diff --git a/home-manager/services/dolt/start.sh b/home-manager/services/dolt/start.sh new file mode 100644 index 000000000..e55cbbe0b --- /dev/null +++ b/home-manager/services/dolt/start.sh @@ -0,0 +1,24 @@ +#!/usr/bin/env bash +# @beadsDir@ and @dolt@ are substituted by pkgs.replaceVars. +set -euo pipefail + +mkdir -p "@beadsDir@" + +if [ -d "@beadsDir@/dolt" ] && [ ! -L "@beadsDir@/dolt" ]; then + if [ -e "@beadsDir@/df" ]; then + echo "Refusing to migrate @beadsDir@/dolt because @beadsDir@/df already exists" >&2 + exit 1 + fi + + mv -f "@beadsDir@/dolt" "@beadsDir@/df" +fi + +if [ -d "@beadsDir@/df" ]; then + ln -sfn df "@beadsDir@/dolt" +fi + +exec "@dolt@/bin/dolt" sql-server \ + -H 127.0.0.1 \ + -P 3307 \ + --data-dir "@beadsDir@" \ + --loglevel info diff --git a/scripts/check-nix-inline-scripts.sh b/scripts/check-nix-inline-scripts.sh index 0a9de20ca..41fdcbade 100755 --- a/scripts/check-nix-inline-scripts.sh +++ b/scripts/check-nix-inline-scripts.sh @@ -52,12 +52,12 @@ while IFS= read -r nix_file; do return line ~ /^(\$DRY_RUN_CMD[[:space:]]+)?[^[:space:];|&<>`]*bin\/bash([[:space:]]+(".*"|\$\{.*\}|[^[:space:];|&<>`]+))+([[:space:]]+\|\|[[:space:]]+true)?[[:space:]]*\\?$/ } - function block_has_violation( i, line, saw_bash_call, saw_content) { + function block_has_violation( i, n, line, saw_bash_call, saw_content) { saw_bash_call = 0 saw_content = 0 - split(body, lines, "\n") + n = split(body, lines, "\n") - for (i in lines) { + for (i = 1; i <= n; i++) { line = trim(lines[i]) if (line == "" || line ~ /^#/) continue From 0c509282a113b72d0b773b5efedaf62ff5b6cea4 Mon Sep 17 00:00:00 2001 From: Claude Date: Thu, 16 Apr 2026 22:13:50 +0000 Subject: [PATCH 2/4] test(dolt): add spec and coverage entry for dolt/start.sh The coverage_spec.sh diffs `git ls-files '*.sh'` against the covered_scripts allowlist and fails shell-test if either side has an entry the other doesn't. Register the new script and add a basic spec covering shebang, strict mode, placeholder tokens, migration behavior, and sql-server flags. --- spec/coverage_spec.sh | 5 +++ spec/dolt_start_spec.sh | 70 +++++++++++++++++++++++++++++++++++++++++ 2 files changed, 75 insertions(+) create mode 100644 spec/dolt_start_spec.sh diff --git a/spec/coverage_spec.sh b/spec/coverage_spec.sh index 63f6606c1..5650a0a25 100644 --- a/spec/coverage_spec.sh +++ b/spec/coverage_spec.sh @@ -188,6 +188,10 @@ End It 'has spec file for home-manager/services/docker/docker-setup.sh' The path "spec/docker_setup_wrapper_spec.sh" should be exist End + +It 'has spec file for home-manager/services/dolt/start.sh' +The path "spec/dolt_start_spec.sh" should be exist +End It 'has spec file for nix-darwin/services/pmset-battery-policy/power-policy.sh' The path "spec/pmset_battery_policy_spec.sh" should be exist End @@ -402,6 +406,7 @@ home-manager/services/docker-postgres/start-postgres-wrapper.sh home-manager/services/docker-postgres/start-postgres.sh home-manager/services/docker/docker-setup.sh home-manager/services/docker/setup-docker.sh +home-manager/services/dolt/start.sh home-manager/services/dotfiles-updater/update.sh home-manager/services/gas-town/start.sh home-manager/services/make-updater/update.sh diff --git a/spec/dolt_start_spec.sh b/spec/dolt_start_spec.sh new file mode 100644 index 000000000..5b29f478b --- /dev/null +++ b/spec/dolt_start_spec.sh @@ -0,0 +1,70 @@ +#!/usr/bin/env bash +# shellcheck disable=SC2329 + +Describe 'home-manager/services/dolt/start.sh' +SCRIPT="$PWD/home-manager/services/dolt/start.sh" + +Describe 'script properties' +It 'uses bash shebang' +When run bash -c "head -1 '$SCRIPT'" +The output should include '#!/usr/bin/env bash' +End + +It 'uses strict mode' +When run bash -c "grep 'set -euo pipefail' '$SCRIPT'" +The output should include 'set -euo pipefail' +End + +It 'passes bash syntax check after stripping placeholders' +When run bash -c "sed 's|@[a-z_]*@|/usr|g' '$SCRIPT' | bash -n" +The status should be success +End +End + +Describe 'placeholder substitutions' +It 'references @beadsDir@' +When run bash -c "grep '@beadsDir@' '$SCRIPT'" +The output should include '@beadsDir@' +End + +It 'references @dolt@' +When run bash -c "grep '@dolt@' '$SCRIPT'" +The output should include '@dolt@' +End +End + +Describe 'dolt migration behavior' +It 'migrates legacy dolt directory to df' +When run bash -c "grep 'mv -f' '$SCRIPT'" +The output should include 'mv -f' +End + +It 'symlinks dolt to df for backwards compatibility' +When run bash -c "grep 'ln -sfn df' '$SCRIPT'" +The output should include 'ln -sfn df' +End + +It 'refuses to overwrite an existing df directory' +When run bash -c "grep 'Refusing to migrate' '$SCRIPT'" +The output should include 'Refusing to migrate' +End +End + +Describe 'sql-server invocation' +It 'binds to localhost' +When run bash -c "grep -- '-H 127.0.0.1' '$SCRIPT'" +The output should include '-H 127.0.0.1' +End + +It 'listens on port 3307' +When run bash -c "grep -- '-P 3307' '$SCRIPT'" +The output should include '-P 3307' +End + +It 'points --data-dir at the beads directory' +When run bash -c "grep -- '--data-dir' '$SCRIPT'" +The output should include '--data-dir' +End +End + +End From f5d833f7ff3c474c95870a14e3f873a7717103a3 Mon Sep 17 00:00:00 2001 From: Claude Date: Fri, 17 Apr 2026 08:04:42 +0000 Subject: [PATCH 3/4] fix(dolt): stringify startScript derivation for launchd ProgramArguments nix-darwin on galactica was failing with: definition for option `launchd.agents.dolt.config.ProgramArguments' is not of type `string'. Definition value: `pkgs.writeShellScript` returns a derivation; ProgramArguments expects strings, so interpolate to coerce to the store path, matching the pattern used by cliproxyapi/tmux-session-logger/code-syncer. Also widen the placeholder-stripping regex in dolt_start_spec.sh so it catches camelCase tokens like @beadsDir@ (previously only lowercase was stripped, making the bash -n smoke test weaker than intended). --- home-manager/services/dolt/default.nix | 2 +- spec/dolt_start_spec.sh | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/home-manager/services/dolt/default.nix b/home-manager/services/dolt/default.nix index 608c00711..bdd909fe1 100644 --- a/home-manager/services/dolt/default.nix +++ b/home-manager/services/dolt/default.nix @@ -24,7 +24,7 @@ lib.mkIf enabled { launchd.agents.dolt = lib.mkIf pkgs.stdenv.isDarwin { enable = true; config = { - ProgramArguments = [ startScript ]; + ProgramArguments = [ "${startScript}" ]; KeepAlive = true; RunAtLoad = true; WorkingDirectory = repoDir; diff --git a/spec/dolt_start_spec.sh b/spec/dolt_start_spec.sh index 5b29f478b..37c94cd8f 100644 --- a/spec/dolt_start_spec.sh +++ b/spec/dolt_start_spec.sh @@ -16,7 +16,7 @@ The output should include 'set -euo pipefail' End It 'passes bash syntax check after stripping placeholders' -When run bash -c "sed 's|@[a-z_]*@|/usr|g' '$SCRIPT' | bash -n" +When run bash -c "sed 's|@[A-Za-z_][A-Za-z0-9_]*@|/usr|g' '$SCRIPT' | bash -n" The status should be success End End From dc7a8c00539dee9fa0fea1df20ece7dccf817d1d Mon Sep 17 00:00:00 2001 From: Claude Date: Fri, 17 Apr 2026 08:22:16 +0000 Subject: [PATCH 4/4] fix(fish-test): drop stray 'test' prefix in tmux bootstrap assertions fishtape wraps the remaining arguments of @test with `test`, so @test "unknown session returns failure" test \$unknown_status -ne 0 expanded to `test test 1 -ne 0` (5 args) which fish's test rejects, causing shell-test to fail since PR #1479 introduced this spec. Drop the literal `test` so fishtape produces `test 1 -ne 0`. --- spec/fish/__tmux_bootstrap_default_session_test.fish | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/spec/fish/__tmux_bootstrap_default_session_test.fish b/spec/fish/__tmux_bootstrap_default_session_test.fish index 28ce8fca5..03ed9febe 100644 --- a/spec/fish/__tmux_bootstrap_default_session_test.fish +++ b/spec/fish/__tmux_bootstrap_default_session_test.fish @@ -34,7 +34,7 @@ end __tmux_bootstrap_default_session unknown >/dev/null 2>/dev/null set unknown_status $status -@test "unknown session returns failure" test $unknown_status -ne 0 -@test "unknown session does not touch tmux" test ! -s $log_unknown +@test "unknown session returns failure" $unknown_status -ne 0 +@test "unknown session does not touch tmux" ! -s $log_unknown rm -f $log_primary $log_work $log_unknown