forked from pub-solar/os
Merge pull request #266 from Pacman99/extract-builds
pass builderArgs to config and extract builds
This commit is contained in:
commit
378107fd03
|
@ -79,7 +79,7 @@
|
|||
"utils": "utils_2"
|
||||
},
|
||||
"locked": {
|
||||
"narHash": "sha256-TQvd6TvSuT0sJCLlGsV65YjB+nIfDdDKZ1F94pCfkTw=",
|
||||
"narHash": "sha256-oTiKYoR210VwjomzfSn/pCJ3immdUDRUPbYTDGaPFn8=",
|
||||
"path": "./lib",
|
||||
"type": "path"
|
||||
},
|
||||
|
|
|
@ -57,6 +57,7 @@
|
|||
externalModules = [
|
||||
ci-agent.nixosModules.agent-profile
|
||||
home.nixosModules.home-manager
|
||||
./modules/customBuilds.nix
|
||||
];
|
||||
};
|
||||
hosts = nixos.lib.mkMerge [
|
||||
|
|
|
@ -4,9 +4,10 @@ nixosConfigurations:
|
|||
|
||||
with lib;
|
||||
let
|
||||
mkHomes = host: config:
|
||||
mapAttrs' (user: v: nameValuePair "${user}@${host}" v.home)
|
||||
config.config.system.build.homes;
|
||||
mkHomes = hostName: host:
|
||||
mapAttrs' (user: v: nameValuePair "${user}@${hostName}" v.home)
|
||||
# So this function is useful for non-devos hosts
|
||||
(host.config.system.build.homes or host.config.home-manager.users);
|
||||
|
||||
hmConfigs = mapAttrs mkHomes nixosConfigurations;
|
||||
|
||||
|
|
|
@ -64,7 +64,10 @@ lib.systemFlake (lib.mergeAny
|
|||
hostDefaults = lib.mergeAny hostDefaults {
|
||||
specialArgs.suites = cfg.nixos.suites;
|
||||
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;
|
||||
|
|
|
@ -43,6 +43,7 @@
|
|||
|
||||
_module.args = {
|
||||
inherit self;
|
||||
devlib = lib;
|
||||
hosts = builtins.mapAttrs (_: host: host.config)
|
||||
(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;
|
||||
}
|
||||
];
|
||||
};
|
||||
}
|
||||
|
||||
|
|
|
@ -23,11 +23,9 @@ let
|
|||
nixosTesting =
|
||||
(import "${toString pkgs.path}/nixos/lib/testing-python.nix" {
|
||||
inherit (pkgs) system;
|
||||
inherit (host.config.lib) specialArgs;
|
||||
inherit (host.config.lib.builderArgs) specialArgs;
|
||||
inherit pkgs;
|
||||
extraConfigurations = [
|
||||
host.config.lib.testModule
|
||||
];
|
||||
extraConfigurations = host._module.args.modules;
|
||||
});
|
||||
in
|
||||
test:
|
||||
|
|
29
modules/customBuilds.nix
Normal file
29
modules/customBuilds.nix
Normal 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;
|
||||
};
|
||||
}
|
Loading…
Reference in a new issue