From 95f71801e0d74b75d40abfd52e48d8d987949e84 Mon Sep 17 00:00:00 2001 From: smayzy Date: Fri, 4 Jul 2025 15:49:11 +0200 Subject: [PATCH] try to make grub settings a custom option --- hosts/desktop1/configuration.nix | 2 -- hosts/laptop1/configuration.nix | 2 +- modules/nix/grub.nix | 25 ++++++++++++++++++++----- 3 files changed, 21 insertions(+), 8 deletions(-) diff --git a/hosts/desktop1/configuration.nix b/hosts/desktop1/configuration.nix index 2bbd287..9190cf6 100644 --- a/hosts/desktop1/configuration.nix +++ b/hosts/desktop1/configuration.nix @@ -9,8 +9,6 @@ ../../modules/nix/virt.nix ]; - boot.loader.efi.canTouchEfiVariables = true; - home-manager = { extraSpecialArgs = { inherit inputs; }; users = { diff --git a/hosts/laptop1/configuration.nix b/hosts/laptop1/configuration.nix index 3cd1a6d..c2ccb83 100644 --- a/hosts/laptop1/configuration.nix +++ b/hosts/laptop1/configuration.nix @@ -7,7 +7,7 @@ ./hardware-configuration.nix ]; - boot.loader.grub.efiInstallAsRemovable = true; + smayzy.grub-on-lap = true; home-manager = { extraSpecialArgs = { inherit inputs; }; diff --git a/modules/nix/grub.nix b/modules/nix/grub.nix index e43ff8d..d451d1c 100644 --- a/modules/nix/grub.nix +++ b/modules/nix/grub.nix @@ -1,7 +1,22 @@ { config, lib, pkgs, ... }: + + with lib; + { - boot.loader.systemd-boot.enable = false; - boot.loader.grub.enable = true; - boot.loader.grub.efiSupport = true; - boot.loader.grub.device = "nodev"; -} + options.smayzy.grub-on-lap.enable = mkOption { + type = types.bool; + default = false; + description = "make grub works on this piece of shit laptop that can't boot normally"; + }; + + config = { + boot.loader.systemd-boot.enable = false; + boot.loader.grub.enable = true; + boot.loader.grub.efiSupport = true; + boot.loader.grub.device = "nodev"; + + boot.loader.grub.efiInstallAsRemovable = mkIf config.smayzy.grub-on-lap.enable true; + boot.loader.efi.canTouchEfiVariables = mkIf (!config.smayzy.grub-on-lap.enable) true; + }; + +}