13 writeShellApplication {
14 name = "${hostName}-switch";
19 # shellcheck disable=SC2027
20 # shellcheck disable=SC2035
21 # shellcheck disable=SC2086
25 chmod -R g-rwx,o-rwx ./**/*.gpg
26 trap 'git reset ./**/*.gpg' EXIT
27 git rm -rf --cached --ignore-unmatch ./**/*.gpg # prevent copying to /nix/store
29 nix-store --add-root hosts/${hostName}.nixpkgs --indirect --realise ${nixpkgsPath}
30 nix-store --add-root hosts/${hostName}.root --indirect --realise ${build.toplevel}
32 nix copy --to ssh://${config.install.target}"?''${targetStore-}"${lib.optionalString config.install.substituteOnDestination " --substitute-on-destination"} ${build.toplevel}
34 if ssh ${config.install.target} set -x ';' \
35 systemctl reset-failed nixos-fallback '2>/dev/null' ';' \
36 test "''${NO_NIXOS_FALLBACK:+set}" '||' \
37 systemd-run -u nixos-fallback --description=nixos-fallback /bin/sh -xc '''\'''
46 ${profile}/bin/switch-to-configuration switch
49 ${build.toplevel}/bin/switch-to-configuration test
51 ssh ${config.install.target} -o ControlPath=none set -x ';' \
52 systemctl stop nixos-fallback.service ';' \
53 nix-env --profile ${profile} --set '${build.toplevel}' ';' \
54 ${build.toplevel}/bin/switch-to-configuration boot '&&' \
55 nix-env --delete-generations 7d --profile ${profile}
58 echo WARNING: switch-to-configuration was not registered at boot
60 ssh ${config.install.target} -o ControlPath=none set -x ';' \
61 systemctl stop nixos-fallback.service