don't GC other profiles

This commit is contained in:
Henry Hiles 2026-11-16 20:25:13 -05:00
commit 6e8da25d92
Signed by: Henry-Hiles
SSH key fingerprint: SHA256:VKQUdS31Q90KvX7EkKMHMBpUspcmItAh86a+v7PGiIs

View file

@ -1,4 +1,9 @@
{ pkgs, lib, ... }: {
config,
pkgs,
lib,
...
}:
let let
aliases = { aliases = {
upgrade = "nh os switch --update"; upgrade = "nh os switch --update";
@ -23,8 +28,15 @@ in
( (
command: host: command: host:
pkgs.writeShellScriptBin command '' 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" ( ${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} ) aliases}
"$@" "$@"