From 258c33f409b4b253fae9fa175424eb4b75e284a3 Mon Sep 17 00:00:00 2001 From: Raito Bezarius Date: Sun, 21 Apr 2024 20:34:39 +0200 Subject: [PATCH] feat(entrypoint): expose `evalModules` for external interop e.g. colmena can make use of it to declare an heterogeneous set of systems, mixing Liminix and NixOS systems. Signed-off-by: Raito Bezarius --- default.nix | 22 +++++++++------------- lib/eval-config.nix | 24 ++++++++++++++++++++++++ 2 files changed, 33 insertions(+), 13 deletions(-) create mode 100644 lib/eval-config.nix diff --git a/default.nix b/default.nix index 0f589fe..9c87e19 100644 --- a/default.nix +++ b/default.nix @@ -18,24 +18,18 @@ let }; }); - eval = pkgs.lib.evalModules { - specialArgs = { - modulesPath = builtins.toString ./modules; - }; + evalModules = (import ./lib/eval-config.nix { + inherit nixpkgs pkgs; + inherit (pkgs) lib; + }); + + eval = evalModules { modules = [ - { _module.args = { inherit pkgs; inherit (pkgs) lim; }; } - ./modules/hardware.nix - ./modules/base.nix - ./modules/busybox.nix - ./modules/hostname.nix - ./modules/kernel device.module liminix-config - ./modules/s6 - ./modules/users.nix - ./modules/outputs.nix ]; }; + config = eval.config; borderVm = ((import ) { @@ -54,6 +48,8 @@ let ]; }).config.system; in { + inherit evalModules; + outputs = config.system.outputs // { default = config.system.outputs.${config.hardware.defaultOutput}; optionsJson = diff --git a/lib/eval-config.nix b/lib/eval-config.nix new file mode 100644 index 0000000..5c96138 --- /dev/null +++ b/lib/eval-config.nix @@ -0,0 +1,24 @@ +{ nixpkgs ? , pkgs ? (import {}), lib ? pkgs.lib }: +args: +let + modulesPath = builtins.toString ../modules; +in +# FIXME: we could replace the `lib` by a lib-only minimal nixpkgs. +(import "${nixpkgs}/lib/modules.nix" { inherit lib; }).evalModules (args // { + specialArgs = (args.specialArgs or {}) // { + inherit modulesPath; + }; + modules = (args.modules or []) ++ [ + "${modulesPath}/hardware.nix" + "${modulesPath}/base.nix" + "${modulesPath}/busybox.nix" + "${modulesPath}/hostname.nix" + "${modulesPath}/kernel" + "${modulesPath}/s6" + "${modulesPath}/users.nix" + "${modulesPath}/outputs.nix" + # FIXME: we should let the caller inject `pkgs` and `lim` ideally... + ] ++ lib.optional (pkgs ? lim) { + _module.args = { inherit (pkgs) lim; }; + }; +})