From e8d5c27c2d8f76a73a97d2854d5f8890b108a503 Mon Sep 17 00:00:00 2001 From: Cameron Reed Date: Wed, 10 Jan 2024 16:06:59 -0700 Subject: [PATCH] Extract desktops and bootloaders to common/ --- common/bootloader/grub.nix | 45 ++++++++++++++++++++++ common/bootloader/systemd-boot.nix | 17 +++++++++ common/desktop/hyprland.nix | 15 ++++++++ common/desktop/sway.nix | 21 ++++++++++ common/options.nix | 10 +++++ common/users/cameron/default.nix | 6 +-- hosts/nixos/configuration.nix | 61 ++++++++---------------------- 7 files changed, 125 insertions(+), 50 deletions(-) create mode 100644 common/bootloader/grub.nix create mode 100644 common/bootloader/systemd-boot.nix create mode 100644 common/desktop/hyprland.nix create mode 100644 common/desktop/sway.nix create mode 100644 common/options.nix diff --git a/common/bootloader/grub.nix b/common/bootloader/grub.nix new file mode 100644 index 0000000..e382c1a --- /dev/null +++ b/common/bootloader/grub.nix @@ -0,0 +1,45 @@ +{ config, lib, ... }: + +with lib; let + cfg = config.grub; +in { + options.grub = { + device = mkOption { + default = ""; + example = "/dev/disk/by-id/wwn-0x500001234567890a"; + type = types.str; + description = lib.mdDoc '' + The device on which the GRUB boot loader will be installed. + Setting this option also sets GRUB to use legacy boot. + For EFI, do not set this option. + ''; + }; + }; + + config = mkMerge [ + + { + boot.loader.grub = { + enable = true; + + configurationLimit = 25; + default = "saved"; + useOSProber = true; + memtest86.enable = true; + } + } + + (mkIf (cfg.device == "") { + boot.loader = { + efi.canTouchEfiVariables = true; + grub = { + efiSupport = true; + device = "nodev"; + }; + }; + }) + + (mkIf (cfg.device != "") { boot.loader.grub.device = cfg.device; }) + + ]; +} diff --git a/common/bootloader/systemd-boot.nix b/common/bootloader/systemd-boot.nix new file mode 100644 index 0000000..236ae96 --- /dev/null +++ b/common/bootloader/systemd-boot.nix @@ -0,0 +1,17 @@ +{ pkgs, config, ... }: + +{ + boot.loader = { + efi.canTouchEfiVariables = true; + + systemd-boot = { + enable = true; + editor = false; + configurationLimit = 5; + extraInstallCommands = '' + ${pkgs.gnused}/bin/sed -i 's/^version Generation \([0-9]\+\).*$/version Generation \1/' /boot/loader/entries/nixos-generation-* + ${pkgs.gnused}/bin/sed -i 's/^default .*$/default 00-arch.conf/' /boot/loader/loader.conf + ''; + }; + }; +} diff --git a/common/desktop/hyprland.nix b/common/desktop/hyprland.nix new file mode 100644 index 0000000..515360a --- /dev/null +++ b/common/desktop/hyprland.nix @@ -0,0 +1,15 @@ +{ config, pkgs, ... }: + +{ + desktop = "hyprland"; + + programs.hyprland.enable = true; + + environment.systemPackages = (with pkgs; [ + waybar + dmenu + wmenu + ]); + + xdg.portal.wlr.enable = true; +} diff --git a/common/desktop/sway.nix b/common/desktop/sway.nix new file mode 100644 index 0000000..f15b7f9 --- /dev/null +++ b/common/desktop/sway.nix @@ -0,0 +1,21 @@ +{ config, pkgs, ... }: + +{ + desktop = "sway"; + + programs.sway = { + enable = true; + + extraPackages = with pkgs; [ + swaylock + swayidle + dmenu + wmenu + i3status + brightnessctl + wob + ]; + }; + + xdg.portal.wlr.enable = true; +} diff --git a/common/options.nix b/common/options.nix new file mode 100644 index 0000000..9037291 --- /dev/null +++ b/common/options.nix @@ -0,0 +1,10 @@ +{ lib, ... }: + +with lib; { + options = { + desktop = mkOption { + default = ""; + type = types.str; + }; + }; +} diff --git a/common/users/cameron/default.nix b/common/users/cameron/default.nix index d6a83af..763c242 100644 --- a/common/users/cameron/default.nix +++ b/common/users/cameron/default.nix @@ -27,12 +27,10 @@ in { packages = (with pkgs; [ direnv nix-direnv + ] ++ (lib.optionals (config.desktop != "") [ bibata-cursors bibata-cursors-translucent - ]) ++ (with pkgs.gnomeExtensions; [ - gsconnect - dock-from-dash - ]); + ])); }; }; }; diff --git a/hosts/nixos/configuration.nix b/hosts/nixos/configuration.nix index 76eb5d3..665a4d2 100644 --- a/hosts/nixos/configuration.nix +++ b/hosts/nixos/configuration.nix @@ -1,16 +1,16 @@ -# Edit this configuration file to define what should be installed on -# your system. Help is available in the configuration.nix(5) man page -# and in the NixOS manual (accessible by running ‘nixos-help’). - { config, pkgs, ... }: -{ +let common_dir=../../common; +in { imports = [ # Include the results of the hardware scan. ./hardware-configuration.nix - # User configuration - ../../common/users/users.nix + (common_dir + /options.nix) + + (common_dir + /bootloader/systemd-boot.nix) + (common_dir + /users/users.nix) + (common_dir + /desktop/sway.nix) ]; @@ -26,21 +26,7 @@ - # Bootloader Configuration - - boot.loader = { - efi.canTouchEfiVariables = true; - - systemd-boot = { - enable = true; - editor = false; - configurationLimit = 5; - extraInstallCommands = '' - ${pkgs.gnused}/bin/sed -i 's/^version Generation \([0-9]\+\).*$/version Generation \1/' /boot/loader/entries/nixos-generation-* - ${pkgs.gnused}/bin/sed -i 's/^default .*$/default 00-arch.conf/' /boot/loader/loader.conf - ''; - }; - }; + # Kernel Param Configuration boot.kernelParams = [ "quiet" "splash" ]; @@ -100,17 +86,21 @@ programs = { zsh.enable = true; - vim.defaultEditor = true; + neovim = { + defaultEditor = true; + viAlias = true; + vimAlias = true; + }; }; environment.systemPackages = (with pkgs; [ - vim - neovim git + curl wget kitty ranger lf + tmux firefox greetd.tuigreet @@ -118,7 +108,6 @@ environment.shells = with pkgs; [ bash zsh ]; - xdg.portal.wlr.enable = true; nixpkgs.config.allowUnfree = true; @@ -197,26 +186,6 @@ - # Desktop Environment Configuration - - programs = { - sway = { - enable = true; - - extraPackages = with pkgs; [ - swaylock - swayidle - dmenu - wmenu - i3status - brightnessctl - wob - ]; - }; - }; - - - # User Configuration user.cameron.enable = true;