diff --git a/flake.nix b/flake.nix index afed8b7..e1e5ac5 100644 --- a/flake.nix +++ b/flake.nix @@ -13,6 +13,7 @@ profile = "personal"; # select a profile defined from my profiles directory timezone = "America/Chicago"; # select timezone locale = "en_US.UTF-8"; # select locale + bootMode = "uefi"; # uefi or bios }; # ----- USER SETTINGS ----- # diff --git a/install.sh b/install.sh index 57dddb7..97ee9b7 100755 --- a/install.sh +++ b/install.sh @@ -2,15 +2,35 @@ # Automated script to install my dotfiles +# Clone dotfiles nix-shell -p git --command "git clone https://gitlab.com/librephoenix/nixos-config ~/.dotfiles" + +# Generate hardware config for new system sudo nixos-generate-config --show-hardware-config > ~/.dotfiles/system/hardware-configuration.nix + +# Check if uefi or bios +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 +fi + +# Patch flake.nix with different username/name and remove email by default sed -i "0,/emmet/s//$(whoami)/" ~/.dotfiles/flake.nix sed -i "0,/Emmet/s//$(getent passwd $(whoami) | cut -d ':' -f 5 | cut -d ',' -f 1)/" ~/.dotfiles/flake.nix sed -i "s/emmet@librephoenix.com//" ~/.dotfiles/flake.nix + +# Open up editor to manually edit flake.nix before install if [ -z "$EDITOR" ]; then EDITOR=nano; fi $EDITOR ~/.dotfiles/flake.nix; + +# Rebuild system sudo nixos-rebuild switch --flake ~/.dotfiles#system; + +# Install and build home-manager configuration nix run home-manager/master --extra-experimental-features nix-command --extra-experimental-features flakes -- switch --flake ~/.dotfiles#user; + +# Permissions for files that should be owned by root sudo ~/.dotfiles/harden.sh ~/.dotfiles; diff --git a/profiles/work/configuration.nix b/profiles/work/configuration.nix index 8b7e8c0..acf58c4 100644 --- a/profiles/work/configuration.nix +++ b/profiles/work/configuration.nix @@ -46,9 +46,10 @@ boot.kernelModules = [ "i2c-dev" "i2c-piix4" "cpufreq_powersave" ]; # 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 = "/boot"; # does nothing if running bios rather than uefi # Networking networking.hostName = systemSettings.hostname; # Define your hostname.