move locale, add host option

This commit is contained in:
2025-12-21 22:20:19 +02:00
parent 17246b3ccb
commit 6243330c4b
5 changed files with 75 additions and 181 deletions
-1
View File
@@ -1,7 +1,6 @@
{
imports = [
./common.nix
./locale.nix
./misc
./stylix
./virt
+29 -113
View File
@@ -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;
@@ -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 = {