forked from c3d2/nix-config
flake.nix: add -nixos-rebuild-local
This commit is contained in:
parent
2c950f0a8d
commit
1ddc5d2b11
|
@ -66,6 +66,13 @@ for example: `nix run c3d2#glotzbert-nixos-rebuild switch`. Use `nix flake show
|
|||
to show what is available. Note that the deploy scripts only work if
|
||||
the target machines already has flakes enabled.
|
||||
|
||||
Now that there is a `-local` variant that builds the system profile on
|
||||
your machine (possibly reusing dependencies that were built for other
|
||||
hosts), flakification of an existing NixOS host can be done using `nix
|
||||
run c3d2#glotzbert-nixos-rebuild-local switch`
|
||||
|
||||
The must be an existing `nixosConfiguration.${host}` in `flake.nix`.
|
||||
|
||||
### Remote deployment from non-NixOS
|
||||
|
||||
A shell script that copies the current working tree, and runs
|
||||
|
|
13
flake.nix
13
flake.nix
|
@ -70,7 +70,7 @@
|
|||
# remote machine and bulding and switching there.
|
||||
# Can be run with nix run c3d2#deploy-…
|
||||
{ name
|
||||
, host ? "${name}.hq.c3d2.de"
|
||||
, host
|
||||
# remote builders to pass
|
||||
, builders ? null
|
||||
}:
|
||||
|
@ -146,6 +146,17 @@
|
|||
} // nixpkgs.lib.optionalAttrs (hostRegistry.hosts.${name} ? builders) {
|
||||
inherit (hostRegistry.hosts.${name}) builders;
|
||||
});
|
||||
|
||||
"${name}-nixos-rebuild-local" =
|
||||
let
|
||||
host = getHostAddr name;
|
||||
target = ''root@"${host}"'';
|
||||
profile = self.nixosConfigurations.${name}.config.system.build.toplevel;
|
||||
in pkgs.writeScriptBin "${name}-nixos-rebuild" ''
|
||||
#!${pkgs.runtimeShell} -e
|
||||
nix-copy-closure --to ${target} ${profile}
|
||||
exec ssh -t ${target} "${profile}/bin/switch-to-configuration $@"
|
||||
'';
|
||||
}) {} (builtins.attrNames flakifiedHosts)
|
||||
);
|
||||
|
||||
|
|
Loading…
Reference in New Issue