diff options
Diffstat (limited to 'flakes/mypackages/overlays/morph')
-rw-r--r-- | flakes/mypackages/overlays/morph/default.nix | 27 | ||||
-rw-r--r-- | flakes/mypackages/overlays/morph/dry-run.patch | 59 | ||||
-rw-r--r-- | flakes/mypackages/overlays/morph/verbose_nix.patch | 12 |
3 files changed, 98 insertions, 0 deletions
diff --git a/flakes/mypackages/overlays/morph/default.nix b/flakes/mypackages/overlays/morph/default.nix new file mode 100644 index 0000000..b316d70 --- /dev/null +++ b/flakes/mypackages/overlays/morph/default.nix | |||
@@ -0,0 +1,27 @@ | |||
1 | self: super: { | ||
2 | morph = super.morph.overrideAttrs(old: rec { | ||
3 | version = "1.6.0-30-g5b85237"; | ||
4 | src = self.fetchFromGitHub { | ||
5 | owner = "dbcdk"; | ||
6 | repo = "morph"; | ||
7 | rev = "5b852370d8054a895b5ba79b5ef017c3afbb3a3c"; | ||
8 | sha256 = "166dwibbpb90bdy8dvhlinh6gc509f8pq8wn345h01pilf7fc8fh"; | ||
9 | }; | ||
10 | |||
11 | ldflags = [ | ||
12 | "-X main.version=${version}" | ||
13 | ]; | ||
14 | preBuild = '' | ||
15 | ldflags+=" -X main.assetRoot=$lib" | ||
16 | ''; | ||
17 | postInstall = '' | ||
18 | mkdir -p $lib | ||
19 | cp -v ./data/*.nix $lib | ||
20 | ''; | ||
21 | |||
22 | outputs = [ "out" "lib" ]; | ||
23 | vendorSha256 = "08zzp0h4c4i5hk4whz06a3da7qjms6lr36596vxz0d8q0n7rspr9"; | ||
24 | |||
25 | patches = (old.patches or []) ++ [ ./dry-run.patch ]; | ||
26 | }); | ||
27 | } | ||
diff --git a/flakes/mypackages/overlays/morph/dry-run.patch b/flakes/mypackages/overlays/morph/dry-run.patch new file mode 100644 index 0000000..2ff099e --- /dev/null +++ b/flakes/mypackages/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 | ||
diff --git a/flakes/mypackages/overlays/morph/verbose_nix.patch b/flakes/mypackages/overlays/morph/verbose_nix.patch new file mode 100644 index 0000000..389a79c --- /dev/null +++ b/flakes/mypackages/overlays/morph/verbose_nix.patch | |||
@@ -0,0 +1,12 @@ | |||
1 | diff --git a/nix/nix.go b/nix/nix.go | ||
2 | index bb63870..7fe04aa 100644 | ||
3 | --- a/nix/nix.go | ||
4 | +++ b/nix/nix.go | ||
5 | @@ -347,6 +347,7 @@ func Push(ctx *ssh.SSHContext, host Host, paths ...string) (err error) { | ||
6 | options := mkOptions(host) | ||
7 | for _, path := range paths { | ||
8 | args := []string{ | ||
9 | + "-v", | ||
10 | "copy", | ||
11 | path, | ||
12 | "--to", "ssh://" + userArg + host.TargetHost + keyArg, | ||