mirror of
https://github.com/nix-community/disko
synced 2024-11-13 23:57:12 +00:00
module: throw if no disks are defined
This commit is contained in:
parent
706a1722f6
commit
c5853dcb32
2 changed files with 66 additions and 57 deletions
|
@ -388,55 +388,59 @@ let
|
||||||
description = ''
|
description = ''
|
||||||
The scripts generated by disko
|
The scripts generated by disko
|
||||||
'';
|
'';
|
||||||
default = { pkgs, checked ? false }: {
|
default = { pkgs, checked ? false }:
|
||||||
destroyScript = (diskoLib.writeCheckedBash { inherit pkgs checked; }) "disko-destroy" ''
|
let
|
||||||
export PATH=${lib.makeBinPath (with pkgs; [
|
throwIfNoDisksDetected = _: v: if devices.disk == { } then throw "No disks defined, did you forget to import your disko config?" else v;
|
||||||
util-linux
|
in
|
||||||
e2fsprogs
|
mapAttrs throwIfNoDisksDetected {
|
||||||
mdadm
|
destroyScript = (diskoLib.writeCheckedBash { inherit pkgs checked; }) "disko-destroy" ''
|
||||||
zfs
|
export PATH=${lib.makeBinPath (with pkgs; [
|
||||||
lvm2
|
util-linux
|
||||||
bash
|
e2fsprogs
|
||||||
jq
|
mdadm
|
||||||
gnused
|
zfs
|
||||||
gawk
|
lvm2
|
||||||
coreutils-full
|
bash
|
||||||
])}:$PATH
|
jq
|
||||||
${cfg.config._destroy}
|
gnused
|
||||||
'';
|
gawk
|
||||||
|
coreutils-full
|
||||||
|
])}:$PATH
|
||||||
|
${cfg.config._destroy}
|
||||||
|
'';
|
||||||
|
|
||||||
formatScript = (diskoLib.writeCheckedBash { inherit pkgs checked; }) "disko-format" ''
|
formatScript = (diskoLib.writeCheckedBash { inherit pkgs checked; }) "disko-format" ''
|
||||||
export PATH=${lib.makeBinPath (cfg.config._packages pkgs)}:$PATH
|
export PATH=${lib.makeBinPath (cfg.config._packages pkgs)}:$PATH
|
||||||
${cfg.config._create}
|
${cfg.config._create}
|
||||||
'';
|
'';
|
||||||
|
|
||||||
mountScript = (diskoLib.writeCheckedBash { inherit pkgs checked; }) "disko-mount" ''
|
mountScript = (diskoLib.writeCheckedBash { inherit pkgs checked; }) "disko-mount" ''
|
||||||
export PATH=${lib.makeBinPath (cfg.config._packages pkgs)}:$PATH
|
export PATH=${lib.makeBinPath (cfg.config._packages pkgs)}:$PATH
|
||||||
${cfg.config._mount}
|
${cfg.config._mount}
|
||||||
'';
|
'';
|
||||||
|
|
||||||
diskoScript = (diskoLib.writeCheckedBash { inherit pkgs checked; }) "disko" ''
|
diskoScript = (diskoLib.writeCheckedBash { inherit pkgs checked; }) "disko" ''
|
||||||
export PATH=${lib.makeBinPath ((cfg.config._packages pkgs) ++ [ pkgs.bash ])}:$PATH
|
export PATH=${lib.makeBinPath ((cfg.config._packages pkgs) ++ [ pkgs.bash ])}:$PATH
|
||||||
${cfg.config._disko}
|
${cfg.config._disko}
|
||||||
'';
|
'';
|
||||||
|
|
||||||
# These are useful to skip copying executables uploading a script to an in-memory installer
|
# These are useful to skip copying executables uploading a script to an in-memory installer
|
||||||
destroyScriptNoDeps = (diskoLib.writeCheckedBash { inherit pkgs checked; noDeps = true; }) "disko-destroy" ''
|
destroyScriptNoDeps = (diskoLib.writeCheckedBash { inherit pkgs checked; noDeps = true; }) "disko-destroy" ''
|
||||||
${cfg.config._destroy}
|
${cfg.config._destroy}
|
||||||
'';
|
'';
|
||||||
|
|
||||||
formatScriptNoDeps = (diskoLib.writeCheckedBash { inherit pkgs checked; noDeps = true; }) "disko-format" ''
|
formatScriptNoDeps = (diskoLib.writeCheckedBash { inherit pkgs checked; noDeps = true; }) "disko-format" ''
|
||||||
${cfg.config._create}
|
${cfg.config._create}
|
||||||
'';
|
'';
|
||||||
|
|
||||||
mountScriptNoDeps = (diskoLib.writeCheckedBash { inherit pkgs checked; noDeps = true; }) "disko-mount" ''
|
mountScriptNoDeps = (diskoLib.writeCheckedBash { inherit pkgs checked; noDeps = true; }) "disko-mount" ''
|
||||||
${cfg.config._mount}
|
${cfg.config._mount}
|
||||||
'';
|
'';
|
||||||
|
|
||||||
diskoScriptNoDeps = (diskoLib.writeCheckedBash { inherit pkgs checked; noDeps = true; }) "disko" ''
|
diskoScriptNoDeps = (diskoLib.writeCheckedBash { inherit pkgs checked; noDeps = true; }) "disko" ''
|
||||||
${cfg.config._disko}
|
${cfg.config._disko}
|
||||||
'';
|
'';
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
_destroy = lib.mkOption {
|
_destroy = lib.mkOption {
|
||||||
internal = true;
|
internal = true;
|
||||||
|
|
35
module.nix
35
module.nix
|
@ -200,23 +200,28 @@ in
|
||||||
eval-config = import (pkgs.path + "/nixos/lib/eval-config.nix");
|
eval-config = import (pkgs.path + "/nixos/lib/eval-config.nix");
|
||||||
};
|
};
|
||||||
|
|
||||||
system.build = (cfg.devices._scripts { inherit pkgs; checked = cfg.checkScripts; }) // {
|
system.build = (cfg.devices._scripts { inherit pkgs; checked = cfg.checkScripts; }) // (
|
||||||
# we keep these old outputs for compatibility
|
let
|
||||||
disko = builtins.trace "the .disko output is deprecated, please use .diskoScript instead" (cfg.devices._scripts { inherit pkgs; }).diskoScript;
|
throwIfNoDisksDetected = _: v: if cfg.devices.disk == { } then throw "No disks defined, did you forget to import your disko config?" else v;
|
||||||
diskoNoDeps = builtins.trace "the .diskoNoDeps output is deprecated, please use .diskoScriptNoDeps instead" (cfg.devices._scripts { inherit pkgs; }).diskoScriptNoDeps;
|
in
|
||||||
|
lib.mapAttrs throwIfNoDisksDetected {
|
||||||
|
# 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;
|
||||||
|
diskoNoDeps = builtins.trace "the .diskoNoDeps output is deprecated, please use .diskoScriptNoDeps instead" (cfg.devices._scripts { inherit pkgs; }).diskoScriptNoDeps;
|
||||||
|
|
||||||
installTest = diskoLib.testLib.makeDiskoTest {
|
installTest = diskoLib.testLib.makeDiskoTest {
|
||||||
inherit extendModules pkgs;
|
inherit extendModules pkgs;
|
||||||
name = "${config.networking.hostName}-disko";
|
name = "${config.networking.hostName}-disko";
|
||||||
disko-config = builtins.removeAttrs config [ "_module" ];
|
disko-config = builtins.removeAttrs config [ "_module" ];
|
||||||
testMode = "direct";
|
testMode = "direct";
|
||||||
efi = cfg.tests.efi;
|
efi = cfg.tests.efi;
|
||||||
extraSystemConfig = cfg.tests.extraConfig;
|
extraSystemConfig = cfg.tests.extraConfig;
|
||||||
extraTestScript = cfg.tests.extraChecks;
|
extraTestScript = cfg.tests.extraChecks;
|
||||||
};
|
};
|
||||||
|
|
||||||
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
|
||||||
|
|
Loading…
Reference in a new issue