From 6e8da25d92d739b78bde692737d26c2336e4bc52 Mon Sep 17 00:00:00 2001 From: Henry-Hiles Date: Mon, 16 Nov 2026 20:25:13 -0500 Subject: [PATCH] don't GC other profiles --- modules/common/nh.nix | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/modules/common/nh.nix b/modules/common/nh.nix index b161d99..fe5ce74 100644 --- a/modules/common/nh.nix +++ b/modules/common/nh.nix @@ -1,4 +1,9 @@ -{ pkgs, lib, ... }: +{ + config, + pkgs, + lib, + ... +}: let aliases = { upgrade = "nh os switch --update"; @@ -23,8 +28,15 @@ in ( command: host: pkgs.writeShellScriptBin command '' + # Stop other systems from getting GC'd + keep() { + path=$(nix build --no-link --print-out-paths \ + "${config.programs.nh.flake}#nixosConfigurations.${host}.config.system.build.toplevel") + sudo nix-env --profile /nix/var/nix/profiles/${host} --set "$path" + } + ${lib.concatMapAttrsStringSep "\n" ( - name: cmd: ''${name}() { ${cmd} -H ${host} --target-host ${command} --diff never "$@"; }'' + name: cmd: ''${name}() { ${cmd} -H ${host} --target-host ${command} --diff never "$@" && keep; }'' ) aliases} "$@"