aboutsummaryrefslogtreecommitdiff
path: root/flakes/mypackages/overlays/morph/dry-run.patch
blob: 2ff099e855ccbf2ed19ef5278857062a33341942 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
diff --git a/morph.go b/morph.go
index a88414b..e5894df 100644
--- a/morph.go
+++ b/morph.go
@@ -542,6 +542,7 @@ func getNixContext() *nix.NixContext {
 	return &nix.NixContext{
 		EvalMachines:    filepath.Join(assetRoot, assets.Friendly, "eval-machines.nix"),
 		ShowTrace:       showTrace,
+		DryRun:          *dryRun,
 		KeepGCRoot:      *keepGCRoot,
 		AllowBuildShell: *allowBuildShell,
 	}
@@ -574,8 +575,10 @@ func buildHosts(hosts []nix.Host) (resultPath string, err error) {
 		return
 	}
 
-	fmt.Fprintln(os.Stderr, "nix result path: ")
-	fmt.Println(resultPath)
+	if resultPath != "" {
+		fmt.Fprintln(os.Stderr, "nix result path: ")
+		fmt.Println(resultPath)
+	}
 	return
 }
 
diff --git a/nix/nix.go b/nix/nix.go
index 6a9cfd5..0f7884b 100644
--- a/nix/nix.go
+++ b/nix/nix.go
@@ -49,6 +49,7 @@ type Deployment struct {
 type NixContext struct {
 	EvalMachines    string
 	ShowTrace       bool
+	DryRun          bool
 	KeepGCRoot      bool
 	AllowBuildShell bool
 }
@@ -269,6 +270,10 @@ func (ctx *NixContext) BuildMachines(deploymentPath string, hosts []Host, nixArg
 		args = append(args, "--show-trace")
 	}
 
+	if ctx.DryRun {
+		args = append(args, "--dry-run")
+	}
+
 	if nixBuildTargets != "" {
 		args = append(args,
 			"--arg", "buildTargets", nixBuildTargets)
@@ -308,6 +313,10 @@ func (ctx *NixContext) BuildMachines(deploymentPath string, hosts []Host, nixArg
 		return resultPath, errors.New(errorMessage)
 	}
 
+	if ctx.DryRun {
+		return "", err
+	}
+
 	resultPath, err = os.Readlink(resultLinkPath)
 	if err != nil {
 		return "", err