diff options
| author | Alejandro Soto <alejandro@34project.org> | 2022-03-11 00:58:55 -0600 |
|---|---|---|
| committer | Alejandro Soto <alejandro@34project.org> | 2022-03-11 00:58:55 -0600 |
| commit | 4dd10ae76ba832031b3617341ebb57afe3a8f025 (patch) | |
| tree | b9c8a71dc4ea74c04e0b91ecad01c23e952e1d17 /sys/default.nix | |
| parent | 1f0b119fac141d362094740328ce5f60dd47ad28 (diff) | |
Add user bootloader
Diffstat (limited to '')
| -rw-r--r-- | sys/default.nix | 37 |
1 files changed, 25 insertions, 12 deletions
diff --git a/sys/default.nix b/sys/default.nix index 3c3ab69..7636e91 100644 --- a/sys/default.nix +++ b/sys/default.nix @@ -14,6 +14,10 @@ in { type = bool; }; + loader = mkOption { + type = enum [ "grub" "systemd-boot" ]; + }; + canTouchEfiVariables = mkOption { type = bool; }; @@ -28,7 +32,7 @@ in { }; initrdModules = mkOption { - type = str; + type = listOf str; }; crypt = mkOption { @@ -153,8 +157,15 @@ in { # !!! tmpOnTmpfs = true; - loader = { + loader = (if cfg.loader == "grub" then { + grub = { + enable = true; + device = "nodev"; + efiSupport = true; + }; + } else { systemd-boot.enable = true; + }) // { efi = { inherit (cfg) canTouchEfiVariables; }; @@ -176,6 +187,16 @@ in { sleep 2 #TODO ''; + postMountCommands = let + fromRoot = path: escapeShellArg "/mnt-root/${path}"; + auxOpen = aux: '' + cryptsetup -v open \ + --header ${fromRoot aux.header} \ + --key-file ${fromRoot aux.keyfile} \ + ${aux.device} ${aux.target} + ''; + in concatStringsSep "\n" (map auxOpen cfg.crypt.aux); + luks.devices."${crypt.target}" = { inherit (crypt) device; header = "/initrd-boot/${crypt.headerFromBoot}"; @@ -185,17 +206,9 @@ in { mount -o ro -t vfat ${escapeShellArg cfg.fs.boot.device} /initrd-boot ''; - postOpenCommands = let - fromRoot = path: escapeShellArg "/mnt-root/${path}"; - auxOpen = aux: '' - cryptsetup open \ - --header ${fromRoot aux.header} \ - --key-file ${fromRoot aux.keyfile} \ - ${aux.device} ${aux.target} - ''; - in '' + postOpenCommands = '' umount /initrd-boot - '' + concatStringsSep "\n" (map auxOpen cfg.crypt.aux); + ''; }; #network = { |
