From abd133c244e9c9f9be8a66bd4a2e1a98e4090270 Mon Sep 17 00:00:00 2001 From: Pacman99 Date: Sun, 25 Apr 2021 16:21:40 -0700 Subject: [PATCH] make devosSystem construct a proper nixos builder Get `self` and `inputs` during construction, and rely on specialArgs.channel for nixos flake --- lib/devos/devosSystem.nix | 63 ++++++++++++++++++++++----------------- 1 file changed, 36 insertions(+), 27 deletions(-) diff --git a/lib/devos/devosSystem.nix b/lib/devos/devosSystem.nix index 00c9e3e..c48f68a 100644 --- a/lib/devos/devosSystem.nix +++ b/lib/devos/devosSystem.nix @@ -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; + }; + }; + }]; + })