1
1
mirror of https://github.com/divnix/digga.git synced 2024-11-26 23:35:12 +03:00

pass builderArgs to config and extract builds

have mkHomeConfiguration create its own custom build within the function
create a externalModule for customBuilds so its easy to add more
This commit is contained in:
Pacman99 2021-04-28 11:30:04 -07:00
parent e1f18728e2
commit e98e595704
7 changed files with 42 additions and 22 deletions

View File

@ -79,7 +79,7 @@
"utils": "utils_2" "utils": "utils_2"
}, },
"locked": { "locked": {
"narHash": "sha256-TQvd6TvSuT0sJCLlGsV65YjB+nIfDdDKZ1F94pCfkTw=", "narHash": "sha256-oTiKYoR210VwjomzfSn/pCJ3immdUDRUPbYTDGaPFn8=",
"path": "./lib", "path": "./lib",
"type": "path" "type": "path"
}, },

View File

@ -57,6 +57,7 @@
externalModules = [ externalModules = [
ci-agent.nixosModules.agent-profile ci-agent.nixosModules.agent-profile
home.nixosModules.home-manager home.nixosModules.home-manager
./modules/customBuilds.nix
]; ];
}; };
hosts = nixos.lib.mkMerge [ hosts = nixos.lib.mkMerge [

View File

@ -4,9 +4,10 @@ nixosConfigurations:
with lib; with lib;
let let
mkHomes = host: config: mkHomes = hostName: host:
mapAttrs' (user: v: nameValuePair "${user}@${host}" v.home) mapAttrs' (user: v: nameValuePair "${user}@${hostName}" v.home)
config.config.system.build.homes; # So this function is useful for non-devos hosts
(host.config.system.build.homes or host.config.home-manager.users);
hmConfigs = mapAttrs mkHomes nixosConfigurations; hmConfigs = mapAttrs mkHomes nixosConfigurations;

View File

@ -64,7 +64,10 @@ lib.systemFlake (lib.mergeAny
hostDefaults = lib.mergeAny hostDefaults { hostDefaults = lib.mergeAny hostDefaults {
specialArgs.suites = cfg.nixos.suites; specialArgs.suites = cfg.nixos.suites;
modules = cfg.nixos.hostDefaults.externalModules ++ defaultModules; modules = cfg.nixos.hostDefaults.externalModules ++ defaultModules;
builder = os.devosSystem { inherit self inputs; }; builder = args: args.specialArgs.channel.input.lib.nixosSystem (lib.mergeAny args {
# So modules and functions can create their own version of the build
modules = [ { lib.builderArgs = args; } ];
});
}; };
nixosModules = lib.exporter.modulesFromList cfg.nixos.hostDefaults.modules; nixosModules = lib.exporter.modulesFromList cfg.nixos.hostDefaults.modules;

View File

@ -43,6 +43,7 @@
_module.args = { _module.args = {
inherit self; inherit self;
devlib = lib;
hosts = builtins.mapAttrs (_: host: host.config) hosts = builtins.mapAttrs (_: host: host.config)
(removeAttrs self.nixosConfigurations [ config.networking.hostName ]); (removeAttrs self.nixosConfigurations [ config.networking.hostName ]);
}; };
@ -111,18 +112,5 @@
}; };
}; };
hmConfig =
{ config, ... }: {
home-manager.useUserPackages = lib.mkForce false;
home-manager.sharedModules = [
{
home.sessionVariables = {
inherit (config.environment.sessionVariables) NIX_PATH;
};
xdg.configFile."nix/registry.json".text =
config.environment.etc."nix/registry.json".text;
}
];
};
} }

View File

@ -23,11 +23,9 @@ let
nixosTesting = nixosTesting =
(import "${toString pkgs.path}/nixos/lib/testing-python.nix" { (import "${toString pkgs.path}/nixos/lib/testing-python.nix" {
inherit (pkgs) system; inherit (pkgs) system;
inherit (host.config.lib) specialArgs; inherit (host.config.lib.builderArgs) specialArgs;
inherit pkgs; inherit pkgs;
extraConfigurations = [ extraConfigurations = host._module.args.modules;
host.config.lib.testModule
];
}); });
in in
test: test:

29
modules/customBuilds.nix Normal file
View File

@ -0,0 +1,29 @@
{ lib, self, devlib, config, modules, channel, ... }:
let
mkBuild = buildModule:
channel.input.lib.nixosSystem (devlib.mergeAny config.lib.builderArgs {
modules = [ buildModule ];
});
in
{
system.build = {
iso = (mkBuild (devlib.modules.isoConfig {
inherit self;
inherit (self) inputs;
fullHostConfig = config;
})).config.system.build.isoImage;
homes = (mkBuild ({ config, ... }: {
home-manager.useUserPackages = lib.mkForce false;
home-manager.sharedModules = [
{
home.sessionVariables = {
inherit (config.environment.sessionVariables) NIX_PATH;
};
xdg.configFile."nix/registry.json".text =
config.environment.etc."nix/registry.json".text;
}
];
})).config.home-manager.users;
};
}