Home

ugit @a40abd06932672d22c977b115a554d709c209045 - refs - log -
-
https://git.jolheiser.com/ugit.git
The code powering this h*ckin' site
ugit / dagger / main.go
- raw
 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
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)
}