]> git.immae.eu Git - perso/Immae/Config/Nix.git/blame - overlays/morph/dry-run.patch
Add dry-run patch for morph
[perso/Immae/Config/Nix.git] / overlays / morph / dry-run.patch
CommitLineData
70712d46
IB
1diff --git a/morph.go b/morph.go
2index 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
26diff --git a/nix/nix.go b/nix/nix.go
27index 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