diff options
| author | Ophestra <cat@gensokyo.uk> | 2025-08-15 03:27:54 +0900 |
|---|---|---|
| committer | Ophestra <cat@gensokyo.uk> | 2025-08-15 03:27:54 +0900 |
| commit | 4433c993fae86634b813ee212803a84aaeedd374 (patch) | |
| tree | c407029bf3e7df57398ef5ba40f7630176348241 | |
| parent | 430991c39bedafb231e0017277e69ad95cb1d56e (diff) | |
nix: check config via hakurei
This is unfortunately the only feasible way of doing this in nix.
Signed-off-by: Ophestra <cat@gensokyo.uk>
| -rw-r--r-- | nixos.nix | 13 | ||||
| -rw-r--r-- | options.nix | 45 | ||||
| -rw-r--r-- | test/sandbox/configuration.nix | 1 |
3 files changed, 14 insertions, 45 deletions
@@ -204,11 +204,20 @@ in ] ); }; - }; + + checkedConfig = + name: value: + let + file = pkgs.writeText name (builtins.toJSON value); + in + pkgs.runCommand "checked-${name}" { nativeBuildInputs = [ cfg.package ]; } '' + ln -vs ${file} "$out" + hakurei show ${file} + ''; in pkgs.writeShellScriptBin app.name '' - exec hakurei${if app.verbose then " -v" else ""} app ${pkgs.writeText "hakurei-app-${app.name}.json" (builtins.toJSON conf)} $@ + exec hakurei${if app.verbose then " -v" else ""} app ${checkedConfig "hakurei-app-${app.name}.json" conf} $@ '' ) ] diff --git a/options.nix b/options.nix index d5d82496..bd45b7b5 100644 --- a/options.nix +++ b/options.nix @@ -3,47 +3,6 @@ packages: let inherit (lib) types mkOption mkEnableOption; - - mountPoint = - let - inherit (types) - enum - str - submodule - nullOr - listOf - ; - in - listOf (submodule { - options = { - type = mkOption { - type = enum [ "bind" ]; - default = "bind"; - description = '' - Type of the mount point; - ''; - }; - - dst = mkOption { - type = nullOr str; - default = null; - description = '' - Mount point in container, same as src if null. - ''; - }; - - src = mkOption { - type = str; - description = '' - Host filesystem path to make available to the container. - ''; - }; - - write = mkEnableOption "mounting path as writable"; - dev = mkEnableOption "use of device files"; - optional = mkEnableOption "ignore nonexistent source path"; - }; - }); in { @@ -243,7 +202,7 @@ in }; extraPaths = mkOption { - type = mountPoint; + type = anything; default = [ ]; description = '' Extra paths to make available to the container. @@ -301,7 +260,7 @@ in }; commonPaths = mkOption { - type = mountPoint; + type = types.anything; default = [ ]; description = '' Common extra paths to make available to the container. diff --git a/test/sandbox/configuration.nix b/test/sandbox/configuration.nix index 77af45a4..fae60ac2 100644 --- a/test/sandbox/configuration.nix +++ b/test/sandbox/configuration.nix @@ -78,6 +78,7 @@ in commonPaths = [ { + type = "bind"; src = "/var/cache"; write = true; } |
