flake.nix: format, remove exec, check if hostname is correct

This commit is contained in:
Sandro - 2021-10-27 21:25:00 +02:00
parent 1460fa8131
commit df2549e712
Signed by: sandro
GPG Key ID: 3AF5A43A3EECC2E5
1 changed files with 10 additions and 9 deletions

View File

@ -136,22 +136,23 @@
# Can be run with `nix run c3d2#…-nixos-rebuild switch`
"${name}-nixos-rebuild" = pkgs.writeScriptBin "${name}-nixos-rebuild" ''
#!${pkgs.runtimeShell} -e
[[ $(ssh ${target} cat /etc/hostname) == ${name} ]]
nix copy --to ssh://${target} ${secrets}
nix copy --to ssh://${target} ${self}
exec ssh ${target} nixos-rebuild ${rebuildArg} $@
ssh ${target} nixos-rebuild ${rebuildArg} "$@"
'';
"${name}-nixos-rebuild-local" = pkgs.writeScriptBin "${name}-nixos-rebuild" ''
#!${pkgs.runtimeShell} -e
set -x
nix copy --to ssh://${target} ${profile}
exec ssh ${target} "${profile}/bin/switch-to-configuration $@"
'';
#!${pkgs.runtimeShell} -e
[[ $(ssh ${target} cat /etc/hostname) == ${name} ]]
nix copy --to ssh://${target} ${profile}
ssh ${target} "${profile}/bin/switch-to-configuration $*"
'';
"${name}-cleanup" = pkgs.writeScriptBin "${name}-cleanup" ''
#!${pkgs.runtimeShell} -e
exec ssh ${target} "time nix-collect-garbage -d && time nix-store --optimise"
'';
#!${pkgs.runtimeShell} -e
ssh ${target} "time nix-collect-garbage -d && time nix-store --optimise"
'';
}) {} (builtins.attrNames flakifiedHosts) //
builtins.foldl' (result: host: result // {