2023-10-22 17:12:42 +02:00
|
|
|
{ lib, config, ... }:
|
|
|
|
with lib;
|
|
|
|
let
|
|
|
|
luksDevicesModule = types.submodule {
|
|
|
|
options.name = mkOption {
|
|
|
|
type = types.str;
|
|
|
|
description = ''
|
|
|
|
The partition name.
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
|
|
|
|
options.deviceUUID = mkOption {
|
|
|
|
type = types.str;
|
|
|
|
description = ''
|
|
|
|
The partition device UUID.
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
|
|
|
|
options.isPreLVM = mkOption {
|
|
|
|
type = types.bool;
|
|
|
|
default = false;
|
|
|
|
example = true;
|
|
|
|
description = ''
|
|
|
|
Whether the decrypted partition will be a LVM device.
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
};
|
|
|
|
in
|
|
|
|
{
|
|
|
|
options.enableDefaultSystemdBoot = mkOption {
|
|
|
|
type = types.bool;
|
|
|
|
default = true;
|
|
|
|
example = false;
|
|
|
|
description = ''
|
|
|
|
Whether or not enable the default SystemD boot system.
|
|
|
|
Can be useful for devices using u-boot.
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
|
|
|
|
options.luksDevices = mkOption {
|
|
|
|
type = types.listOf luksDevicesModule;
|
|
|
|
default = [ ];
|
|
|
|
description = ''
|
|
|
|
List of LUKS devices.
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
|
|
|
|
config = {
|
2024-04-11 20:15:47 +02:00
|
|
|
boot.initrd.luks.devices = builtins.listToAttrs (
|
|
|
|
map (fs: {
|
2023-10-22 17:12:42 +02:00
|
|
|
name = fs.name;
|
|
|
|
value = {
|
|
|
|
device = "/dev/disk/by-uuid/${fs.deviceUUID}";
|
|
|
|
preLVM = fs.isPreLVM;
|
|
|
|
};
|
2024-04-11 20:15:47 +02:00
|
|
|
}) config.luksDevices
|
|
|
|
);
|
2023-10-22 17:12:42 +02:00
|
|
|
|
|
|
|
boot.loader.systemd-boot.enable = config.enableDefaultSystemdBoot;
|
|
|
|
boot.loader.efi.canTouchEfiVariables = true;
|
|
|
|
};
|
|
|
|
}
|