Skip to content

Commit 54db037

Browse files
Lillecarlclaude
andcommitted
Enhance README with NRI examples and lib.getExe tip
Add comprehensive NRI plugin section showing annotation-based injection alongside CSI ephemeral volume examples. Include practical tip about using lib.getExe for clean command and environment variable references in pod configurations. Co-Authored-By: Claude Haiku 4.5 <noreply@anthropic.com> Update CLAUDE.md development environment reference Change "Python with nix-csi" to "Python with nixkube" in development environment description. Co-Authored-By: Claude Haiku 4.5 <noreply@anthropic.com>
1 parent 5fd0423 commit 54db037

2 files changed

Lines changed: 85 additions & 23 deletions

File tree

CLAUDE.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -154,7 +154,7 @@ just push
154154
### Development Environment
155155

156156
The development environment includes:
157-
- Python with nix-csi, csi-proto-python, kr8s
157+
- Python with nixkube, csi-proto-python, kr8s
158158
- xonsh shell
159159
- ruff, pyright (linting/type checking)
160160
- kluctl, stern, kubectx (Kubernetes tools)

README.md

Lines changed: 84 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -21,28 +21,90 @@ and stuff the result into Kustomize, a blender or your Kubernetes cluster
2121

2222
## Deploying workloads
2323

24-
* [multi-system example](https://github.com/Lillecarl/hetzkube/blob/4ed76ec77bfb104d1c2307b1ba178efa61dd34e2/kubenix/modules/cheapam.nix#L113)
25-
* [single-system ci example(s)](https://github.com/Lillecarl/nix-csi/blob/3179e5f8383e760bbef313300a224e44f18722c7/kubenix/ci/default.nix)
26-
* YAML example, because YAML is....cool
24+
nixkube supports two methods for injecting Nix stores into pods:
25+
26+
### CSI Ephemeral Volumes (Explicit)
27+
28+
Request Nix stores explicitly via CSI volumeAttributes. Specify one or more:
29+
- `storePath` - Direct nix store path (highest priority)
30+
- `flakeRef` - Flake reference to build
31+
- `nixExpr` - Nix expression to evaluate and build
32+
2733
```yaml
28-
volumeAttributes:
29-
# Pull storePath without eval, prio 1
30-
x86_64-linux: /nix/store/hello-......
31-
aarch64-linux: /nix/store/hello-......
32-
# Evaluates and builds flake, prio 2
33-
flakeRef: github:nixos/nixpkgs/nixos-unstable#hello
34-
# Evaluates and builds expression, prio 3
35-
nixExpr: |
36-
let
37-
nixpkgs = builtins.fetchTree {
38-
type = "github";
39-
owner = "nixos";
40-
repo = "nixpkgs";
41-
ref = "nixos-unstable";
42-
};
43-
pkgs = import nixpkgs { };
44-
in
45-
pkgs.hello
34+
apiVersion: v1
35+
kind: Pod
36+
metadata:
37+
name: hello-csi
38+
spec:
39+
containers:
40+
- name: hello
41+
image: nixos/nix:latest
42+
volumeMounts:
43+
- name: nix
44+
mountPath: /nix
45+
volumes:
46+
- name: nix
47+
ephemeral:
48+
volumeClaimTemplate:
49+
spec:
50+
accessModes: ["ReadOnlyMany"]
51+
storageClassName: ephemeral-storage
52+
resources:
53+
requests:
54+
storage: 1Gi
55+
csi:
56+
driver: nixkube
57+
volumeAttributes:
58+
x86_64-linux: /nix/store/hello-......
59+
aarch64-linux: /nix/store/hello-......
60+
flakeRef: github:nixos/nixpkgs/nixos-unstable#hello
61+
nixExpr: |
62+
let
63+
nixpkgs = builtins.fetchTree {
64+
type = "github";
65+
owner = "nixos";
66+
repo = "nixpkgs";
67+
ref = "nixos-unstable";
68+
};
69+
pkgs = import nixpkgs { };
70+
in
71+
pkgs.hello
72+
```
73+
74+
The first successful option by priority wins.
75+
76+
**Tip**: For command arrays and environment variables, use `lib.getExe` to reference executables without managing full store paths:
77+
78+
```nix
79+
command = [ (lib.getExe pkgs.hello) ]
80+
env = {
81+
name = "HELLO_CONFIG";
82+
value = pkgs.hello-config;
83+
}
4684
```
47-
You can specify all these options but the first successful one by priority wins
85+
86+
### NRI Plugin (Automatic via Annotations)
87+
88+
Use pod annotations to automatically inject Nix stores without explicit volume requests:
89+
90+
```yaml
91+
apiVersion: v1
92+
kind: Pod
93+
metadata:
94+
name: hello-nri
95+
annotations:
96+
nix-nri/pod: |
97+
/nix/store/hello-......
98+
nix-nri/pod@aarch64-linux: |
99+
/nix/store/hello-aarch64-......
100+
spec:
101+
containers:
102+
- name: hello
103+
image: nixos/nix:latest
104+
# /nix is automatically mounted by NRI plugin
105+
```
106+
107+
Examples:
108+
* [multi-system example](https://github.com/Lillecarl/hetzkube/blob/4ed76ec77bfb104d1c2307b1ba178efa61dd34e2/kubenix/modules/cheapam.nix#L113)
109+
* [single-system ci example(s)](https://github.com/Lillecarl/nix-csi/blob/3179e5f8383e760bbef313300a224e44f18722c7/kubenix/ci/default.nix)
48110

0 commit comments

Comments
 (0)