mirror of
https://github.com/NiklasGollenstede/nixos-installer.git
synced 2025-02-16 17:50:55 +01:00
ZFS, encryption (keys, keystore, LUKS), bootFS, ephemeral root (tmpfs, ZFS, F2FS, ...), testing in qemu, options & debugging, ... and many small things
40 lines
1.8 KiB
Markdown
40 lines
1.8 KiB
Markdown
/*
|
|
|
|
# Boot(-loader) File Systems
|
|
|
|
This is a simple shortcut to define and mount a boot/firmware/EFI partition and file system, such that they can get created automatically.
|
|
|
|
|
|
## Implementation
|
|
|
|
```nix
|
|
#*/# end of MarkDown, beginning of NixOS module:
|
|
dirname: inputs: { config, pkgs, lib, ... }: let inherit (inputs.self) lib; in let
|
|
prefix = inputs.config.prefix;
|
|
cfg = config.${prefix}.fs.boot;
|
|
hash = builtins.substring 0 8 (builtins.hashString "sha256" config.networking.hostName);
|
|
in {
|
|
|
|
options.${prefix} = { fs.boot = {
|
|
enable = lib.mkEnableOption "configuration of a boot partition as GPT partition 1 on the »primary« disk and a FAT32 filesystem on it";
|
|
mountpoint = lib.mkOption { description = "Path at which to mount a vfat boot partition."; type = lib.types.str; default = "/boot"; };
|
|
createMbrPart = lib.mkOption { description = "Whether to create a hybrid MBR with (only) the boot partition listed as partition 1."; type = lib.types.bool; default = true; };
|
|
size = lib.mkOption { description = "Size of the boot partition, should be *more* than 32M(iB)."; type = lib.types.str; default = "2G"; };
|
|
}; };
|
|
|
|
config = let
|
|
in lib.mkIf cfg.enable (lib.mkMerge [ ({
|
|
|
|
${prefix} = {
|
|
fs.disks.partitions."boot-${hash}" = { type = "ef00"; size = cfg.size; index = 1; order = 1500; disk = "primary"; }; # require it to be part1, and create it early
|
|
fs.disks.devices = lib.mkIf cfg.createMbrPart { primary = { mbrParts = "1"; extraFDiskCommands = ''
|
|
t;1;c # type ; part1 ; W95 FAT32 (LBA)
|
|
a;1 # active/boot ; part1
|
|
''; }; };
|
|
};
|
|
fileSystems.${cfg.mountpoint} = { fsType = "vfat"; device = "/dev/disk/by-partlabel/boot-${hash}"; neededForBoot = true; options = [ "noatime" "umask=0022" ]; formatOptions = "-F 32"; };
|
|
|
|
}) ]);
|
|
|
|
}
|