external: initialize machinery for external interop #5

Merged
rlahfa merged 2 commits from colmena--compat into main 2024-05-24 17:34:19 +02:00
2 changed files with 33 additions and 4 deletions
Showing only changes of commit c8ee9b6d5a - Show all commits

View file

@ -18,10 +18,12 @@ 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
@ -36,6 +38,7 @@ let
./modules/outputs.nix
];
};
config = eval.config;
borderVm = ((import <nixpkgs/nixos/lib/eval-config.nix>) {
@ -54,6 +57,8 @@ let
];
}).config.system;
in {
inherit evalModules;
outputs = config.system.outputs // {
default = config.system.outputs.${config.hardware.defaultOutput};
optionsJson =

24
lib/eval-config.nix Normal file
View file

@ -0,0 +1,24 @@
{ nixpkgs ? <nixpkgs>, pkgs ? (import <nixpkgs> {}), 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; };
};
})