diff --git a/flake.nix b/flake.nix index e1e5ac5..caf51da 100644 --- a/flake.nix +++ b/flake.nix @@ -14,6 +14,8 @@ timezone = "America/Chicago"; # select timezone locale = "en_US.UTF-8"; # select locale bootMode = "uefi"; # uefi or bios + bootMountPath = "/boot"; # mount path for efi boot partition; only used for uefi boot mode + grubDevice = ""; # device identifier for grub; only used for legacy (bios) boot mode }; # ----- USER SETTINGS ----- # diff --git a/install.sh b/install.sh index 97ee9b7..cfe44f2 100755 --- a/install.sh +++ b/install.sh @@ -13,6 +13,8 @@ if [ -d /sys/firmware/efi/efivars ]; then sed -i "0,/bootMode.*=.*\".*\";/s//bootMode = \"uefi\";/" ~/.dotfiles/flake.nix else sed -i "0,/bootMode.*=.*\".*\";/s//bootMode = \"bios\";/" ~/.dotfiles/flake.nix + grubDevice=$(findmnt / | awk -F' ' '{ print $2 }' | sed 's/\[.*\]//g' | tail -n 1 | lsblk -no pkname | tail -n 1 ) + sed -i "0,/grubDevice.*=.*\".*\";/s//grubDevice = \"\/dev\/$grubDevice\";/" ~/.dotfiles/flake.nix fi # Patch flake.nix with different username/name and remove email by default diff --git a/profiles/homelab/base.nix b/profiles/homelab/base.nix index c32ce2c..cfb8a96 100644 --- a/profiles/homelab/base.nix +++ b/profiles/homelab/base.nix @@ -28,9 +28,12 @@ boot.kernelModules = [ "i2c-dev" "i2c-piix4" ]; # Bootloader - boot.loader.systemd-boot.enable = true; - boot.loader.efi.canTouchEfiVariables = true; - boot.loader.efi.efiSysMountPoint = "/boot"; + # Use systemd-boot if uefi, default to grub otherwise + boot.loader.systemd-boot.enable = if (systemSettings.bootMode == "uefi") then true else false; + boot.loader.efi.canTouchEfiVariables = if (systemSettings.bootMode == "uefi") then true else false; + boot.loader.efi.efiSysMountPoint = systemSettings.bootMountPath; # does nothing if running bios rather than uefi + boot.loader.grub.enable = if (systemSettings.bootMode == "uefi") then false else true; + boot.loader.grub.device = systemSettings.grubDevice; # does nothing if running uefi rather than bios # Networking networking.hostName = systemSettings.hostname; # Define your hostname. diff --git a/profiles/work/configuration.nix b/profiles/work/configuration.nix index acf58c4..cf3e98f 100644 --- a/profiles/work/configuration.nix +++ b/profiles/work/configuration.nix @@ -49,7 +49,9 @@ # Use systemd-boot if uefi, default to grub otherwise boot.loader.systemd-boot.enable = if (systemSettings.bootMode == "uefi") then true else false; boot.loader.efi.canTouchEfiVariables = if (systemSettings.bootMode == "uefi") then true else false; - boot.loader.efi.efiSysMountPoint = "/boot"; # does nothing if running bios rather than uefi + boot.loader.efi.efiSysMountPoint = systemSettings.bootMountPath; # does nothing if running bios rather than uefi + boot.loader.grub.enable = if (systemSettings.bootMode == "uefi") then false else true; + boot.loader.grub.device = systemSettings.grubDevice; # does nothing if running uefi rather than bios # Networking networking.hostName = systemSettings.hostname; # Define your hostname.