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
|
diff --git a/dagger/main.go b/dagger/main.go
new file mode 100644
index 0000000000000000000000000000000000000000..fa936487a5880ffb6e34f924a86500af9f1090db
--- /dev/null
+++ b/dagger/main.go
@@ -0,0 +1,42 @@
+package main
+
+import "context"
+
+type Ugit struct{}
+
+// Base nix container
+func (u *Ugit) Nix(source *Directory) *Container {
+ return dag.Container().
+ From("nixos/nix:latest").
+ WithDirectory("/src", source).
+ WithWorkdir("/src")
+}
+
+// Nix build
+func (u *Ugit) Build(source *Directory) *Container {
+ return u.Nix(source).
+ WithExec([]string{
+ "nix",
+ "--experimental-features",
+ "nix-command flakes",
+ "build",
+ })
+}
+
+// Push to cachix
+func (u *Ugit) Cachix(ctx context.Context, source *Directory, cachix *Secret) (string, error) {
+ return u.Build(source).
+ WithSecretVariable("CACHIX_AUTH_TOKEN", cachix).
+ WithExec([]string{
+ "nix",
+ "--experimental-features",
+ "nix-command flakes",
+ "run",
+ "nixpkgs#cachix",
+ "--",
+ "push",
+ "jolheiser",
+ "./result",
+ }).
+ Stdout(ctx)
+}
|