merge options and rename some for fewer top level options

This commit is contained in:
twoneis 2024-08-05 18:38:58 +02:00
parent 5ceb84faee
commit 714180b656
17 changed files with 136 additions and 151 deletions

View file

@ -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";
};
};
};
}

View file

@ -1,4 +1,6 @@
{ config, pkgs, ... }: { { config, pkgs, ... }: let
inherit (config.device) disks;
in{
imports = [ imports = [
./options.nix ./options.nix
./disks.nix ./disks.nix
@ -31,21 +33,21 @@
fileSystems = { fileSystems = {
"/boot" = { "/boot" = {
device = "/dev/disk/by-uuid/${config.disks.boot}"; device = "/dev/disk/by-uuid/${disks.boot}";
fsType = "vfat"; fsType = "vfat";
}; };
"/" = { "/" = {
device = "/dev/disk/by-uuid/${config.disks.root}"; device = "/dev/disk/by-uuid/${disks.root}";
fsType = "btrfs"; fsType = "btrfs";
options = [ "subvol=root" "compress=zstd" "noatime" ]; options = [ "subvol=root" "compress=zstd" "noatime" ];
}; };
"/nix" = { "/nix" = {
device = "/dev/disk/by-uuid/${config.disks.root}"; device = "/dev/disk/by-uuid/${disks.root}";
fsType = "btrfs"; fsType = "btrfs";
options = [ "subvol=nix" "compress=zstd" "noatime" ]; options = [ "subvol=nix" "compress=zstd" "noatime" ];
}; };
"/ext" = { "/ext" = {
device = "/dev/disk/by-uuid/${config.disks.ext}"; device = "/dev/disk/by-uuid/${disks.ext}";
fsType = "btrfs"; fsType = "btrfs";
options = [ "subvol=ext" "compress=zstd" "noatime" ]; options = [ "subvol=ext" "compress=zstd" "noatime" ];
}; };

View file

@ -1,5 +1,5 @@
{ ... }: { { ... }: {
disks = { device.disks = {
boot = "12CE-A600"; boot = "12CE-A600";
root = "b4a61b48-017f-4d16-ab05-d5c867f2ca6f"; root = "b4a61b48-017f-4d16-ab05-d5c867f2ca6f";
ext = "3ed92a26-775a-4e39-ac1c-84b2822cd3dd"; ext = "3ed92a26-775a-4e39-ac1c-84b2822cd3dd";

View file

@ -4,7 +4,6 @@
niri.enable = true; niri.enable = true;
containers.enable = true; containers.enable = true;
hwmonPath = "/sys/class/hwmon/hwmon1/temp1_input";
stateVersion = "24.05"; stateVersion = "24.05";
hmStateVersion = "24.11"; hmStateVersion = "24.11";
}; };

View file

@ -1,5 +1,6 @@
{ lib, config, pkgs, ... }: let { lib, config, pkgs, ... }: let
inherit (lib) mkDefault; inherit (lib) mkDefault;
inherit (config.device) disks;
in { in {
imports = [ imports = [
./disks.nix ./disks.nix
@ -17,7 +18,7 @@ in {
boot = { boot = {
initrd = { initrd = {
availableKernelModules = [ "nvme" "xhci_pci" "thunderbolt" "usb_storage" "sd_mod" ]; 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" ]; kernelModules = [ "kvm-amd" ];
kernelPackages = pkgs.linuxPackages_zen; kernelPackages = pkgs.linuxPackages_zen;
@ -34,34 +35,34 @@ in {
fileSystems = { fileSystems = {
"/boot" = { "/boot" = {
device = "/dev/disk/by-uuid/${config.disks.boot}"; device = "/dev/disk/by-uuid/${disks.boot}";
fsType = "vfat"; fsType = "vfat";
}; };
"/" = { "/" = {
device = "/dev/disk/by-uuid/${config.disks.root}"; device = "/dev/disk/by-uuid/${disks.root}";
fsType = "btrfs"; fsType = "btrfs";
options = [ "subvol=root" "compress=zstd" "noatime" ]; options = [ "subvol=root" "compress=zstd" "noatime" ];
}; };
"/nix" = { "/nix" = {
device = "/dev/disk/by-uuid/${config.disks.root}"; device = "/dev/disk/by-uuid/${disks.root}";
fsType = "btrfs"; fsType = "btrfs";
options = [ "subvol=nix" "compress=zstd" "noatime" ]; options = [ "subvol=nix" "compress=zstd" "noatime" ];
neededForBoot = true; neededForBoot = true;
}; };
"/vm" = { "/vm" = {
device = "/dev/disk/by-uuid/${config.disks.root}"; device = "/dev/disk/by-uuid/${disks.root}";
fsType = "btrfs"; fsType = "btrfs";
options = [ "subvol=vm" "compress=zstd" "noatime" ]; options = [ "subvol=vm" "compress=zstd" "noatime" ];
neededForBoot = true; neededForBoot = true;
}; };
"/persist" = { "/persist" = {
device = "/dev/disk/by-uuid/${config.disks.root}"; device = "/dev/disk/by-uuid/${disks.root}";
fsType = "btrfs"; fsType = "btrfs";
options = [ "subvol=persist" "compress=zstd" "noatime" ]; options = [ "subvol=persist" "compress=zstd" "noatime" ];
neededForBoot = true; neededForBoot = true;
}; };
"/swap" = { "/swap" = {
device = "/dev/disk/by-uuid/${config.disks.root}"; device = "/dev/disk/by-uuid/${disks.root}";
fsType = "btrfs"; fsType = "btrfs";
options = [ "subvol=swap" "noatime" ]; options = [ "subvol=swap" "noatime" ];
}; };

View file

@ -1,5 +1,5 @@
{ ... }: { { ... }: {
disks = { device.disks = {
boot = "BC3B-2104"; boot = "BC3B-2104";
crypt = "8c2e23a2-301a-483d-9331-afc982082c8a"; crypt = "8c2e23a2-301a-483d-9331-afc982082c8a";
root = "aae3c9f7-579a-48b8-bf20-5c4ae84a7a4a"; root = "aae3c9f7-579a-48b8-bf20-5c4ae84a7a4a";

View file

@ -5,7 +5,6 @@
games.enable = true; games.enable = true;
secureboot.enable = true; secureboot.enable = true;
hwmonPath = "/sys/class/hwmon/hwmon1/temp1_input";
stateVersion = "24.05"; stateVersion = "24.05";
hmStateVersion = "24.11"; hmStateVersion = "24.11";
}; };

View file

@ -1,4 +1,6 @@
{ config, pkgs, ... }: { { config, pkgs, ... }: let
inherit (config.device) disks;
in {
imports = [ imports = [
./options.nix ./options.nix
./disks.nix ./disks.nix
@ -11,7 +13,7 @@
boot = { boot = {
initrd = { initrd = {
availableKernelModules = [ "ahci" "xhci_pci" "ums_realtek" "usbhid" "usb_storage" "sd_mod" "sdhci_pci" ]; 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" ]; kernelModules = [ "kvm-intel" ];
@ -27,26 +29,26 @@
fileSystems = { fileSystems = {
"/boot" = { "/boot" = {
device = "/dev/disk/by-uuid/${config.disks.boot}"; device = "/dev/disk/by-uuid/${disks.boot}";
fsType = "vfat"; fsType = "vfat";
}; };
"/" = { "/" = {
device = "/dev/disk/by-uuid/${config.disks.root}"; device = "/dev/disk/by-uuid/${disks.root}";
fsType = "btrfs"; fsType = "btrfs";
options = [ "subvol=root" "compress=zstd" "noatime" ]; options = [ "subvol=root" "compress=zstd" "noatime" ];
}; };
"/nix" = { "/nix" = {
device = "/dev/disk/by-uuid/${config.disks.root}"; device = "/dev/disk/by-uuid/${disks.root}";
fsType = "btrfs"; fsType = "btrfs";
options = [ "subvol=nix" "compress=zstd" "noatime" ]; options = [ "subvol=nix" "compress=zstd" "noatime" ];
}; };
"/persist" = { "/persist" = {
device = "/dev/disk/by-uuid/${config.disks.root}"; device = "/dev/disk/by-uuid/${disks.root}";
fsType = "btrfs"; fsType = "btrfs";
options = [ "subvol=persist" "compress=zstd" "noatime" ]; options = [ "subvol=persist" "compress=zstd" "noatime" ];
}; };
"/swap" = { "/swap" = {
device = "/dev/disk/by-uuid/${config.disks.root}"; device = "/dev/disk/by-uuid/${disks.root}";
fsType = "btrfs"; fsType = "btrfs";
options = [ "subvol=swap" "noatime" ]; options = [ "subvol=swap" "noatime" ];
}; };

View file

@ -1,5 +1,5 @@
{ ... }: { { ... }: {
disks = { device.disks = {
crypt = "470a6d23-9f08-4c4d-afbb-63d6df1ab6a6"; crypt = "470a6d23-9f08-4c4d-afbb-63d6df1ab6a6";
boot = "4A39-D0DF"; boot = "4A39-D0DF";
root = "75e6536a-4836-4f50-86b3-f9250edca3c0"; root = "75e6536a-4836-4f50-86b3-f9250edca3c0";

View file

@ -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";
};
};
};
}

View file

@ -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";
};
};
};
}

View file

@ -1,6 +1,7 @@
{ lib, config, ... }: let { lib, config, ... }: let
inherit (lib) mkIf; inherit (lib) mkIf;
inherit (config) conf; inherit (config) conf;
inherit (config.conf) keys;
in mkIf conf.apps.enable { in mkIf conf.apps.enable {
home-manager.users.${conf.username} = { home-manager.users.${conf.username} = {
home.packages = [ home.packages = [
@ -9,10 +10,10 @@ in mkIf conf.apps.enable {
programs.sioyek = { programs.sioyek = {
enable = true; enable = true;
bindings = { bindings = {
"move_up" = config.keys.up; "move_up" = keys.up;
"move_down" = config.keys.down; "move_down" = keys.down;
"move_left" = config.keys.left; "move_left" = keys.left;
"move_right" = config.keys.right; "move_right" = keys.right;
}; };
}; };
}; };

View file

@ -1,5 +1,5 @@
{ config, ... }: let { config, ... }: let
inherit (config.keys) up down left right; inherit (config.conf) keys;
in { in {
input = { input = {
keyboard = { keyboard = {
@ -108,10 +108,10 @@ in {
"Mod+Left".action.focus-column-left = []; "Mod+Left".action.focus-column-left = [];
"Mod+Right".action.focus-column-right = []; "Mod+Right".action.focus-column-right = [];
"Mod+${up}".action.focus-window-up = []; "Mod+${keys.up}".action.focus-window-up = [];
"Mod+${down}".action.focus-window-down = []; "Mod+${keys.down}".action.focus-window-down = [];
"Mod+${left}".action.focus-column-left = []; "Mod+${keys.left}".action.focus-column-left = [];
"Mod+${right}".action.focus-column-right = []; "Mod+${keys.right}".action.focus-column-right = [];
# Move column/window # Move column/window
"Mod+Shift+Up".action.move-window-up = []; "Mod+Shift+Up".action.move-window-up = [];
@ -119,10 +119,10 @@ in {
"Mod+Shift+Left".action.move-column-left = []; "Mod+Shift+Left".action.move-column-left = [];
"Mod+Shift+Right".action.move-column-right = []; "Mod+Shift+Right".action.move-column-right = [];
"Mod+Shift+${up}".action.move-window-up = []; "Mod+Shift+${keys.up}".action.move-window-up = [];
"Mod+Shift+${down}".action.move-window-down = []; "Mod+Shift+${keys.down}".action.move-window-down = [];
"Mod+Shift+${left}".action.move-column-left = []; "Mod+Shift+${keys.left}".action.move-column-left = [];
"Mod+Shift+${right}".action.move-column-right = []; "Mod+Shift+${keys.right}".action.move-column-right = [];
# Move monitor focus # Move monitor focus
"Mod+Ctrl+Up".action.focus-monitor-up = []; "Mod+Ctrl+Up".action.focus-monitor-up = [];
@ -130,20 +130,20 @@ in {
"Mod+Ctrl+Left".action.focus-monitor-left = []; "Mod+Ctrl+Left".action.focus-monitor-left = [];
"Mod+Ctrl+Right".action.focus-monitor-right = []; "Mod+Ctrl+Right".action.focus-monitor-right = [];
"Mod+Ctrl+${up}".action.focus-monitor-up = []; "Mod+Ctrl+${keys.up}".action.focus-monitor-up = [];
"Mod+Ctrl+${down}".action.focus-monitor-down = []; "Mod+Ctrl+${keys.down}".action.focus-monitor-down = [];
"Mod+Ctrl+${left}".action.focus-monitor-left = []; "Mod+Ctrl+${keys.left}".action.focus-monitor-left = [];
"Mod+Ctrl+${right}".action.focus-monitor-right = []; "Mod+Ctrl+${keys.right}".action.focus-monitor-right = [];
# Move columns between monitors # Move columns between monitors
"Mod+Shift+Ctrl+Up".action.move-column-to-monitor-up = []; "Mod+Shift+Ctrl+Up".action.move-column-to-monitor-up = [];
"Mod+Shift+Ctrl+Down".action.move-column-to-monitor-down = []; "Mod+Shift+Ctrl+Down".action.move-column-to-monitor-down = [];
"Mod+Shift+Ctrl+Left".action.move-column-to-monitor-left = []; "Mod+Shift+Ctrl+Left".action.move-column-to-monitor-left = [];
"Mod+Shift+Ctrl+Right".action.move-column-to-monitor-right = []; "Mod+Shift+Ctrl+Right".action.move-column-to-monitor-right = [];
"Mod+Shift+Ctrl+${up}".action.move-column-to-monitor-up = []; "Mod+Shift+Ctrl+${keys.up}".action.move-column-to-monitor-up = [];
"Mod+Shift+Ctrl+${down}".action.move-column-to-monitor-down = []; "Mod+Shift+Ctrl+${keys.down}".action.move-column-to-monitor-down = [];
"Mod+Shift+Ctrl+${left}".action.move-column-to-monitor-left = []; "Mod+Shift+Ctrl+${keys.left}".action.move-column-to-monitor-left = [];
"Mod+Shift+Ctrl+${right}".action.move-column-to-monitor-right = []; "Mod+Shift+Ctrl+${keys.right}".action.move-column-to-monitor-right = [];
# Stack windows # Stack windows
"Mod+BracketLeft".action.consume-window-into-column = []; "Mod+BracketLeft".action.consume-window-into-column = [];

View file

@ -1,5 +1,6 @@
{ config, pkgs, ... }: let { config, pkgs, ... }: let
inherit (config) conf; inherit (config) conf;
inherit (config.conf) keys;
in { in {
programs.fish.enable = true; programs.fish.enable = true;
users.defaultUserShell = pkgs.fish; users.defaultUserShell = pkgs.fish;
@ -30,8 +31,8 @@ in {
programs.less = { programs.less = {
enable = true; enable = true;
keys = '' keys = ''
t back-line ${keys.up} back-line
n forw-line ${keys.down} forw-line
''; '';
}; };

View file

@ -1,4 +1,6 @@
{ config, ... }: { { config, ... }: let
inherit (config.conf) keys;
in {
theme = "rose_pine"; theme = "rose_pine";
editor = { editor = {
@ -30,19 +32,19 @@
}; };
keys.normal = { keys.normal = {
${config.keys.up} = "move_line_up"; ${keys.up} = "move_line_up";
${config.keys.down} = "move_line_down"; ${keys.down} = "move_line_down";
${config.keys.left} = "move_char_left"; ${keys.left} = "move_char_left";
${config.keys.right} = "move_char_right"; ${keys.right} = "move_char_right";
C-n = "search_next"; "C-${keys.up}" = "search_prev";
C-t = "search_prev"; "C-${keys.down}" = "search_next";
}; };
keys.select = { keys.select = {
${config.keys.up} = "extend_line_up"; ${keys.up} = "extend_line_up";
${config.keys.down} = "extend_line_down"; ${keys.down} = "extend_line_down";
${config.keys.left} = "extend_char_left"; ${keys.left} = "extend_char_left";
${config.keys.right} = "extend_char_right"; ${keys.right} = "extend_char_right";
}; };
} }

View file

@ -1,29 +1,25 @@
{ lib, ... }: let { lib, ... }: let
inherit (lib) mkOption mkEnableOption; inherit (lib) mkOption mkEnableOption;
inherit (lib.types) nullOr str; inherit (lib.types) nullOr attrsOf str;
in { in {
options = { options = {
conf = { conf = {
apps.enable = mkEnableOption "Enable complete configuration for end-user machine"; apps.enable = mkEnableOption "Enable complete configuration for end-user machine.";
niri.enable = mkEnableOption "Enable niri compositor"; niri.enable = mkEnableOption "Enable niri compositor.";
vm.enable = lib.mkEnableOption "Enable VM related configuration"; vm.enable = lib.mkEnableOption "Enable VM related configuration.";
containers.enable = mkEnableOption "Enable container support"; containers.enable = mkEnableOption "Enable container support.";
games.enable = mkEnableOption "Enable games"; games.enable = mkEnableOption "Enable games.";
impermanence.enable = mkEnableOption "Use impermanence module"; impermanence.enable = mkEnableOption "Use impermanence module.";
secureboot.enable = mkEnableOption "Enable secure boot utilities (manual key-enrolling required)"; secureboot.enable = mkEnableOption "Enable secure boot utilities (manual key-enrolling required).";
extraLayout.enable = mkEnableOption "Enable additional custom layout.";
username = mkOption { username = mkOption {
type = str; type = str;
description = "Username of the default user (single user setup).";
default = "twoneis"; default = "twoneis";
example = "anna"; example = "anna";
}; };
hwmonPath = mkOption {
type = nullOr str;
default = null;
example = "/sys/class/hwmon/hwmon1/temp1_input";
};
stateVersion = mkOption { stateVersion = mkOption {
type = nullOr str; type = nullOr str;
default = null; default = null;
@ -35,6 +31,67 @@ in {
default = null; default = null;
example = "24.11"; 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";
};
}; };
}; };
} }

View file

@ -1,9 +1,6 @@
{ nixpkgs, lix, home-manager, nixos-hardware, niri, impermanence, lanzaboote, ... }@inputs: let { nixpkgs, lix, home-manager, nixos-hardware, niri, impermanence, lanzaboote, ... }@inputs: let
modules = [ modules = [
./modules ./modules
./colors.nix
./disks.nix
./keys.nix
./options.nix ./options.nix
niri.nixosModules.niri niri.nixosModules.niri
home-manager.nixosModules.home-manager home-manager.nixosModules.home-manager