From 135a42b20fca7e6bbb2f113d231601b4e71308b2 Mon Sep 17 00:00:00 2001 From: Zhaofeng Li Date: Fri, 16 Jul 2021 22:52:23 -0700 Subject: [PATCH] eval.nix: Add meta.specialArgs --- src/nix/eval.nix | 12 +++++++++++- src/nix/tests/mod.rs | 17 +++++++++++++++++ 2 files changed, 28 insertions(+), 1 deletion(-) diff --git a/src/nix/eval.nix b/src/nix/eval.nix index 441bdb9..9ba3521 100644 --- a/src/nix/eval.nix +++ b/src/nix/eval.nix @@ -72,6 +72,16 @@ let apply = value: if value == null then null else toString value; type = types.nullOr types.path; }; + specialArgs = lib.mkOption { + description = '' + A set of special arguments to be passed to NixOS modules. + + This will be merged into the `specialArgs` used to evaluate + the NixOS configurations. + ''; + default = {}; + type = types.attrsOf types.unspecified; + }; }; }; @@ -334,7 +344,7 @@ let hive.defaults config ] ++ (import (npkgs.path + "/nixos/modules/module-list.nix")); - specialArgs = { + specialArgs = hive.meta.specialArgs // { inherit name nodes; modulesPath = npkgs.path + "/nixos/modules"; }; diff --git a/src/nix/tests/mod.rs b/src/nix/tests/mod.rs index 4751ecf..dfbc942 100644 --- a/src/nix/tests/mod.rs +++ b/src/nix/tests/mod.rs @@ -388,3 +388,20 @@ fn test_nixpkgs_config_override() { vec![ "test".to_string() ] ); } + +#[test] +fn test_meta_special_args() { + TempHive::valid(r#" + { + meta.specialArgs = { + undine = "assimilated"; + }; + + borg = { undine, ... }: + assert undine == "assimilated"; + { + boot.isContainer = true; + }; + } + "#); +}