Files
nixos-blueprint/modules/shared/nixos/default.nix
T
2025-11-25 21:22:00 +02:00

179 lines
6.6 KiB
Nix

{
config,
# inputs,
lib,
pkgs,
...
}: let
inherit (lib) mkDefault mkEnableOption mkIf;
cfg = config.module.config;
in {
imports = [
./boot
./hardware
./misc
./networking
./nix
./security
./programs.nix
./services.nix
./users.nix
./sops.nix
];
options = {
module.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 [
{
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.powerSave) {
powerManagement.enable = true;
powerManagement.powertop.enable = true;
services.power-profiles-daemon.enable = true;
services.thermald.enable = true;
services.upower.enable = true;
})
(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
];
})
];
}