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