2023-07-20 19:32:47 +03:00
|
|
|
{ config, lib, pkgs, extendModules, ... }@args:
|
2022-10-23 13:29:30 +03:00
|
|
|
let
|
2023-05-16 14:40:03 +03:00
|
|
|
diskoLib = import ./lib {
|
2023-01-24 17:57:17 +03:00
|
|
|
inherit lib;
|
2023-02-07 18:37:12 +03:00
|
|
|
rootMountPoint = config.disko.rootMountPoint;
|
2023-07-20 22:32:53 +03:00
|
|
|
makeTest = import (pkgs.path + "/nixos/tests/make-test-python.nix");
|
|
|
|
eval-config = import (pkgs.path + "/nixos/lib/eval-config.nix");
|
2023-01-24 17:57:17 +03:00
|
|
|
};
|
2022-10-23 13:29:30 +03:00
|
|
|
cfg = config.disko;
|
2023-02-06 17:24:34 +03:00
|
|
|
in
|
|
|
|
{
|
2022-10-23 13:29:30 +03:00
|
|
|
options.disko = {
|
|
|
|
devices = lib.mkOption {
|
2023-07-13 16:08:20 +03:00
|
|
|
type = diskoLib.toplevel;
|
2023-02-06 17:24:34 +03:00
|
|
|
default = { };
|
2023-01-03 21:52:57 +03:00
|
|
|
description = "The devices to set up";
|
2022-10-23 13:29:30 +03:00
|
|
|
};
|
2023-01-24 17:57:17 +03:00
|
|
|
rootMountPoint = lib.mkOption {
|
|
|
|
type = lib.types.str;
|
|
|
|
default = "/mnt";
|
|
|
|
description = "Where the device tree should be mounted by the mountScript";
|
|
|
|
};
|
2022-10-23 13:29:30 +03:00
|
|
|
enableConfig = lib.mkOption {
|
|
|
|
description = ''
|
|
|
|
configure nixos with the specified devices
|
|
|
|
should be true if the system is booted with those devices
|
|
|
|
should be false on an installer image etc.
|
|
|
|
'';
|
|
|
|
type = lib.types.bool;
|
|
|
|
default = true;
|
|
|
|
};
|
2023-01-30 23:36:51 +03:00
|
|
|
checkScripts = lib.mkOption {
|
|
|
|
description = ''
|
|
|
|
Whether to run shellcheck on script outputs
|
|
|
|
'';
|
|
|
|
type = lib.types.bool;
|
|
|
|
default = false;
|
|
|
|
};
|
2023-07-20 19:32:47 +03:00
|
|
|
tests = {
|
|
|
|
efi = lib.mkOption {
|
|
|
|
description = ''
|
|
|
|
Whether efi is enabled for the `system.build.installTest`.
|
|
|
|
We try to automatically detect efi based on the configured bootloader.
|
|
|
|
'';
|
|
|
|
type = lib.types.bool;
|
|
|
|
default = config.boot.loader.systemd-boot.enable || config.boot.loader.grub.efiSupport;
|
|
|
|
};
|
|
|
|
};
|
2022-10-23 13:29:30 +03:00
|
|
|
};
|
2023-02-06 17:24:34 +03:00
|
|
|
config = lib.mkIf (cfg.devices.disk != { }) {
|
2023-07-13 16:08:20 +03:00
|
|
|
system.build = (cfg.devices._scripts { inherit pkgs; checked = cfg.checkScripts; }) // {
|
2022-11-23 15:29:51 +03:00
|
|
|
|
2023-07-30 20:12:24 +03:00
|
|
|
# we keep these old outputs for compatibility
|
|
|
|
disko = builtins.trace "the .disko output is deprecated, please use .diskoScript instead" cfg.devices._scripts.diskoScript;
|
|
|
|
diskoNoDeps = builtins.trace "the .diskoNoDeps output is deprecated, please use .diskoScriptNoDeps instead" cfg.devices._scripts.diskoScriptNoDeps;
|
2023-07-20 19:32:47 +03:00
|
|
|
|
|
|
|
installTest = diskoLib.testLib.makeDiskoTest {
|
|
|
|
inherit extendModules pkgs;
|
|
|
|
name = "${config.networking.hostName}-disko";
|
2023-08-11 09:11:01 +03:00
|
|
|
disko-config = builtins.removeAttrs config [ "_module" ];
|
2023-07-20 19:32:47 +03:00
|
|
|
testMode = "direct";
|
|
|
|
efi = cfg.tests.efi;
|
|
|
|
};
|
2023-07-13 16:08:20 +03:00
|
|
|
};
|
2023-06-23 05:57:57 +03:00
|
|
|
|
2022-11-27 18:50:43 +03:00
|
|
|
|
2023-07-13 16:08:20 +03:00
|
|
|
# we need to specify the keys here, so we don't get an infinite recursion error
|
2022-10-23 13:29:30 +03:00
|
|
|
# Remember to add config keys here if they are added to types
|
2023-08-11 09:11:01 +03:00
|
|
|
fileSystems = lib.mkIf cfg.enableConfig cfg.devices._config.fileSystems or { };
|
|
|
|
boot = lib.mkIf cfg.enableConfig cfg.devices._config.boot or { };
|
|
|
|
swapDevices = lib.mkIf cfg.enableConfig cfg.devices._config.swapDevices or [ ];
|
2022-10-23 13:29:30 +03:00
|
|
|
};
|
|
|
|
}
|