fix(nixos-deploy): stop wrapping sudo in runtimeInputs (closes #138) #139
No reviewers
Labels
No labels
area:authentication
area:flake-utilities
area:performance
area:tbd
host:chaos
host:electra
host:fleet
host:lyra
host:nova
host:vega
investigation
phase:cutover
phase:deploy
phase:mcp
phase:module
phase:packaging
phase:prep
phase:validation
priority:high
priority:medium
project:attic-postgres-lyra-rollout
project:auto-update-reliability
project:auto-update-remediation
project:declarative-purity-cleanup
project:external-review
project:fleet-boundary-cleanup
project:host-facts-refactor
project:lyra-nixos-deploy
project:lyra-service-stack-migration
project:nebula-mesh-network
project:nixos-build-deployment-pipeline
project:security-hardening
project:service-stack-migration
project:vega-sillytavern-cutover
project:wiki-rebuild
repo:numtide/flake-utils
repo:numtide/nix-auth
repo:numtide/nixos-passthru-cache
repo:numtide/nix-relay
service:auto-update
service:mem0
service:nix
service:sillytavern
service:slskd
service:synthseek
No milestone
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
nimmo/nixos-config!139
Loading…
Reference in a new issue
No description provided.
Delete branch "fix/nixos-deploy-sudo-path"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Goal
Restore the pre-PR-#125 behaviour of
just deploy(usesnom, can run as anon-root user via the system setuid sudo wrapper) while keeping the new
packages/nixos-deployNix package that replaced the inline Justfile bash.Root cause
PR #125 moved the long inline bash recipe from
justfiles/deploy.justintoscripts/nixos-deploy.shand packaged it aspackages/nixos-deploy/default.nix(writeShellApplicationwithruntimeInputs = [ coreutils hostname nix nvd nix-output-monitor openssh sudo ]).The script still does the right things when invoked directly. However,
just deploynow shells out tonix run .#nixos-deploy -- ..., and thewriteShellApplicationwrapper hard-codes a PATH that begins with thestore sudo (
/nix/store/...-sudo-1.9.17p2/bin/sudo, mode 0555, notsetuid) before the user's PATH. The setuid sudo lives at
/run/wrappers/bin/sudo(mode 4551) and is only first on PATH in anormal terminal session, where
/etc/set-environmentdoesexport PATH="/run/wrappers/bin:$PATH".Symptom:
just deployaborts atsudo -vwithsudo: /run/current-system/sw/bin/sudo must be owned by uid 0 and have the setuid bit set— i.e. it "complains about not being root". It alsolooks like
just deployno longer usesnom, because the Justfilenow only calls
nix run .#nixos-deploy; thenom buildcall is buriedinside the packaged script and never runs.
Change
packages/nixos-deploy/default.nix: dropsudofrom the functioninputs and from
runtimeInputs. Add a comment explaining why.tests/nixos-deploy-wrapper-regressions.sh(new): evaluates thepackage's
textattribute vianix evaland pins the wrapped PATHcontract — it must keep
$PATHand must not contain asudo-<digit>segment. The test fails against the pre-fix wrapper and passes against
the fixed wrapper.
README.md: note thatsudois intentionally omitted from thewrapper's runtime inputs and that
NIXOS_DEPLOY_SUDOremains theexplicit override.
The script still honours
NIXOS_DEPLOY_SUDO(and the otherNIXOS_DEPLOY_*env vars) for explicit overrides.Validation
bash tests/nixos-deploy-regressions.sh✓bash tests/nixos-deploy-wrapper-regressions.sh✓ (verified to failagainst the pre-fix wrapper text, pass against the fixed wrapper)
shellcheck scripts/nixos-deploy.sh tests/nixos-deploy-regressions.sh tests/nixos-deploy-wrapper-regressions.shcleannix flake check✓Live deployment evidence
None yet — the fix changes the wrapper's PATH contract, not the deployed
system. After merge, the natural canary is
just deployfrom a normalterminal on electra (which uses
/etc/set-environmentand so already has/run/wrappers/binfirst on PATH). Per repo policy, no live canary wasattempted before opening the MR.
Closes #138.
Automated code review
Reviewed commit:
34815882727ab1d25547eb726b9043772d1fde45Verdict: Ready to merge
No blocking or important findings were retained, and deterministic checks passed. Suggestions remain advisory.
Overall assessment
The PR removes
sudofrom thenixos-deploypackage'sruntimeInputsto prevent the store-bundled sudo (mode 0555) from shadowing the system setuid wrapper at/run/wrappers/bin/sudo. This resolves issue #138 where non-root deployments failed. The change is documented in README.md and accompanied by a regression test that validates the wrapper's PATH construction against the store sudo path while confirming required tools remain present. flake.lock contains routine dependency updates.Blocking findings
None.
Important findings
None.
Suggestions
Regression test relies on external
nixCLI and--impureevaluation (tests/nixos-deploy-wrapper-regressions.sh:28; high confidence)if ! command -v nix >/dev/null 2>&1; then\n echo "nix is required for this regression test" >&2\n exit 1\nfi...\nnix eval --raw --impure --expr '...'
Impact: Test execution will fail in restricted CI sandboxes, offline environments, or when the
nixCLI is not provisioned.Suggested fix: Verify that the CI workflow explicitly provisions
nix, or consider integrating the evaluation intonix flake checkif it aligns with repository testing standards.Hardcoded tool assertions may require maintenance on Nixpkgs updates (tests/nixos-deploy-wrapper-regressions.sh:85; high confidence)
for tool in coreutils hostname nix nvd nix-output-monitor openssh; do\n assert_contains "$tool"\ndone
Impact: Future Nixpkgs renames, splits, or deprecations of these packages will cause the regression test to fail unnecessarily.
Suggested fix: Consider deriving the expected tools dynamically from
runtimeInputsin the Nix expression, or document that this list requires review during Nixpkgs bumps.Tests and validation
Questions
just test), or does it currently rely on manual execution?nixos-deployfor all architectures supported by this repository, given the test usesbuiltins.currentSystemto resolve the package?Review limitations
flake.lockcontains numerous dependency updates; their individual security and compatibility impacts were not assessed beyond format validation.Diff coverage
README.md: reviewed — included in a context-limited batchflake.lock: reviewed — included in a context-limited batchpackages/nixos-deploy/default.nix: reviewed — included in a context-limited batchtests/nixos-deploy-wrapper-regressions.sh: reviewed — included in a context-limited batchReview metadata
c8c6d2075c12b8e0d6cf