diff options
author | Martin Fischer <martin@push-f.com> | 2025-09-20 12:51:20 +0200 |
---|---|---|
committer | Martin Fischer <martin@push-f.com> | 2025-09-20 14:40:47 +0200 |
commit | 48fcf9307624388d555e82584eb0c477841c6cb2 (patch) | |
tree | 3c67cdf2146be005f7d2ef3eed6e040eca598332 /nixos/rebuild | |
parent | e7e650a26f6f50ce75c8baa4868eeca7c3190e12 (diff) |
fix: make rebuild register host-specific gcroots
Diffstat (limited to 'nixos/rebuild')
-rwxr-xr-x | nixos/rebuild | 15 |
1 files changed, 10 insertions, 5 deletions
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" +) |