aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMartin Fischer <martin@push-f.com>2025-09-20 12:51:20 +0200
committerMartin Fischer <martin@push-f.com>2025-09-20 14:40:47 +0200
commit48fcf9307624388d555e82584eb0c477841c6cb2 (patch)
tree3c67cdf2146be005f7d2ef3eed6e040eca598332
parente7e650a26f6f50ce75c8baa4868eeca7c3190e12 (diff)
fix: make rebuild register host-specific gcroots
-rw-r--r--nixos/.gitignore2
-rwxr-xr-xnixos/rebuild15
2 files changed, 11 insertions, 6 deletions
diff --git a/nixos/.gitignore b/nixos/.gitignore
index c4a847d..06d39e8 100644
--- a/nixos/.gitignore
+++ b/nixos/.gitignore
@@ -1 +1 @@
-/result
+/hosts/*/result
diff --git a/nixos/rebuild b/nixos/rebuild
index d902bd8..9e62b33 100755
--- a/nixos/rebuild
+++ b/nixos/rebuild
@@ -23,8 +23,13 @@ nixpkgsPath=$(
'
)
-# FIXME: change into host directory for host-specific garbage collector roots
-cd "$top"
-# nixos-rebuild always reads Nixpkgs from the NIX_PATH,
-# so we need to set it explicitly to our pinned version
-exec nixos-rebuild "$@" -I nixpkgs="$nixpkgsPath" -I nixos-config="$configPath" -I top="$top"
+(
+ # The result symlink created in the current directory is registered as a root of the Nix
+ # garbage collector, so it's important that we call nixos-rebuild from the host directory.
+ # (nix-build has an --out-link option but that option cannot be set via nixos-rebuild).
+ cd $top/hosts/$HOSTNAME &&
+
+ # nixos-rebuild always reads Nixpkgs from the NIX_PATH,
+ # so we need to set it explicitly to our pinned version
+ exec nixos-rebuild "$@" -I nixpkgs="$nixpkgsPath" -I nixos-config="$configPath" -I top="$top"
+)