aboutsummaryrefslogtreecommitdiffstats
path: root/nix/package.nix
diff options
context:
space:
mode:
authortv <tv@krebsco.de>2026-11-30 13:13:44 +0000
committertv <tv@krebsco.de>2026-11-30 19:51:09 +0000
commite1644b9d0f72e9bad824e75e3b294968b06a454e (patch)
tree15941ea7931c722c4df8f8b964f4ed9976fb030f /nix/package.nix
parentf67a9a0c80e60dbe44c96ec8573ae78a35852ac4 (diff)
nix: the package, a NixOS module, its VM test
The module makes the schema from options (/etc/enstate/schema.json), every slot its own view unless it says otherwise, and names the views' paths (read-only `path` options) for the services that read them. It configures none of them: a service whose LoadCredential= reads a view is ordered after the unit that puts the views in place, by itself. That unit runs --migrate at boot and when the schema changes; the check before a switch is --migrate --dry-run against the new schema. The test: a consumer with a LoadCredential= of its own; apply from a source list, rotate, switch across a rename and back, a switch refused, a reboot.
Diffstat (limited to 'nix/package.nix')
-rw-r--r--nix/package.nix37
1 files changed, 37 insertions, 0 deletions
diff --git a/nix/package.nix b/nix/package.nix
new file mode 100644
index 0000000..a919061
--- /dev/null
+++ b/nix/package.nix
@@ -0,0 +1,37 @@
+# enstate, the program (README.md).
+{
+ lib,
+ runCommand,
+ rustPlatform,
+ util-linux,
+}:
+
+rustPlatform.buildRustPackage {
+ pname = "enstate";
+ version = "0.0.1";
+
+ # Only what the build reads, each part on its own, never the whole checkout: a
+ # filter over the checkout can't tell its files apart below a symbolic link (Nix
+ # gives it the resolved paths), and lib.fileset refuses one.
+ src = runCommand "enstate-source" { } ''
+ mkdir $out
+ cp ${../Cargo.toml} $out/Cargo.toml
+ cp ${../Cargo.lock} $out/Cargo.lock
+ cp -r ${../src} $out/src
+ cp -r ${../tests} $out/tests
+ '';
+
+ # The tests' fake systemctl looks at the store's lock with flock.
+ nativeCheckInputs = [ util-linux ];
+
+ cargoLock = {
+ lockFile = ../Cargo.lock;
+ outputHashes."config-0.1.0" = "sha256-qtUSpjOQsC9NFwgDXqDIqzvzU1zZqoD90se/ccWSKNs=";
+ };
+
+ meta = {
+ description = "State next to the Nix store: plan, apply, and make submissions";
+ mainProgram = "enstate";
+ platforms = lib.platforms.linux;
+ };
+}