From 8dd338d8d5640f9a487fe2e5a3224892a6e2aa93 Mon Sep 17 00:00:00 2001 From: Oliver Davies Date: Sun, 5 Jan 2025 13:56:55 +0000 Subject: [PATCH] Split t490 configuration --- nix/hosts/t490/configuration.nix | 107 +----------------- nix/hosts/t490/default.nix | 4 + nix/hosts/t490/hardware.nix | 7 ++ nix/hosts/t490/programs.nix | 22 ++++ nix/hosts/t490/services/default.nix | 35 ++++++ .../t490/services/interception-tools.nix | 25 ++++ nix/hosts/t490/services/sound.nix | 12 ++ nix/hosts/t490/services/udev.nix | 9 ++ nix/hosts/t490/services/xserver.nix | 10 ++ nix/hosts/t490/users.nix | 14 +++ 10 files changed, 140 insertions(+), 105 deletions(-) create mode 100644 nix/hosts/t490/hardware.nix create mode 100644 nix/hosts/t490/programs.nix create mode 100644 nix/hosts/t490/services/default.nix create mode 100644 nix/hosts/t490/services/interception-tools.nix create mode 100644 nix/hosts/t490/services/sound.nix create mode 100644 nix/hosts/t490/services/udev.nix create mode 100644 nix/hosts/t490/services/xserver.nix create mode 100644 nix/hosts/t490/users.nix diff --git a/nix/hosts/t490/configuration.nix b/nix/hosts/t490/configuration.nix index 399816b..069fd65 100644 --- a/nix/hosts/t490/configuration.nix +++ b/nix/hosts/t490/configuration.nix @@ -25,62 +25,17 @@ }; }; - services.throttled.enable = true; - services.thermald.enable = true; - services.power-profiles-daemon.enable = false; - systemd.extraConfig = '' DefaultTimeoutStopSec=10s ''; networking.networkmanager.enable = true; - services.xserver = { - enable = true; - - xkb = { - layout = "gb"; - variant = ""; - }; - }; - - services.avahi.enable = true; - services.avahi.nssmdns4 = true; - services.avahi.openFirewall = true; - - services.printing.enable = true; - - hardware.pulseaudio.enable = false; - - hardware.bluetooth.enable = true; - security = { polkit.enable = true; rtkit.enable = true; }; - services.pipewire = { - enable = true; - - alsa = { - enable = true; - support32Bit = true; - }; - - pulse.enable = true; - }; - - users.users.${username} = { - extraGroups = [ "media" ]; - - packages = with pkgs; [ - android-tools - via - ]; - }; - - users.groups.media = { }; - environment.systemPackages = with pkgs; [ gtypist rclone @@ -90,10 +45,6 @@ ytfzf ]; - services.openssh.enable = true; - - programs.dconf.enable = true; - zramSwap.enable = true; nix = { @@ -107,67 +58,13 @@ settings = { auto-optimise-store = true; + experimental-features = [ "nix-command" "flakes" ]; + warn-dirty = false; }; }; - - # Make Caps lock work as an Escape key on press and Ctrl on hold. - services.interception-tools = - let - dfkConfig = pkgs.writeText "dual-function-keys.yaml" '' - MAPPINGS: - - KEY: KEY_CAPSLOCK - TAP: KEY_ESC - HOLD: KEY_LEFTCTRL - ''; - in - { - enable = true; - plugins = pkgs.lib.mkForce [ pkgs.interception-tools-plugins.dual-function-keys ]; - udevmonConfig = '' - - JOB: "${pkgs.interception-tools}/bin/intercept -g $DEVNODE | ${pkgs.interception-tools-plugins.dual-function-keys}/bin/dual-function-keys -c ${dfkConfig} | ${pkgs.interception-tools}/bin/uinput -d $DEVNODE" - DEVICE: - NAME: "AT Translated Set 2 keyboard" - EVENTS: - EV_KEY: [[KEY_CAPSLOCK, KEY_ESC, KEY_LEFTCTRL]] - ''; - }; - - services.gvfs.enable = true; - - programs.gnupg.agent = { - enable = true; - enableSSHSupport = true; - pinentryPackage = pkgs.pinentry-qt; - }; - - programs.firefox = { - enable = true; - languagePacks = [ "en-GB" ]; - preferences = { - "intl.accept_languages" = "en-GB, en"; - "intl.regional_prefs.use_os_locales" = true; - }; - }; - - services.blueman.enable = true; - - services.cron = { - enable = true; - - systemCronJobs = [ "* * * * * opdavies /home/${username}/.local/bin/notify-battery" ]; - }; - - services.auto-cpufreq.enable = true; - - services.udev = { - enable = true; - extraRules = '' - KERNEL=="hidraw*", SUBSYSTEM=="hidraw", MODE="0660", GROUP="users", TAG+="uaccess", TAG+="udev-acl" - ''; - }; } diff --git a/nix/hosts/t490/default.nix b/nix/hosts/t490/default.nix index 2d76c26..7b497fe 100644 --- a/nix/hosts/t490/default.nix +++ b/nix/hosts/t490/default.nix @@ -4,6 +4,10 @@ ../../users/opdavies ./configuration.nix + ./hardware.nix + ./programs.nix + ./services + ./users.nix ]; features = { diff --git a/nix/hosts/t490/hardware.nix b/nix/hosts/t490/hardware.nix new file mode 100644 index 0000000..54785de --- /dev/null +++ b/nix/hosts/t490/hardware.nix @@ -0,0 +1,7 @@ +{ + hardware = { + bluetooth.enable = true; + + pulseaudio.enable = false; + }; +} diff --git a/nix/hosts/t490/programs.nix b/nix/hosts/t490/programs.nix new file mode 100644 index 0000000..83fd67a --- /dev/null +++ b/nix/hosts/t490/programs.nix @@ -0,0 +1,22 @@ +{ pkgs, ... }: + +{ + programs.dconf.enable = true; + + programs.gnupg.agent = { + enable = true; + enableSSHSupport = true; + pinentryPackage = pkgs.pinentry-qt; + }; + + programs.firefox = { + enable = true; + + languagePacks = [ "en-GB" ]; + + preferences = { + "intl.accept_languages" = "en-GB, en"; + "intl.regional_prefs.use_os_locales" = true; + }; + }; +} diff --git a/nix/hosts/t490/services/default.nix b/nix/hosts/t490/services/default.nix new file mode 100644 index 0000000..4b00029 --- /dev/null +++ b/nix/hosts/t490/services/default.nix @@ -0,0 +1,35 @@ +{ username, ... }: + +{ + imports = [ + ./interception-tools.nix + ./sound.nix + ./xserver.nix + ./udev.nix + ]; + + services = { + auto-cpufreq.enable = true; + + avahi = { + enable = true; + nssmdns4 = true; + openFirewall = true; + }; + + blueman.enable = true; + + cron = { + enable = true; + + systemCronJobs = [ "* * * * * opdavies /home/${username}/.local/bin/notify-battery" ]; + }; + + gvfs.enable = true; + openssh.enable = true; + power-profiles-daemon.enable = false; + printing.enable = true; + throttled.enable = true; + thermald.enable = true; + }; +} diff --git a/nix/hosts/t490/services/interception-tools.nix b/nix/hosts/t490/services/interception-tools.nix new file mode 100644 index 0000000..96e43b8 --- /dev/null +++ b/nix/hosts/t490/services/interception-tools.nix @@ -0,0 +1,25 @@ +{ pkgs, ... }: + +{ + # Make Caps lock work as an Escape key on press and Ctrl on hold. + services.interception-tools = + let + dfkConfig = pkgs.writeText "dual-function-keys.yaml" '' + MAPPINGS: + - KEY: KEY_CAPSLOCK + TAP: KEY_ESC + HOLD: KEY_LEFTCTRL + ''; + in + { + enable = true; + plugins = pkgs.lib.mkForce [ pkgs.interception-tools-plugins.dual-function-keys ]; + udevmonConfig = '' + - JOB: "${pkgs.interception-tools}/bin/intercept -g $DEVNODE | ${pkgs.interception-tools-plugins.dual-function-keys}/bin/dual-function-keys -c ${dfkConfig} | ${pkgs.interception-tools}/bin/uinput -d $DEVNODE" + DEVICE: + NAME: "AT Translated Set 2 keyboard" + EVENTS: + EV_KEY: [[KEY_CAPSLOCK, KEY_ESC, KEY_LEFTCTRL]] + ''; + }; +} diff --git a/nix/hosts/t490/services/sound.nix b/nix/hosts/t490/services/sound.nix new file mode 100644 index 0000000..03ff237 --- /dev/null +++ b/nix/hosts/t490/services/sound.nix @@ -0,0 +1,12 @@ +{ + services.pipewire = { + enable = true; + + alsa = { + enable = true; + support32Bit = true; + }; + + pulse.enable = true; + }; +} diff --git a/nix/hosts/t490/services/udev.nix b/nix/hosts/t490/services/udev.nix new file mode 100644 index 0000000..732ca1d --- /dev/null +++ b/nix/hosts/t490/services/udev.nix @@ -0,0 +1,9 @@ +{ + services.udev = { + enable = true; + + extraRules = '' + KERNEL=="hidraw*", SUBSYSTEM=="hidraw", MODE="0660", GROUP="users", TAG+="uaccess", TAG+="udev-acl" + ''; + }; +} diff --git a/nix/hosts/t490/services/xserver.nix b/nix/hosts/t490/services/xserver.nix new file mode 100644 index 0000000..4120a2c --- /dev/null +++ b/nix/hosts/t490/services/xserver.nix @@ -0,0 +1,10 @@ +{ + services.xserver = { + enable = true; + + xkb = { + layout = "gb"; + variant = ""; + }; + }; +} diff --git a/nix/hosts/t490/users.nix b/nix/hosts/t490/users.nix new file mode 100644 index 0000000..1d87bb8 --- /dev/null +++ b/nix/hosts/t490/users.nix @@ -0,0 +1,14 @@ +{ pkgs, username, ... }: + +{ + users.users.${username} = { + extraGroups = [ "media" ]; + + packages = with pkgs; [ + android-tools + via + ]; + }; + + users.groups.media = { }; +}