Merge pull request #776 from Enzime/populate

module: always populate system.build attributes
This commit is contained in:
Jörg Thalheim authored and GitHub committed 2024-09-19 09:20:53 +02:00
commit a31fe5ef16
2 files changed
+19 -15

No files matched your search

+5 -1
View File
@@ -388,7 +388,11 @@ let
description = '' description = ''
The scripts generated by disko The scripts generated by disko
''; '';
default = { pkgs, checked ? false }: { default = { pkgs, checked ? false }:
let
throwIfNoDisksDetected = _: v: if devices.disk == { } then throw "No disks defined, did you forget to import your disko config?" else v;
in
mapAttrs throwIfNoDisksDetected {
destroyScript = (diskoLib.writeCheckedBash { inherit pkgs checked; }) "disko-destroy" '' destroyScript = (diskoLib.writeCheckedBash { inherit pkgs checked; }) "disko-destroy" ''
export PATH=${lib.makeBinPath (with pkgs; [ export PATH=${lib.makeBinPath (with pkgs; [
util-linux util-linux
+14 -14
View File
@@ -192,10 +192,19 @@ in
visible = "shallow"; visible = "shallow";
}; };
config = lib.mkMerge [ config = {
(lib.mkIf (cfg.devices.disk != { }) { _module.args.diskoLib = import ./lib {
system.build = (cfg.devices._scripts { inherit pkgs; checked = cfg.checkScripts; }) // { inherit lib;
rootMountPoint = config.disko.rootMountPoint;
makeTest = import (pkgs.path + "/nixos/tests/make-test-python.nix");
eval-config = import (pkgs.path + "/nixos/lib/eval-config.nix");
};
system.build = (cfg.devices._scripts { inherit pkgs; checked = cfg.checkScripts; }) // (
let
throwIfNoDisksDetected = _: v: if cfg.devices.disk == { } then throw "No disks defined, did you forget to import your disko config?" else v;
in
lib.mapAttrs throwIfNoDisksDetected {
# we keep these old outputs for compatibility # we keep these old outputs for compatibility
disko = builtins.trace "the .disko output is deprecated, please use .diskoScript instead" (cfg.devices._scripts { inherit pkgs; }).diskoScript; disko = builtins.trace "the .disko output is deprecated, please use .diskoScript instead" (cfg.devices._scripts { inherit pkgs; }).diskoScript;
diskoNoDeps = builtins.trace "the .diskoNoDeps output is deprecated, please use .diskoScriptNoDeps instead" (cfg.devices._scripts { inherit pkgs; }).diskoScriptNoDeps; diskoNoDeps = builtins.trace "the .diskoNoDeps output is deprecated, please use .diskoScriptNoDeps instead" (cfg.devices._scripts { inherit pkgs; }).diskoScriptNoDeps;
@@ -211,22 +220,13 @@ in
}; };
vmWithDisko = lib.mkDefault config.virtualisation.vmVariantWithDisko.system.build.vmWithDisko; vmWithDisko = lib.mkDefault config.virtualisation.vmVariantWithDisko.system.build.vmWithDisko;
}; }
);
# we need to specify the keys here, so we don't get an infinite recursion error # we need to specify the keys here, so we don't get an infinite recursion error
# Remember to add config keys here if they are added to types # Remember to add config keys here if they are added to types
fileSystems = lib.mkIf cfg.enableConfig cfg.devices._config.fileSystems or { }; fileSystems = lib.mkIf cfg.enableConfig cfg.devices._config.fileSystems or { };
boot = lib.mkIf cfg.enableConfig cfg.devices._config.boot or { }; boot = lib.mkIf cfg.enableConfig cfg.devices._config.boot or { };
swapDevices = lib.mkIf cfg.enableConfig cfg.devices._config.swapDevices or [ ]; swapDevices = lib.mkIf cfg.enableConfig cfg.devices._config.swapDevices or [ ];
})
{
_module.args.diskoLib = import ./lib {
inherit lib;
rootMountPoint = config.disko.rootMountPoint;
makeTest = import (pkgs.path + "/nixos/tests/make-test-python.nix");
eval-config = import (pkgs.path + "/nixos/lib/eval-config.nix");
}; };
} }
];
}