diff --git a/system/modules/bootloader/default.nix b/system/modules/bootloader/default.nix new file mode 100644 index 00000000..5674575c --- /dev/null +++ b/system/modules/bootloader/default.nix @@ -0,0 +1,35 @@ +{ + config, + lib, + mylib, + ... +}: let + inherit (config.modules) bootloader; +in { + options.modules.bootloader = import ./options.nix {inherit lib mylib;}; + + config = lib.mkIf bootloader.enable (lib.mkMerge [ + { + boot.loader = { + timeout = 10; + efi.canTouchEfiVariables = true; + efi.efiSysMountPoint = bootloader.systemd-boot.bootDevice; + }; + } + (lib.mkIf (bootloader.loader == "systemd-boot") { + boot.loader.systemd-boot = { + enable = true; + configurationLimit = 5; + editor = false; + consoleMode = "max"; + }; + }) + (lib.mkIf (bootloader.loader == "grub") { + boot.loader.grub = { + enable = true; + useOSProber = true; + device = bootloader.grub.bootDevice; + }; + }) + ]); +} diff --git a/system/modules/bootloader/options.nix b/system/modules/bootloader/options.nix new file mode 100644 index 00000000..666c9b3e --- /dev/null +++ b/system/modules/bootloader/options.nix @@ -0,0 +1,31 @@ +{ + lib, + mylib, + ... +}: { + enable = lib.mkEnableOption "Enable boot loader configuration"; + + loader = lib.mkOption { + type = lib.types.enum [ + "grub" + "systemd-boot" + ]; + description = "What boot loader to use"; + example = "systemd-boot"; + default = "systemd-boot"; + }; + + systemd-boot.bootDevice = lib.mkOption { + type = lib.types.str; + description = "The path to the boot partition"; + example = "/boot/efi"; + default = "/boot/efi"; + }; + + grub.bootDevice = lib.mkOption { + type = lib.types.str; + description = "The path to the boot partition"; + example = "/dev/sda"; + default = "/dev/sda"; + }; +} diff --git a/system/modules/default.nix b/system/modules/default.nix index 0cea5e60..68305cf1 100644 --- a/system/modules/default.nix +++ b/system/modules/default.nix @@ -1,5 +1,6 @@ {...}: { imports = [ + ./bootloader ./desktopportal ./fonts ./mime