1
# enbi
2
3
Comprised of two parts:
4
5
* NixBuild CRD. An instance of one looks like this:
6
7
```
8
Spec:
9
Flake URL: git+https://nossa.ee/~talya/chog?rev=f5d531177a7330e9b270c15cca5df0eb72b8684c
10
Image Tag: nossa.ee/talya/chog:f5d531177a7330e9b270c15cca5df0eb72b8684c
11
Package Name: chog-docker.stream-layered
12
System: aarch64-linux
13
```
14
15
When created, this will build `packages.aarch64-linux.chog-docker.stream-layered` from the given
16
flake, on a node in the cluster which has the target architecture. (Nodes can be excluded from
17
builds with `-node-repel`.)
18
19
It's expected that the output will be a Docker/OCI tarball image itself, or (preferably) a script
20
generated by [`streamLayeredImage`](https://nixos.org/manual/nixpkgs/stable/#ssec-pkgs-dockerTools-streamLayeredImage).
21
The resulting tarball will be loaded into the `containerd` of the build host; use something like
22
[Spegel](https://spegel.dev/) to make it automatically available to any host that might need it.
23
24
You can see what's happening in `kubectl get`:
25
26
```
27
NAME IMAGE TAG SYSTEM STATUS BUILD NODE AGE
28
podwatcher-5d74cd57bb nossa.ee/talya/chog:f5d531177a7330e9b270c15cca5df0eb72b8684c aarch64-linux Succeeded cass 71m
29
```
30
31
And more details in `kubectl describe`:
32
33
```
34
Status:
35
Build Job Name: podwatcher-5d74cd57bb-5d74cd57bb
36
Build Node: cass
37
Conditions:
38
Last Transition Time: 2025-08-31T08:34:01Z
39
Message: Build completed successfully and result was fetched from endpoint
40
Reason: ResultSuccess
41
Status: True
42
Type: Success
43
Last Transition Time: 2025-08-31T08:34:01Z
44
Message: Image loaded
45
Reason: BuildFinished
46
Status: True
47
Type: Complete
48
Image Digest: sha256:707b2b90f3f21c5cccad07429f51e1a37b9833d4ff87b323786d7cb246b8360c
49
Image Size: 112199680
50
Status: Succeeded
51
```
52
53
* Annotations to be added to your PodTemplateSpec. Like this:
54
55
```
56
Pod Template:
57
Labels: app.kubernetes.io/name=chog
58
Annotations: enbi.hrzn.ee/nixbuild-flakeUrl: git+https://nossa.ee/~talya/chog?rev=f5d531177a7330e9b270c15cca5df0eb72b8684c
59
enbi.hrzn.ee/nixbuild-imageTag: nossa.ee/talya/chog:f5d531177a7330e9b270c15cca5df0eb72b8684c
60
enbi.hrzn.ee/nixbuild-packageName: chog-docker.stream-layered
61
```
62
63
If a Pod with these annotations is found to be failing to start up due to a missing image, and
64
the tag of that image matches the one in the annotation, a corresponding NixBuild will be
65
created; after the image is built and loaded, your containers will come up at next retry!
66
67
Left to do:
68
69
* [ ] flesh out the tests; we'll need to manipulate the state surrounding the controller (create
70
Nodes, PVs, etc.).
71
* [ ] check our behaviour when a Pod fails to start because it's trying to run a container with the
72
wrong arch; we probably will ignore it (search codebase for `RestartCount`).
73
* [ ] running in Docker for Mac's kind doesn't work well wrt. building across Nodes; there's no
74
Spegel-like auto-pull across Nodes, only from the host cache (which we don't (can't?) touch).
75
* [ ] consider limiting the number of leftover successful NixBuilds.
76
* [ ] make it easier to deploy for others (and to update our own deployment, given the situation
77
with `config/` and how we use Timoni).
78
* [ ] document assumptions, limitations.
79
* [ ] `local-overlay-store` support?
80
* [ ] system (Node) Nix daemon support?
81
82
Built while following the [Kubebuilder](https://book.kubebuilder.io/) book.
83
84
## License
85
86
Copyright © 2025 Asherah Connor \<ashe@kivikakk.ee\>
87
88
Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in
89
compliance with the License. You may obtain a copy of the License at <http://www.apache.org/licenses/LICENSE-2.0>;
90
it is included in this distribution at [`LICENSE`](LICENSE).
91
92
Unless required by applicable law or agreed to in writing, software distributed under the License
93
is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
94
implied. See the License for the specific language governing permissions and limitations under the
95
License.
96
97