Sender | Message | Time |
---|---|---|
28 Aug 2025 | ||
https://asciinema.org/a/I6RXVGmCyCcHnXInvh5DKph4C read-write nix store in kubernetes with overlayfs 😄 yayy | 17:49:38 | |
20:39:24 | ||
29 Aug 2025 | ||
In reply to @lillecarl:matrix.orgIt would be interesting to see the data you pipe into kubectl apply in the first command, it seems to be the magic sauce :-) | 08:17:14 | |
In reply to @claesatwork:matrix.org https://gist.github.com/Lillecarl/cbd2e037f1fba7c145a37c3f33d5f926 Essentially everything except the daemonset,csidriver and the ubuntu pod is reduntant(in the current state). Currently the volume is just "ephemeral" so the expression metadata is straight in the podspec under volumeAttributes rather than through the expression CRD. The reason for having a CRD to stick nix expressions into is so that they can be built ahead of pod-creation time, but I've reprioritized to just make sure it works reliably building on pod creation. It'll still be "kewl enough" to hopefully attract more eyes and ideas 😄 | 08:54:03 | |
Another thing to build is a minimal activation script (sigh we don't get away from those hey) that copies cacerts, users, groups, nss and such from /nix/store into their "well-known paths" so #most applications Just work ™️ 😄 | 08:57:55 | |
Claes: The entire CSI driver is in this file: https://github.com/Lillecarl/cknix/blob/main/cknix_csi/cknix.py I've cleaned it up now and honestly it's so dumb and simple now. The "coolest" part is probably the execline script (Don't wanna ship a full shell) that pipes nix-store --dump-db to nix-store --load-db 😸 The nix code quality is still garbage so don't judge too hard | 09:38:37 | |
Cool! In the example you exec into the pod to show that the nix store is present. Do you have a plan for how it will work for a pod to execute the right process at start? I assume all pods running in a cluster will all have the same nix store mounted so the loose end here is to distinguish which pods run what? | 09:45:21 | |
In reply to @claesatwork:matrix.org Nix makes the "top derivation" available under /nix/var/result/bin/binaryname in the container, which can be set as the command in podspec to execute straight from the volume. Volumes are mounted before the container is created so it works out (You should use "tini" as the entrypoint which then executes your code to reap zombie processes, same thing with any container really). How the stores work: There's a daemonset (run once per node) that is this CSI driver, it mounts HOST/var/lib/cknix/nix to /nix2 in the daemonset initcontainer, copies /nix to /nix2. Then the actual CSI container runs and mounts HOST/var/lib/cknix/nix to /nix. This store is is the "source store" for all pods on that NODE. But to create an isolated "store view" per pod so they can't see other pods storepaths we create "fake stores" using hardlinks only containing the paths from nix path-info into the "fake store" the "fake store" is then either bind mounted (shares page cache and is amazing but readonly) into the pod, or overlayfs mounted (means you can run nix commands within the workload pod and RW the entire Nix store :) RW mounting should only be in development, but it's cool because it allows you to edit any storepaths (since the workload pods aren't privileged we can't setup a nix-daemon and do the RO bind mount thing on /nix/store so the entire store is read-write so you can do shenanigans you've never before imagined without strangling your dog | 09:54:24 | |
The part where we hardlink from the source store to a new "fake store" is where it's unique, just sharing a global /nix with all pods on the host would work, but definitely not for "production" since any application in the cluster could read any other application in the clusters code by travesting the store. | 09:55:42 | |
nix-snapshotter solves this by creating one bind mount per storepath instead, which is an approach that only works in the containerd layer, the benefit they get is that they can create container paths outside /nix. With cknix-csi you must write an activation script that copies files from /nix to FHS if you need stuff outside of /nix | 09:59:49 | |
Sorry for spamming, excited | 09:59:57 | |
* nix-snapshotter solves this by creating one bind mount per storepath instead, which is an approach that only works in the containerd layer, the benefit they get is that they can create container paths outside /nix(i think). With cknix-csi you must write an activation script that copies files from /nix to FHS if you need stuff outside of /nix | 10:01:30 | |
In reply to @lillecarl:matrix.org ok this part I misunderstood first will need more time to look through but definitely innovative! | 10:07:13 | |
30 Aug 2025 | ||
I published my secrets management module here : https://github.com/claes/hemlis | 13:25:39 | |
1 Sep 2025 | ||
Nice Claes! I'll have a look later tonight | 15:12:58 | |
I've got a thing to share which I thought can be quite useful. The nix.db database contains a field called "registrationTime" which nix-collect-garbage --delete-older-than Xd uses. I(Claude) wrote a little Python script to "touch" all dependencies (optionally including build dependencies) in the database so that recently built things don't get garbage collected if you run with the age options https://gist.github.com/Lillecarl/a08759fdc8f264eb237e46fd0ef16c40 <- I just tested that it does what I want it to-ish so don't go break your DB with this :p Something something --dry-run and --info also needs sudo because something something sqlite WAL needs write access even when only reading (?). I might just tmpclone the db for read ops 😄 The reason I made this is to make garbage collection more dynamic for the Nix CSI driver i've been spamming about. | 15:18:35 | |
I forgot if it is possible but I would like combine the age limit with a generation limit. Something like gc everything older than 7 days but keep at least 5 generations | 16:46:43 | |
There's https://search.nixos.org/options?channel=25.05&show=boot.loader.grub.configurationLimit&query=grub. but it's a maximum, not a minimum :/ | 17:21:52 | |
The nix sqlite database is really simple. Once I'm done cursing over replacing hardlinks with bind-mounts (hopefully) this'll be a good project | 19:57:57 | |
The GC could do with a bit more "intelligence". The current one is honestly dumb as WORDS | 19:58:17 | |
2 Sep 2025 | ||
Are any of you coming to nixcon? :) | 14:21:03 | |
not me | 14:32:04 | |
I have to skip this year unfortunately. | 14:50:00 | |
14 Sep 2025 | ||
08:39:46 | ||
17:36:41 | ||
16 Sep 2025 | ||
markuskowa: I notice you haven't scheduled a next meetup ;) | 16:03:36 | |
In reply to @lillecarl:matrix.orgYou got me 🫠. It was quite busy. What about Tuesday 30th of September? | 16:08:11 | |
Sounds good to me! 😁 | 16:11:59 | |
markuskowa: Last one was a Wednesday, I can't remember if we have some preference previously, cast a vote! 😄 | 17:26:06 | |
We were alternating between Tuesday and Wednesday to make it the decision easier. | 18:15:49 |