Split shared host config into dedicated modules

- Add shared modules for boot, hardware, networking, input, and host defaults
- Move host-specific TOML flags to new option namespaces
- Update SSH and service defaults for the new layout
This commit is contained in:
2026-05-11 15:01:36 +03:00
parent e873ad80e0
commit 14b4bdb585
22 changed files with 211 additions and 110 deletions
+10 -86
View File
@@ -1,16 +1,15 @@
{
config,
# inputs,
lib,
pkgs,
...
}: let
inherit (lib) mkDefault mkOption mkEnableOption mkIf;
cfg = config.unexplrd.config;
cfgHost = config.unexplrd.host;
in {
{lib, ...}: {
imports = [
(lib.mkRenamedOptionModule ["unexplrd" "config" "laptop" "homeRowMods"] ["unexplrd" "input" "homeRowMods" "enable"])
(lib.mkRenamedOptionModule ["unexplrd" "config" "powerSave"] ["unexplrd" "hardware" "powerSave" "enable"])
(lib.mkRenamedOptionModule ["unexplrd" "config" "secureBoot"] ["unexplrd" "boot" "secureBoot" "enable"])
(lib.mkRenamedOptionModule ["unexplrd" "config" "tpmDiskUnlock"] ["unexplrd" "boot" "tpmDiskUnlock" "enable"])
(lib.mkRenamedOptionModule ["unexplrd" "config" "useIwd"] ["unexplrd" "networking" "iwd" "enable"])
(lib.mkRenamedOptionModule ["unexplrd" "config" "vaapi"] ["unexplrd" "hardware" "graphics" "vaapi"])
./boot
./hardware
./host.nix
./input/home-row-mods.nix
./misc
./module/lanzaboote.nix
./module/locale.nix
@@ -24,79 +23,4 @@ in {
./sops.nix
./users.nix
];
options = {
unexplrd.host = {
name = mkOption {
type = lib.types.str;
};
id = mkOption {
type = lib.types.strMatching "[a-z0-9]{8}";
};
stateVersion = mkOption {
type = lib.types.strMatching ''[0-9]{2}\.[0-9]{2}'';
};
type = mkOption {
type = lib.types.enum ["laptop" "server" "workstation"];
};
};
unexplrd.config = {
laptop.homeRowMods = mkEnableOption "set to have mods on asdfjkl;";
powerSave = mkEnableOption "set to use various power saving daemons";
secureBoot = mkEnableOption "set if secure boot is configured";
tpmDiskUnlock = mkEnableOption "set if luks enrolled in tpm2";
useIwd = mkEnableOption "set to use iwd instead of wpa-supplicant";
vaapi = lib.mkOption {
type = lib.types.nullOr (lib.types.enum ["intel-media-driver" "nvidia"]);
default = null;
};
};
};
config = lib.mkMerge [
{
system.stateVersion = cfgHost.stateVersion;
networking.hostName = cfgHost.name;
networking.hostId = cfgHost.id;
}
{
boot.initrd.systemd.tpm2.enable = mkDefault cfg.tpmDiskUnlock;
boot.loader.systemd-boot.enable = mkDefault (!cfg.secureBoot);
}
(mkIf (cfg.laptop.homeRowMods)
# lib.asserts.assertMsg (config.services.kanata.enable != config.services.keyd.enable) "Kanata and keyd create soft lock when both enabled"
{
services.kanata.enable = true;
services.kanata.keyboards.internal = {
extraDefCfg = ''
process-unmapped-keys no
'';
configFile = ./kanata/internal.kbd;
};
})
(mkIf (cfg.powerSave) {
powerManagement.enable = true;
powerManagement.powertop.enable = true;
services.power-profiles-daemon.enable = true;
services.thermald.enable = true;
services.upower.enable = true;
hardware.bluetooth.settings.Policy.AutoEnable = false;
})
(mkIf cfg.useIwd {
networking = {
networkmanager.wifi.backend = "iwd";
wireless.iwd.enable = true;
};
})
(mkIf (cfg.vaapi == "intel-media-driver") {
hardware.graphics.extraPackages = with pkgs; [
intel-compute-runtime
intel-media-driver
vpl-gpu-rt
];
})
(mkIf (cfg.vaapi == "nvidia") {
hardware.graphics.extraPackages = with pkgs; [
nvidia-vaapi-driver
];
})
];
}