make devosSystem construct a proper nixos builder

Get `self` and `inputs` during construction, and rely on
specialArgs.channel for nixos flake
This commit is contained in:
Pacman99 2021-04-25 16:21:40 -07:00
parent c0d6453b08
commit abd133c244

View file

@ -1,31 +1,40 @@
{ lib }:
{ self, nixos, inputs, modules, ... } @ allArgs:
let args = builtins.removeAttrs allArgs [ "self" "nixos" "inputs" ]; in
lib.nixosSystem (args // {
modules =
let
moduleList = builtins.attrValues modules;
# dependencies to return a builder
{ self, inputs }:
fullHostConfig = (lib.nixosSystem (args // { modules = moduleList; })).config;
{ modules, specialArgs, ... } @ args:
let inherit (specialArgs.channel.input.lib) nixosSystem; in
nixosSystem
(args // {
modules =
let
fullHostConfig = (nixosSystem (args // { inherit modules; })).config;
isoConfig = (lib.nixosSystem
(args // {
modules = moduleList ++ [
(lib.modules.iso { inherit self nixos inputs fullHostConfig; })
];
})).config;
hmConfig = (lib.nixosSystem
(args // {
modules = moduleList ++ [
(lib.modules.hmConfig)
];
})).config;
in
moduleList ++ [{
system.build = {
iso = isoConfig.system.build.isoImage;
homes = hmConfig.home-manager.users;
};
}];
})
isoConfig = (nixosSystem
(args // {
modules = modules ++ [
(lib.modules.iso { inherit self inputs fullHostConfig; })
];
})).config;
hmConfig = (nixosSystem
(args // {
modules = modules ++ [
(lib.modules.hmConfig)
];
})).config;
in
modules ++ [{
system.build = {
iso = isoConfig.system.build.isoImage;
homes = hmConfig.home-manager.users;
};
lib = {
inherit specialArgs;
testModule = {
imports = modules;
};
};
}];
})