diff options
-rw-r--r-- | nixos/.gitignore | 2 | ||||
-rwxr-xr-x | nixos/rebuild | 15 |
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" +) |