Add option to substitute on the target machine if local build
Signed-off-by: Magic_RB <magic_rb@redalder.org> Co-authored-by: matthewcroughan <matt@croughan.sh>
This commit is contained in:
parent
6dfbffee74
commit
b5683029f9
2 changed files with 11 additions and 2 deletions
|
@ -32,6 +32,7 @@ Below is a minimal example:
|
||||||
host = "itchy.scratchy.com";
|
host = "itchy.scratchy.com";
|
||||||
sshUser = "matthew";
|
sshUser = "matthew";
|
||||||
buildOn = "remote"; # valid args are "local" or "remote"
|
buildOn = "remote"; # valid args are "local" or "remote"
|
||||||
|
substituteOnTarget = true; # if buildOn is "local" then it will substitute on the target, "-s"
|
||||||
hermetic = false;
|
hermetic = false;
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
@ -105,6 +106,13 @@ Connection to itchy.scratchy.com closed.
|
||||||
Whether to copy Nix to the remote for usage when building and activating,
|
Whether to copy Nix to the remote for usage when building and activating,
|
||||||
instead of using the Nix which is already installed on the remote.
|
instead of using the Nix which is already installed on the remote.
|
||||||
|
|
||||||
|
- `substituteOnTarget` *`bool`*
|
||||||
|
|
||||||
|
Whether to fetch closures and paths from the remote, even when building
|
||||||
|
locally. This makes sense in most cases, because the remote will have already
|
||||||
|
built a lot of the paths from the previous deployment. However, if the remote
|
||||||
|
has a slow upload bandwidth, this would not be a good idea to enable.
|
||||||
|
|
||||||
# Project Principles
|
# Project Principles
|
||||||
|
|
||||||
* No Premature Optimization: Make it work, then optimize it later if the
|
* No Premature Optimization: Make it work, then optimize it later if the
|
||||||
|
|
|
@ -27,7 +27,7 @@
|
||||||
validMachines = final.lib.remove "" (final.lib.forEach machines (x: final.lib.optionalString (flake.nixosConfigurations."${x}"._module.args ? nixinate) "${x}" ));
|
validMachines = final.lib.remove "" (final.lib.forEach machines (x: final.lib.optionalString (flake.nixosConfigurations."${x}"._module.args ? nixinate) "${x}" ));
|
||||||
mkDeployScript = { machine, dryRun }: let
|
mkDeployScript = { machine, dryRun }: let
|
||||||
inherit (builtins) abort;
|
inherit (builtins) abort;
|
||||||
inherit (final.lib) getExe;
|
inherit (final.lib) getExe optionalString;
|
||||||
nix = "${getExe final.nix}";
|
nix = "${getExe final.nix}";
|
||||||
nixos-rebuild = "${getExe final.nixos-rebuild}";
|
nixos-rebuild = "${getExe final.nixos-rebuild}";
|
||||||
openssh = "${getExe final.openssh}";
|
openssh = "${getExe final.openssh}";
|
||||||
|
@ -38,6 +38,7 @@
|
||||||
host = n.host;
|
host = n.host;
|
||||||
where = n.buildOn or "remote";
|
where = n.buildOn or "remote";
|
||||||
remote = if where == "remote" then true else if where == "local" then false else abort "_module.args.nixinate.buildOn is not set to a valid value of 'local' or 'remote'";
|
remote = if where == "remote" then true else if where == "local" then false else abort "_module.args.nixinate.buildOn is not set to a valid value of 'local' or 'remote'";
|
||||||
|
substituteOnTarget = n.substituteOnTarget or false;
|
||||||
switch = if dryRun then "dry-activate" else "switch";
|
switch = if dryRun then "dry-activate" else "switch";
|
||||||
script =
|
script =
|
||||||
''
|
''
|
||||||
|
@ -58,7 +59,7 @@
|
||||||
'')
|
'')
|
||||||
else ''
|
else ''
|
||||||
echo "🔨 Building system closure locally, copying it to remote store and activating it:"
|
echo "🔨 Building system closure locally, copying it to remote store and activating it:"
|
||||||
( set -x; NIX_SSHOPTS="-t" ${nixos-rebuild} ${switch} --flake ${flake}#${machine} --target-host ${user}@${host} --use-remote-sudo )
|
( set -x; NIX_SSHOPTS="-t" ${nixos-rebuild} ${switch} --flake ${flake}#${machine} --target-host ${user}@${host} --use-remote-sudo ${optionalString substituteOnTarget "-s"} )
|
||||||
'');
|
'');
|
||||||
in final.writeScript "deploy-${machine}.sh" script;
|
in final.writeScript "deploy-${machine}.sh" script;
|
||||||
in
|
in
|
||||||
|
|
Loading…
Add table
Reference in a new issue