diff options
Diffstat (limited to 'overlays')
-rw-r--r-- | overlays/morph/default.nix | 2 | ||||
-rw-r--r-- | overlays/morph/dry-run.patch | 59 |
2 files changed, 60 insertions, 1 deletions
diff --git a/overlays/morph/default.nix b/overlays/morph/default.nix index ee59e25..448f051 100644 --- a/overlays/morph/default.nix +++ b/overlays/morph/default.nix | |||
@@ -1,5 +1,5 @@ | |||
1 | self: super: { | 1 | self: super: { |
2 | morph = super.morph.overrideAttrs(old: { | 2 | morph = super.morph.overrideAttrs(old: { |
3 | patches = (old.patches or []) ++ [ ./verbose_nix.patch ]; | 3 | patches = (old.patches or []) ++ [ ./verbose_nix.patch ./dry-run.patch ]; |
4 | }); | 4 | }); |
5 | } | 5 | } |
diff --git a/overlays/morph/dry-run.patch b/overlays/morph/dry-run.patch new file mode 100644 index 0000000..2ff099e --- /dev/null +++ b/overlays/morph/dry-run.patch | |||
@@ -0,0 +1,59 @@ | |||
1 | diff --git a/morph.go b/morph.go | ||
2 | index a88414b..e5894df 100644 | ||
3 | --- a/morph.go | ||
4 | +++ b/morph.go | ||
5 | @@ -542,6 +542,7 @@ func getNixContext() *nix.NixContext { | ||
6 | return &nix.NixContext{ | ||
7 | EvalMachines: filepath.Join(assetRoot, assets.Friendly, "eval-machines.nix"), | ||
8 | ShowTrace: showTrace, | ||
9 | + DryRun: *dryRun, | ||
10 | KeepGCRoot: *keepGCRoot, | ||
11 | AllowBuildShell: *allowBuildShell, | ||
12 | } | ||
13 | @@ -574,8 +575,10 @@ func buildHosts(hosts []nix.Host) (resultPath string, err error) { | ||
14 | return | ||
15 | } | ||
16 | |||
17 | - fmt.Fprintln(os.Stderr, "nix result path: ") | ||
18 | - fmt.Println(resultPath) | ||
19 | + if resultPath != "" { | ||
20 | + fmt.Fprintln(os.Stderr, "nix result path: ") | ||
21 | + fmt.Println(resultPath) | ||
22 | + } | ||
23 | return | ||
24 | } | ||
25 | |||
26 | diff --git a/nix/nix.go b/nix/nix.go | ||
27 | index 6a9cfd5..0f7884b 100644 | ||
28 | --- a/nix/nix.go | ||
29 | +++ b/nix/nix.go | ||
30 | @@ -49,6 +49,7 @@ type Deployment struct { | ||
31 | type NixContext struct { | ||
32 | EvalMachines string | ||
33 | ShowTrace bool | ||
34 | + DryRun bool | ||
35 | KeepGCRoot bool | ||
36 | AllowBuildShell bool | ||
37 | } | ||
38 | @@ -269,6 +270,10 @@ func (ctx *NixContext) BuildMachines(deploymentPath string, hosts []Host, nixArg | ||
39 | args = append(args, "--show-trace") | ||
40 | } | ||
41 | |||
42 | + if ctx.DryRun { | ||
43 | + args = append(args, "--dry-run") | ||
44 | + } | ||
45 | + | ||
46 | if nixBuildTargets != "" { | ||
47 | args = append(args, | ||
48 | "--arg", "buildTargets", nixBuildTargets) | ||
49 | @@ -308,6 +313,10 @@ func (ctx *NixContext) BuildMachines(deploymentPath string, hosts []Host, nixArg | ||
50 | return resultPath, errors.New(errorMessage) | ||
51 | } | ||
52 | |||
53 | + if ctx.DryRun { | ||
54 | + return "", err | ||
55 | + } | ||
56 | + | ||
57 | resultPath, err = os.Readlink(resultLinkPath) | ||
58 | if err != nil { | ||
59 | return "", err | ||