Skip to content

Commit

Permalink
added deployment module option for nix copy --substitute-on-destination
Browse files Browse the repository at this point in the history
  • Loading branch information
Johan Thomsen authored and adamtulinius committed Oct 27, 2019
1 parent 86f1760 commit 685a0f7
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 2 deletions.
7 changes: 6 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -163,8 +163,10 @@ The default is an empty set, meaning that the nix configuration is inherited fro

`buildOnly` makes morph skip the "push" and "switch" steps for the given host, even if "morph deploy" or "morph push" is executed. (default: false)

`substituteOnDestination` Sets the `--substitute-on-destination` flag on nix copy, allowing for the deployment target to use substitutes. See `nix copy --help`. (default: false)

Example usage of `nixConfig` and `deployment.buildOnly`:

Example usage of `nixConfig` and deployment module options:
```
network = {
nixConfig = {
Expand All @@ -176,6 +178,9 @@ machine1 = { ... }: {
deployment.buildOnly = true;
};
machine2 = { ... }: {
deployment.substituteOnDestination = true;
};
```


Expand Down
2 changes: 1 addition & 1 deletion data/eval-machines.nix
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ rec {

machines =
flip mapAttrs nodes (n: v': let v = scrubOptionValue v'; in
{ inherit (v.config.deployment) targetHost secrets healthChecks buildOnly;
{ inherit (v.config.deployment) targetHost secrets healthChecks buildOnly substituteOnDestination;
name = n;
nixosRelease = v.config.system.nixos.release or (removeSuffix v.config.system.nixos.version.suffix v.config.system.nixos.version);
nixConfig = mapAttrs
Expand Down
10 changes: 10 additions & 0 deletions data/options.nix
Original file line number Diff line number Diff line change
Expand Up @@ -172,6 +172,16 @@ in
'';
};

substituteOnDestination = mkOption {
type = bool;
default = false;
description = ''
Sets the `--substitute-on-destination` flag on nix copy,
allowing for the deployment target to use substitutes.
See `nix copy --help`.
'';
};

secrets = mkOption {
default = {};
example = {
Expand Down
4 changes: 4 additions & 0 deletions nix/nix.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ type Host struct {
TargetHost string
Secrets map[string]secrets.Secret
BuildOnly bool
SubstituteOnDestination bool
NixConfig map[string]string
}

Expand Down Expand Up @@ -259,6 +260,9 @@ func Push(ctx *ssh.SSHContext, host Host, paths ...string) (err error) {
"--to", "ssh://" + userArg + host.TargetHost + keyArg,
}
args = append(args, options...)
if host.SubstituteOnDestination {
args = append(args, "--substitute-on-destination")
}

cmd := exec.Command(
"nix", args...,
Expand Down

0 comments on commit 685a0f7

Please sign in to comment.