nixos-config/modules/common/boot.nix

63 lines
1.3 KiB
Nix
Raw Normal View History

{ 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: {
name = fs.name;
value = {
device = "/dev/disk/by-uuid/${fs.deviceUUID}";
preLVM = fs.isPreLVM;
};
2024-04-11 20:15:47 +02:00
}) config.luksDevices
);
boot.loader.systemd-boot.enable = config.enableDefaultSystemdBoot;
boot.loader.efi.canTouchEfiVariables = true;
};
}