From 714180b6568ed36a1db00e6201e8943be07304a5 Mon Sep 17 00:00:00 2001 From: twoneis Date: Mon, 5 Aug 2024 18:38:58 +0200 Subject: [PATCH] merge options and rename some for fewer top level options --- colors.nix | 44 ----------------- devices/ellaca/default.nix | 12 +++-- devices/ellaca/disks.nix | 2 +- devices/ellaca/options.nix | 1 - devices/inkvine/default.nix | 15 +++--- devices/inkvine/disks.nix | 2 +- devices/inkvine/options.nix | 1 - devices/pleniscenta/default.nix | 16 ++++--- devices/pleniscenta/disks.nix | 2 +- disks.nix | 16 ------- keys.nix | 16 ------- modules/apps/notes.nix | 9 ++-- modules/niri/niri.conf.nix | 34 ++++++------- modules/utils/default.nix | 5 +- modules/utils/helix.conf.nix | 24 +++++----- options.nix | 85 +++++++++++++++++++++++++++------ outputs.nix | 3 -- 17 files changed, 136 insertions(+), 151 deletions(-) delete mode 100644 colors.nix delete mode 100644 disks.nix delete mode 100644 keys.nix diff --git a/colors.nix b/colors.nix deleted file mode 100644 index 0ffbb43..0000000 --- a/colors.nix +++ /dev/null @@ -1,44 +0,0 @@ -{ lib, ... }: let - inherit (lib) mkOption; - inherit (lib.types) attrsOf str; -in { - options = { - theme = mkOption { - type = attrsOf str; - default = { - base = "#191724"; - surface = "#1f1d2e"; - overlay = "#26233a"; - muted = "#6e6a86"; - subtle = "#908caa"; - text = "#e0def4"; - love = "#eb6f92"; - gold = "#f6c177"; - rose = "#ebbcba"; - pine = "#31748f"; - foam = "#9ccfd8"; - iris = "#c4a7e7"; - highlight-low = "#21202e"; - highlight-med = "#403d52"; - highlight-high = "#524f67"; - }; - example = { - base = "#191724"; - surface = "#1f1d2e"; - overlay = "#26233a"; - muted = "#6e6a86"; - subtle = "#908caa"; - text = "#e0def4"; - love = "#eb6f92"; - gold = "#f6c177"; - rose = "#ebbcba"; - pine = "#31748f"; - foam = "#9ccfd8"; - iris = "#c4a7e7"; - highlight-low = "#21202e"; - highlight-med = "#403d52"; - highlight-high = "#524f67"; - }; - }; - }; -} diff --git a/devices/ellaca/default.nix b/devices/ellaca/default.nix index cf68b9b..b57f9e5 100644 --- a/devices/ellaca/default.nix +++ b/devices/ellaca/default.nix @@ -1,4 +1,6 @@ -{ config, pkgs, ... }: { +{ config, pkgs, ... }: let + inherit (config.device) disks; +in{ imports = [ ./options.nix ./disks.nix @@ -31,21 +33,21 @@ fileSystems = { "/boot" = { - device = "/dev/disk/by-uuid/${config.disks.boot}"; + device = "/dev/disk/by-uuid/${disks.boot}"; fsType = "vfat"; }; "/" = { - device = "/dev/disk/by-uuid/${config.disks.root}"; + device = "/dev/disk/by-uuid/${disks.root}"; fsType = "btrfs"; options = [ "subvol=root" "compress=zstd" "noatime" ]; }; "/nix" = { - device = "/dev/disk/by-uuid/${config.disks.root}"; + device = "/dev/disk/by-uuid/${disks.root}"; fsType = "btrfs"; options = [ "subvol=nix" "compress=zstd" "noatime" ]; }; "/ext" = { - device = "/dev/disk/by-uuid/${config.disks.ext}"; + device = "/dev/disk/by-uuid/${disks.ext}"; fsType = "btrfs"; options = [ "subvol=ext" "compress=zstd" "noatime" ]; }; diff --git a/devices/ellaca/disks.nix b/devices/ellaca/disks.nix index 5a6208d..6bf3e54 100644 --- a/devices/ellaca/disks.nix +++ b/devices/ellaca/disks.nix @@ -1,5 +1,5 @@ { ... }: { - disks = { + device.disks = { boot = "12CE-A600"; root = "b4a61b48-017f-4d16-ab05-d5c867f2ca6f"; ext = "3ed92a26-775a-4e39-ac1c-84b2822cd3dd"; diff --git a/devices/ellaca/options.nix b/devices/ellaca/options.nix index 10e3200..97b6637 100644 --- a/devices/ellaca/options.nix +++ b/devices/ellaca/options.nix @@ -4,7 +4,6 @@ niri.enable = true; containers.enable = true; - hwmonPath = "/sys/class/hwmon/hwmon1/temp1_input"; stateVersion = "24.05"; hmStateVersion = "24.11"; }; diff --git a/devices/inkvine/default.nix b/devices/inkvine/default.nix index 0f25186..2461caa 100644 --- a/devices/inkvine/default.nix +++ b/devices/inkvine/default.nix @@ -1,5 +1,6 @@ { lib, config, pkgs, ... }: let inherit (lib) mkDefault; + inherit (config.device) disks; in { imports = [ ./disks.nix @@ -17,7 +18,7 @@ in { boot = { initrd = { availableKernelModules = [ "nvme" "xhci_pci" "thunderbolt" "usb_storage" "sd_mod" ]; - luks.devices.root.device = "/dev/disk/by-uuid/${config.disks.crypt}"; + luks.devices.root.device = "/dev/disk/by-uuid/${disks.crypt}"; }; kernelModules = [ "kvm-amd" ]; kernelPackages = pkgs.linuxPackages_zen; @@ -34,34 +35,34 @@ in { fileSystems = { "/boot" = { - device = "/dev/disk/by-uuid/${config.disks.boot}"; + device = "/dev/disk/by-uuid/${disks.boot}"; fsType = "vfat"; }; "/" = { - device = "/dev/disk/by-uuid/${config.disks.root}"; + device = "/dev/disk/by-uuid/${disks.root}"; fsType = "btrfs"; options = [ "subvol=root" "compress=zstd" "noatime" ]; }; "/nix" = { - device = "/dev/disk/by-uuid/${config.disks.root}"; + device = "/dev/disk/by-uuid/${disks.root}"; fsType = "btrfs"; options = [ "subvol=nix" "compress=zstd" "noatime" ]; neededForBoot = true; }; "/vm" = { - device = "/dev/disk/by-uuid/${config.disks.root}"; + device = "/dev/disk/by-uuid/${disks.root}"; fsType = "btrfs"; options = [ "subvol=vm" "compress=zstd" "noatime" ]; neededForBoot = true; }; "/persist" = { - device = "/dev/disk/by-uuid/${config.disks.root}"; + device = "/dev/disk/by-uuid/${disks.root}"; fsType = "btrfs"; options = [ "subvol=persist" "compress=zstd" "noatime" ]; neededForBoot = true; }; "/swap" = { - device = "/dev/disk/by-uuid/${config.disks.root}"; + device = "/dev/disk/by-uuid/${disks.root}"; fsType = "btrfs"; options = [ "subvol=swap" "noatime" ]; }; diff --git a/devices/inkvine/disks.nix b/devices/inkvine/disks.nix index 056cf34..82e9efd 100644 --- a/devices/inkvine/disks.nix +++ b/devices/inkvine/disks.nix @@ -1,5 +1,5 @@ { ... }: { - disks = { + device.disks = { boot = "BC3B-2104"; crypt = "8c2e23a2-301a-483d-9331-afc982082c8a"; root = "aae3c9f7-579a-48b8-bf20-5c4ae84a7a4a"; diff --git a/devices/inkvine/options.nix b/devices/inkvine/options.nix index ce2e223..c176251 100644 --- a/devices/inkvine/options.nix +++ b/devices/inkvine/options.nix @@ -5,7 +5,6 @@ games.enable = true; secureboot.enable = true; - hwmonPath = "/sys/class/hwmon/hwmon1/temp1_input"; stateVersion = "24.05"; hmStateVersion = "24.11"; }; diff --git a/devices/pleniscenta/default.nix b/devices/pleniscenta/default.nix index 25217ec..c15320d 100644 --- a/devices/pleniscenta/default.nix +++ b/devices/pleniscenta/default.nix @@ -1,4 +1,6 @@ -{ config, pkgs, ... }: { +{ config, pkgs, ... }: let + inherit (config.device) disks; +in { imports = [ ./options.nix ./disks.nix @@ -11,7 +13,7 @@ boot = { initrd = { availableKernelModules = [ "ahci" "xhci_pci" "ums_realtek" "usbhid" "usb_storage" "sd_mod" "sdhci_pci" ]; - luks.devices."root".device = "/dev/disk/by-uuid/${config.disks.crypt}"; + luks.devices.root.device = "/dev/disk/by-uuid/${disks.crypt}"; }; kernelModules = [ "kvm-intel" ]; @@ -27,26 +29,26 @@ fileSystems = { "/boot" = { - device = "/dev/disk/by-uuid/${config.disks.boot}"; + device = "/dev/disk/by-uuid/${disks.boot}"; fsType = "vfat"; }; "/" = { - device = "/dev/disk/by-uuid/${config.disks.root}"; + device = "/dev/disk/by-uuid/${disks.root}"; fsType = "btrfs"; options = [ "subvol=root" "compress=zstd" "noatime" ]; }; "/nix" = { - device = "/dev/disk/by-uuid/${config.disks.root}"; + device = "/dev/disk/by-uuid/${disks.root}"; fsType = "btrfs"; options = [ "subvol=nix" "compress=zstd" "noatime" ]; }; "/persist" = { - device = "/dev/disk/by-uuid/${config.disks.root}"; + device = "/dev/disk/by-uuid/${disks.root}"; fsType = "btrfs"; options = [ "subvol=persist" "compress=zstd" "noatime" ]; }; "/swap" = { - device = "/dev/disk/by-uuid/${config.disks.root}"; + device = "/dev/disk/by-uuid/${disks.root}"; fsType = "btrfs"; options = [ "subvol=swap" "noatime" ]; }; diff --git a/devices/pleniscenta/disks.nix b/devices/pleniscenta/disks.nix index 269d0c7..4c86b9e 100644 --- a/devices/pleniscenta/disks.nix +++ b/devices/pleniscenta/disks.nix @@ -1,5 +1,5 @@ { ... }: { - disks = { + device.disks = { crypt = "470a6d23-9f08-4c4d-afbb-63d6df1ab6a6"; boot = "4A39-D0DF"; root = "75e6536a-4836-4f50-86b3-f9250edca3c0"; diff --git a/disks.nix b/disks.nix deleted file mode 100644 index 104acda..0000000 --- a/disks.nix +++ /dev/null @@ -1,16 +0,0 @@ -{ lib, ... }: let - inherit (lib) mkOption; - inherit (lib.types) attrsOf str; -in { - options = { - disks = mkOption { - type = attrsOf str; - default = { }; - example = { - boot = "4672-C1A9"; - crypt = "747ae319-f189-44f5-9737-a42672e2c02d"; - root = "04255623-c061-4cf0-89fa-b3d8eb239d59"; - }; - }; - }; -} diff --git a/keys.nix b/keys.nix deleted file mode 100644 index 11c6231..0000000 --- a/keys.nix +++ /dev/null @@ -1,16 +0,0 @@ -{ lib, ... }: let - inherit (lib) mkOption; - inherit (lib.types) attrsOf str; -in{ - options = { - keys = mkOption { - type = attrsOf str; - default = { - up = "t"; - down = "n"; - left = "h"; - right = "s"; - }; - }; - }; -} diff --git a/modules/apps/notes.nix b/modules/apps/notes.nix index 122e4a1..ff83db0 100644 --- a/modules/apps/notes.nix +++ b/modules/apps/notes.nix @@ -1,6 +1,7 @@ { lib, config, ... }: let inherit (lib) mkIf; inherit (config) conf; + inherit (config.conf) keys; in mkIf conf.apps.enable { home-manager.users.${conf.username} = { home.packages = [ @@ -9,10 +10,10 @@ in mkIf conf.apps.enable { programs.sioyek = { enable = true; bindings = { - "move_up" = config.keys.up; - "move_down" = config.keys.down; - "move_left" = config.keys.left; - "move_right" = config.keys.right; + "move_up" = keys.up; + "move_down" = keys.down; + "move_left" = keys.left; + "move_right" = keys.right; }; }; }; diff --git a/modules/niri/niri.conf.nix b/modules/niri/niri.conf.nix index 19448f0..ee1f73a 100644 --- a/modules/niri/niri.conf.nix +++ b/modules/niri/niri.conf.nix @@ -1,5 +1,5 @@ { config, ... }: let - inherit (config.keys) up down left right; + inherit (config.conf) keys; in { input = { keyboard = { @@ -108,10 +108,10 @@ in { "Mod+Left".action.focus-column-left = []; "Mod+Right".action.focus-column-right = []; - "Mod+${up}".action.focus-window-up = []; - "Mod+${down}".action.focus-window-down = []; - "Mod+${left}".action.focus-column-left = []; - "Mod+${right}".action.focus-column-right = []; + "Mod+${keys.up}".action.focus-window-up = []; + "Mod+${keys.down}".action.focus-window-down = []; + "Mod+${keys.left}".action.focus-column-left = []; + "Mod+${keys.right}".action.focus-column-right = []; # Move column/window "Mod+Shift+Up".action.move-window-up = []; @@ -119,10 +119,10 @@ in { "Mod+Shift+Left".action.move-column-left = []; "Mod+Shift+Right".action.move-column-right = []; - "Mod+Shift+${up}".action.move-window-up = []; - "Mod+Shift+${down}".action.move-window-down = []; - "Mod+Shift+${left}".action.move-column-left = []; - "Mod+Shift+${right}".action.move-column-right = []; + "Mod+Shift+${keys.up}".action.move-window-up = []; + "Mod+Shift+${keys.down}".action.move-window-down = []; + "Mod+Shift+${keys.left}".action.move-column-left = []; + "Mod+Shift+${keys.right}".action.move-column-right = []; # Move monitor focus "Mod+Ctrl+Up".action.focus-monitor-up = []; @@ -130,20 +130,20 @@ in { "Mod+Ctrl+Left".action.focus-monitor-left = []; "Mod+Ctrl+Right".action.focus-monitor-right = []; - "Mod+Ctrl+${up}".action.focus-monitor-up = []; - "Mod+Ctrl+${down}".action.focus-monitor-down = []; - "Mod+Ctrl+${left}".action.focus-monitor-left = []; - "Mod+Ctrl+${right}".action.focus-monitor-right = []; + "Mod+Ctrl+${keys.up}".action.focus-monitor-up = []; + "Mod+Ctrl+${keys.down}".action.focus-monitor-down = []; + "Mod+Ctrl+${keys.left}".action.focus-monitor-left = []; + "Mod+Ctrl+${keys.right}".action.focus-monitor-right = []; # Move columns between monitors "Mod+Shift+Ctrl+Up".action.move-column-to-monitor-up = []; "Mod+Shift+Ctrl+Down".action.move-column-to-monitor-down = []; "Mod+Shift+Ctrl+Left".action.move-column-to-monitor-left = []; "Mod+Shift+Ctrl+Right".action.move-column-to-monitor-right = []; - "Mod+Shift+Ctrl+${up}".action.move-column-to-monitor-up = []; - "Mod+Shift+Ctrl+${down}".action.move-column-to-monitor-down = []; - "Mod+Shift+Ctrl+${left}".action.move-column-to-monitor-left = []; - "Mod+Shift+Ctrl+${right}".action.move-column-to-monitor-right = []; + "Mod+Shift+Ctrl+${keys.up}".action.move-column-to-monitor-up = []; + "Mod+Shift+Ctrl+${keys.down}".action.move-column-to-monitor-down = []; + "Mod+Shift+Ctrl+${keys.left}".action.move-column-to-monitor-left = []; + "Mod+Shift+Ctrl+${keys.right}".action.move-column-to-monitor-right = []; # Stack windows "Mod+BracketLeft".action.consume-window-into-column = []; diff --git a/modules/utils/default.nix b/modules/utils/default.nix index 268e478..923a623 100644 --- a/modules/utils/default.nix +++ b/modules/utils/default.nix @@ -1,5 +1,6 @@ { config, pkgs, ... }: let inherit (config) conf; + inherit (config.conf) keys; in { programs.fish.enable = true; users.defaultUserShell = pkgs.fish; @@ -30,8 +31,8 @@ in { programs.less = { enable = true; keys = '' - t back-line - n forw-line + ${keys.up} back-line + ${keys.down} forw-line ''; }; diff --git a/modules/utils/helix.conf.nix b/modules/utils/helix.conf.nix index d9d09ef..96546bd 100644 --- a/modules/utils/helix.conf.nix +++ b/modules/utils/helix.conf.nix @@ -1,4 +1,6 @@ -{ config, ... }: { +{ config, ... }: let + inherit (config.conf) keys; +in { theme = "rose_pine"; editor = { @@ -30,19 +32,19 @@ }; keys.normal = { - ${config.keys.up} = "move_line_up"; - ${config.keys.down} = "move_line_down"; - ${config.keys.left} = "move_char_left"; - ${config.keys.right} = "move_char_right"; + ${keys.up} = "move_line_up"; + ${keys.down} = "move_line_down"; + ${keys.left} = "move_char_left"; + ${keys.right} = "move_char_right"; - C-n = "search_next"; - C-t = "search_prev"; + "C-${keys.up}" = "search_prev"; + "C-${keys.down}" = "search_next"; }; keys.select = { - ${config.keys.up} = "extend_line_up"; - ${config.keys.down} = "extend_line_down"; - ${config.keys.left} = "extend_char_left"; - ${config.keys.right} = "extend_char_right"; + ${keys.up} = "extend_line_up"; + ${keys.down} = "extend_line_down"; + ${keys.left} = "extend_char_left"; + ${keys.right} = "extend_char_right"; }; } diff --git a/options.nix b/options.nix index 3f73d90..a4e694b 100644 --- a/options.nix +++ b/options.nix @@ -1,29 +1,25 @@ { lib, ... }: let inherit (lib) mkOption mkEnableOption; - inherit (lib.types) nullOr str; + inherit (lib.types) nullOr attrsOf str; in { options = { conf = { - apps.enable = mkEnableOption "Enable complete configuration for end-user machine"; - niri.enable = mkEnableOption "Enable niri compositor"; - vm.enable = lib.mkEnableOption "Enable VM related configuration"; - containers.enable = mkEnableOption "Enable container support"; - games.enable = mkEnableOption "Enable games"; - impermanence.enable = mkEnableOption "Use impermanence module"; - secureboot.enable = mkEnableOption "Enable secure boot utilities (manual key-enrolling required)"; + apps.enable = mkEnableOption "Enable complete configuration for end-user machine."; + niri.enable = mkEnableOption "Enable niri compositor."; + vm.enable = lib.mkEnableOption "Enable VM related configuration."; + containers.enable = mkEnableOption "Enable container support."; + games.enable = mkEnableOption "Enable games."; + impermanence.enable = mkEnableOption "Use impermanence module."; + secureboot.enable = mkEnableOption "Enable secure boot utilities (manual key-enrolling required)."; + extraLayout.enable = mkEnableOption "Enable additional custom layout."; username = mkOption { type = str; + description = "Username of the default user (single user setup)."; default = "twoneis"; example = "anna"; }; - hwmonPath = mkOption { - type = nullOr str; - default = null; - example = "/sys/class/hwmon/hwmon1/temp1_input"; - }; - stateVersion = mkOption { type = nullOr str; default = null; @@ -35,6 +31,67 @@ in { default = null; example = "24.11"; }; + + keys = mkOption { + type = attrsOf str; + default = { + up = "t"; + down = "n"; + left = "h"; + right = "s"; + }; + }; + }; + + device = { + disks = mkOption { + type = attrsOf str; + description = "A set of UUIDs of the partitions/lvms/... that can be used easily reused in the config. In this config boot and root are assumed to be always present."; + default = { }; + example = { + boot = "4672-C1A9"; + crypt = "747ae319-f189-44f5-9737-a42672e2c02d"; + root = "04255623-c061-4cf0-89fa-b3d8eb239d59"; + }; + }; + }; + + theme = mkOption { + type = attrsOf str; + default = { + base = "#191724"; + surface = "#1f1d2e"; + overlay = "#26233a"; + muted = "#6e6a86"; + subtle = "#908caa"; + text = "#e0def4"; + love = "#eb6f92"; + gold = "#f6c177"; + rose = "#ebbcba"; + pine = "#31748f"; + foam = "#9ccfd8"; + iris = "#c4a7e7"; + highlight-low = "#21202e"; + highlight-med = "#403d52"; + highlight-high = "#524f67"; + }; + example = { + base = "#191724"; + surface = "#1f1d2e"; + overlay = "#26233a"; + muted = "#6e6a86"; + subtle = "#908caa"; + text = "#e0def4"; + love = "#eb6f92"; + gold = "#f6c177"; + rose = "#ebbcba"; + pine = "#31748f"; + foam = "#9ccfd8"; + iris = "#c4a7e7"; + highlight-low = "#21202e"; + highlight-med = "#403d52"; + highlight-high = "#524f67"; + }; }; }; } diff --git a/outputs.nix b/outputs.nix index a4587f9..5ab6ba4 100644 --- a/outputs.nix +++ b/outputs.nix @@ -1,9 +1,6 @@ { nixpkgs, lix, home-manager, nixos-hardware, niri, impermanence, lanzaboote, ... }@inputs: let modules = [ ./modules - ./colors.nix - ./disks.nix - ./keys.nix ./options.nix niri.nixosModules.niri home-manager.nixosModules.home-manager