From 48fcf9307624388d555e82584eb0c477841c6cb2 Mon Sep 17 00:00:00 2001 From: Martin Fischer Date: Sat, 20 Sep 2025 12:51:20 +0200 Subject: fix: make rebuild register host-specific gcroots --- nixos/.gitignore | 2 +- 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" +) -- cgit v1.2.3