From 6243330c4bb6e07e674da7216b9034a45d276635 Mon Sep 17 00:00:00 2001 From: unexplrd Date: Sun, 21 Dec 2025 22:20:19 +0200 Subject: [PATCH] move locale, add host option --- hosts/dunamis/configuration.nix | 84 +++-------- hosts/dunamis/host.toml | 12 ++ modules/nixos/system/default.nix | 1 - modules/shared/nixos/default.nix | 142 ++++-------------- .../{nixos/system => shared/nixos}/locale.nix | 17 ++- 5 files changed, 75 insertions(+), 181 deletions(-) create mode 100644 hosts/dunamis/host.toml rename modules/{nixos/system => shared/nixos}/locale.nix (60%) diff --git a/hosts/dunamis/configuration.nix b/hosts/dunamis/configuration.nix index 5c668ca..7e27b6b 100644 --- a/hosts/dunamis/configuration.nix +++ b/hosts/dunamis/configuration.nix @@ -1,78 +1,38 @@ { inputs, - lib, pkgs, + lib, ... }: { - imports = with inputs; [ - self.modules.shared.nixos - self.nixosModules.desktop - self.nixosModules.system - ./disko - ./misc - ]; + imports = with inputs.self; + [modules.shared.nixos nixosModules.desktop nixosModules.system] + ++ [./disko ./misc]; - networking = { - hostId = "c7f6c4a1"; - hostName = "dunamis"; - }; - - system.stateVersion = "25.11"; - time.timeZone = "Europe/Kyiv"; - - desktop.niri.enable = true; + desktop.dms.enable = true; services.displayManager.autoLogin = { enable = true; user = "user"; }; - environment.systemPackages = [pkgs.labwc]; - services.xserver = { + services.mullvad-vpn = { enable = true; - desktopManager = { - xterm.enable = false; - xfce = { + package = pkgs.mullvad-vpn; + }; + + module = ( + lib.attrsets.recursiveUpdate + (builtins.fromTOML (builtins.readFile ./host.toml)) + { + stylix = { enable = true; - noDesktop = true; - enableXfwm = false; + theme = "ashes"; + polarity = "dark"; }; - }; - # windowManager.i3.enable = true; - }; - # services.displayManager.defaultSession = "xfce"; - - networking.firewall.allowedTCPPorts = [3923 3921 3990]; # for github:9001/copyparty - - networking.networkmanager.enable = lib.mkDefault false; - systemd.network.networks."10-wan" = { - matchConfig.Name = "enp8s0"; - networkConfig = { - # start a DHCP Client for IPv4 Addressing/Routing - DHCP = "ipv4"; - # accept Router Advertisements for Stateless IPv6 Autoconfiguraton (SLAAC) - IPv6AcceptRA = true; - }; - # make routing on this interface a dependency for network-online.target - linkConfig.RequiredForOnline = "routable"; - }; - - module = { - config = { - secureBoot = true; - tpmDiskUnlock = true; - vaapi = "intel-media-driver"; - }; - stylix = { - enable = true; - theme = "sandcastle"; - }; - locale = "uk_UA.UTF-8"; - misc = { - opentabletdriver.enable = false; - qmk-vial.enable = true; - }; - virt.libvirt.enable = true; - virt.podman.enable = true; - }; + misc.opentabletdriver.enable = false; + misc.qmk-vial.enable = true; + virt.libvirt.enable = true; + virt.podman.enable = true; + } + ); } diff --git a/hosts/dunamis/host.toml b/hosts/dunamis/host.toml new file mode 100644 index 0000000..92acb71 --- /dev/null +++ b/hosts/dunamis/host.toml @@ -0,0 +1,12 @@ +[host] +name = "dunamis" +id = "c7f6c4a1" +type = "workstation" +stateVersion = "24.11" + +[config] +locale = "uk_UA.UTF-8" +timeZone = "Europe/Kyiv" +# secureBoot = true +tpmDiskUnlock = true + diff --git a/modules/nixos/system/default.nix b/modules/nixos/system/default.nix index 6d29c97..cc0f6a2 100644 --- a/modules/nixos/system/default.nix +++ b/modules/nixos/system/default.nix @@ -1,7 +1,6 @@ { imports = [ ./common.nix - ./locale.nix ./misc ./stylix ./virt diff --git a/modules/shared/nixos/default.nix b/modules/shared/nixos/default.nix index 8fd2b5c..17a1d90 100644 --- a/modules/shared/nixos/default.nix +++ b/modules/shared/nixos/default.nix @@ -5,7 +5,7 @@ pkgs, ... }: let - inherit (lib) mkDefault mkEnableOption mkIf; + inherit (lib) mkDefault mkOption mkEnableOption mkIf; cfg = config.module.config; in { imports = [ @@ -15,12 +15,27 @@ in { ./networking ./nix ./security + ./locale.nix ./programs.nix ./services.nix - ./users.nix ./sops.nix + ./users.nix ]; options = { + module.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"]; + }; + }; module.config = { laptop.homeRowMods = mkEnableOption "set to have mods on asdfjkl;"; powerSave = mkEnableOption "set to use various power saving daemons"; @@ -34,121 +49,22 @@ in { }; }; config = lib.mkMerge [ + { + system.stateVersion = config.module.host.stateVersion; + networking = { + hostName = config.module.host.name; + hostId = config.module.host.id; + }; + } { boot.initrd.systemd.tpm2.enable = mkDefault cfg.tpmDiskUnlock; boot.loader.systemd-boot.enable = mkDefault (!cfg.secureBoot); } - (mkIf (cfg.laptop.homeRowMods) { - services.kanata.keyboards.internal.config = '' - ;; Kanata Configuration File for Graphite Anglemod Layout - - ;; Add a default configuration section to define unmapped key behavior. - (defcfg - process-unmapped-keys no ;; Ensure unmapped keys are passed to the OS unchanged. - ) - - ;; Define the source keys Kanata will intercept. - (defsrc - grv 1 2 3 4 5 6 7 8 9 0 - = bspc - tab q w e r t y u i o p [ ] \ - caps a s d f g h j k l ; ' ret - lsft z x c v b n m , . / rsft - lctl lmet lalt spc ralt rmet rctl - ) - - (defvar - tap-time 150 - hold-time 200 - ) - - ;; Default QWERTY Layout - (deflayer qwerty - grv 1 2 3 4 5 6 7 8 9 0 - = bspc - tab q w e r t y u i o p [ ] \ - caps a s d f g h j k l ; ' ret - lsft z x c v b n m , . / rsft - lctl lmet lalt spc ralt rmet rctl - ) - - (defalias - escctrl (tap-hold 100 100 esc lctl) - a (multi f24 (tap-hold $tap-time $hold-time a lalt)) - s (multi f24 (tap-hold $tap-time $hold-time s lmet)) - d (multi f24 (tap-hold $tap-time $hold-time d lctl)) - f (multi f24 (tap-hold $tap-time $hold-time f lsft)) - x (multi f24 (tap-hold $tap-time $hold-time x ralt)) - j (multi f24 (tap-hold $tap-time $hold-time j lsft)) - k (multi f24 (tap-hold $tap-time $hold-time k lctl)) - l (multi f24 (tap-hold $tap-time $hold-time l lmet)) - ; (multi f24 (tap-hold $tap-time $hold-time ; lalt)) - . (multi f24 (tap-hold $tap-time $hold-time . ralt)) - ) - - ;; QWERTY Layout with home row mods - (deflayer qwerty-home-mod - @grl 1 2 3 4 5 6 7 8 9 0 - = bspc - tab q w e r t y u i o p [ ] \ - @esscctrl @a @s @d @f g h @j @k @l @; ' ret - lsft z @x c v b n m , @. / rsft - lctl lmet lalt spc ralt rmet rctl - ) - - (defalias - quote (fork ' S-- (lsft rsft)) ;; ' -> _ - comma (fork , S-/ (lsft rsft)) ;; , -> ? - hyphen (fork - S-' (lsft rsft)) ;; - -> " - slash (fork / S-, (lsft rsft)) ;; / -> < - ) - - (defalias - n (multi f24 (tap-hold $tap-time $hold-time n lalt)) - r (multi f24 (tap-hold $tap-time $hold-time r lmet)) - t (multi f24 (tap-hold $tap-time $hold-time t lctl)) - gs (multi f24 (tap-hold $tap-time $hold-time s lsft)) - m (multi f24 (tap-hold $tap-time $hold-time m ralt)) - h (multi f24 (tap-hold $tap-time $hold-time h lsft)) - ga (multi f24 (tap-hold $tap-time $hold-time a lctl)) - e (multi f24 (tap-hold $tap-time $hold-time e lmet)) - i (multi f24 (tap-hold $tap-time $hold-time i lalt)) - hyph (multi f24 (tap-hold $tap-time $hold-time @hyphen ralt)) - ) - - - ;; Graphite Anglemod Layout - (deflayer graphite-anglemod - @grl 1 2 3 4 5 6 7 8 9 0 [ ] bspc - tab b l d w z @quote f o u j ; = \ - @cap @n @r @t @gs g y @h @ga @e @i @comma ret - lsft x @m c v q p k . @hyph @slash rsft - lctl lmet lalt spc ralt rmet rctl - ) - - ;; Define layer-switching aliases for clean deflayer declarations - (defalias - ;; Tap: backtick (grave), Hold: toggles 'layers' for layer switching. - grl (tap-hold 200 200 grv (layer-toggle layers)) - - ;; Layer-switch aliases - gar (layer-switch graphite-anglemod) - qwr (layer-switch qwerty) - qwm (layer-switch qwerty-home-mod) - - ;; Tap for Caps Lock, Hold for Ctrl - cap (tap-hold 200 200 caps lctl) - ) - - ;; Layer-Switching Layer - ;; Keys 1 and 2 switch between QWERTY and Graphite Anglemod layouts - ;; The _ (underscore) indicates transparent behavior (passes through base layer). - (deflayer layers - _ @qwm @gar @qwr _ _ _ _ _ _ _ _ _ _ - _ _ _ _ _ _ _ _ _ _ _ _ _ _ - _ _ _ _ _ _ _ _ _ _ _ _ _ - _ _ _ _ _ _ _ _ _ _ _ _ - _ _ _ _ _ _ _ - ) - ''; - }) + (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.keyboards.internal.config = builtins.readFile ./kanata/internal.kbd; + }) (mkIf (cfg.powerSave) { powerManagement.enable = true; powerManagement.powertop.enable = true; diff --git a/modules/nixos/system/locale.nix b/modules/shared/nixos/locale.nix similarity index 60% rename from modules/nixos/system/locale.nix rename to modules/shared/nixos/locale.nix index f98f7d9..2152c35 100644 --- a/modules/nixos/system/locale.nix +++ b/modules/shared/nixos/locale.nix @@ -6,15 +6,22 @@ inherit (lib) types mkOption; in { options = { - module.locale = mkOption { - type = types.strMatching "[a-z]{2}_[A-Z]{2}\\.UTF-8"; - default = "en_US.UTF-8"; - description = "set locale"; + module.config = { + locale = mkOption { + type = types.strMatching "[a-z]{2}_[A-Z]{2}\\.UTF-8"; + default = "en_US.UTF-8"; + description = "set locale"; + }; + timeZone = mkOption { + type = types.str; + default = "Europe/Kyiv"; + }; }; }; config = { + time.timeZone = config.module.config.timeZone; i18n = let - inherit (config.module) locale; + inherit (config.module.config) locale; in { defaultLocale = locale; extraLocaleSettings = {