From 9e94d074ff89f84adb1f167e99dd97b23243b94d Mon Sep 17 00:00:00 2001 From: Charlie Root Date: Mon, 7 Apr 2025 14:01:35 +0200 Subject: [PATCH] flake: set options for both grub and systemd-boot --- hosts/hermit/configuration.nix | 2 +- hosts/temperance/configuration.nix | 3 ++ hosts/tower/configuration.nix | 7 ++-- modules/system/boot/module.nix | 62 ++++++++++++++++++++---------- 4 files changed, 49 insertions(+), 25 deletions(-) diff --git a/hosts/hermit/configuration.nix b/hosts/hermit/configuration.nix index 3c30c09..abb9e89 100644 --- a/hosts/hermit/configuration.nix +++ b/hosts/hermit/configuration.nix @@ -27,6 +27,7 @@ modules = { desktops.hyprland.enable = true; system = { + boot.grub.enable = true; impermanence.enable = false; services = { nextcloud.enable = true; @@ -63,7 +64,6 @@ locate.enable = true; kanata.enable = true; - media.mpd = { enable = true; }; diff --git a/hosts/temperance/configuration.nix b/hosts/temperance/configuration.nix index 91f7a08..d986f3c 100644 --- a/hosts/temperance/configuration.nix +++ b/hosts/temperance/configuration.nix @@ -44,6 +44,9 @@ in { modules = { system = { impermanence.enable = true; + boot = { + systemd-boot.enable = true; + }; services = { nextcloud.enable = true; }; diff --git a/hosts/tower/configuration.nix b/hosts/tower/configuration.nix index aa39d5e..a1428a8 100644 --- a/hosts/tower/configuration.nix +++ b/hosts/tower/configuration.nix @@ -25,10 +25,11 @@ mainUser.gitSigningKey = ""; }; modules = { - services = { - locate.enable = true; - }; + services = { + locate.enable = true; + }; system = { + boot.grub.enable = true; services.forgejo.enable = true; programs = { editors = { diff --git a/modules/system/boot/module.nix b/modules/system/boot/module.nix index b3179d9..9c9214b 100644 --- a/modules/system/boot/module.nix +++ b/modules/system/boot/module.nix @@ -1,34 +1,54 @@ { + config, lib, pkgs, ... }: let inherit (lib.modules) mkForce; + inherit (lib.modules) mkIf; + inherit (lib.options) mkEnableOption; + cfg = config.modules.system.boot; in { - boot = { - initrd = { - verbose = true; - systemd.enable = true; - }; - loader = { - efi.canTouchEfiVariables = true; - systemd-boot = { - enable = true; - editor = mkForce false; - configurationLimit = 5; + options.modules.system.boot = { + grub.enable = mkEnableOption "Grub, a bloated boot loader"; + systemd-boot.enable = mkEnableOption "Poetteringboot"; + }; + config = { + assertions = [ + { + assertion = cfg.systemd-boot.enable || cfg.grub.enable; + message = "No bootloader is enabled."; + } + { + assertion = cfg.systemd-boot.enable -> !cfg.grub.enable && cfg.grub.enable -> !cfg.systemd-boot.enable; + message = "Please enable only ONE of systemd-boot or grub."; + } + ]; + boot = { + initrd = { + verbose = true; + systemd.enable = true; }; - grub = { + loader = { + efi.canTouchEfiVariables = true; + systemd-boot = { + enable = cfg.systemd-boot.enable; + editor = mkForce false; + configurationLimit = 5; + }; + grub = { + enable = cfg.grub.enable; + efiSupport = true; + device = "nodev"; + configurationLimit = 5; + }; + }; + plymouth = { enable = false; - efiSupport = true; - device = "nodev"; - configurationLimit = 5; + # font = "${pkgs.jetbrains-mono}/share/fonts/truetype/JetBrainsMono-Regular.ttf"; + themePackages = [pkgs.plymouth-matrix-theme]; + theme = "matrix"; }; }; - plymouth = { - enable = false; - # font = "${pkgs.jetbrains-mono}/share/fonts/truetype/JetBrainsMono-Regular.ttf"; - themePackages = [pkgs.plymouth-matrix-theme]; - theme = "matrix"; - }; }; }