From 39d8043ed0fb988b873e5f8c27de2040005f5efe Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Vili=20Sinerv=C3=A4?= Date: Thu, 6 Jun 2024 21:12:13 +0300 Subject: [PATCH] Split generic parts out of machine-confs/helium.nix --- hardware-specific/amd-laptop.nix | 24 +++++ hardware-specific/keychron-q11.nix | 10 ++ hardware-specific/trackball.nix | 79 ++++++++++++++ hardware-specific/usb-automount.nix | 9 ++ machine-confs/helium.nix | 155 ++++------------------------ services/game-streaming.nix | 8 ++ services/redshift.nix | 23 +++++ 7 files changed, 172 insertions(+), 136 deletions(-) create mode 100644 hardware-specific/amd-laptop.nix create mode 100644 hardware-specific/keychron-q11.nix create mode 100644 hardware-specific/trackball.nix create mode 100644 hardware-specific/usb-automount.nix create mode 100644 services/game-streaming.nix create mode 100644 services/redshift.nix diff --git a/hardware-specific/amd-laptop.nix b/hardware-specific/amd-laptop.nix new file mode 100644 index 0000000..0ad2f0e --- /dev/null +++ b/hardware-specific/amd-laptop.nix @@ -0,0 +1,24 @@ +# Config for laptop with AMD CPU and integrated graphics +{ config, pkgs, ... }: +{ + environment.systemPackages = with pkgs; [ zenmonitor ]; + + hardware.opengl.extraPackages = with pkgs; [ rocmPackages.clr.icd ]; + + boot.initrd.kernelModules = [ "amdgpu" ]; + + services = { + xserver = { + videoDrivers = [ + "amdgpu" + "modesetting" + ]; + deviceSection = '' + Option "DRI" "2" + Option "TearFree" "true" + ''; + }; + + logind.lidSwitch = "hibernate"; + }; +} diff --git a/hardware-specific/keychron-q11.nix b/hardware-specific/keychron-q11.nix new file mode 100644 index 0000000..d1571c5 --- /dev/null +++ b/hardware-specific/keychron-q11.nix @@ -0,0 +1,10 @@ +# Config for Keychron Q11 keyboard +{ config, pkgs, ... }: +{ + environment.systemPackages = with pkgs; [ via ]; + + # Keychron Q11 + services.udev.extraRules = '' + KERNEL=="hidraw*", SUBSYSTEM=="hidraw", ATTRS{idVendor}=="3434", ATTRS{idProduct}=="01e0", MODE="0660", GROUP="users", TAG+="uaccess", TAG+="udev-acl" + ''; +} diff --git a/hardware-specific/trackball.nix b/hardware-specific/trackball.nix new file mode 100644 index 0000000..115305d --- /dev/null +++ b/hardware-specific/trackball.nix @@ -0,0 +1,79 @@ +# Config for my Logitech trackball +{ config, pkgs, ... }: +{ + disabledModules = [ "services/hardware/libinput.nix" ]; + + nixpkgs.overlays = [ + (final: prev: { + moonlight-qt = prev.moonlight-qt.overrideAttrs (old: { + patches = (old.patches or [ ]) ++ [ ../misc/mouse-accel.patch ]; + }); + }) + ]; + + imports = [ ../misc/libinput.nix ]; + + hardware.logitech.wireless = { + enable = true; + enableGraphical = true; + }; + + services.libinput.mouse = { + accelProfile = "custom"; + accelStepMotion = 5.0e-2; + accelPointsMotion = [ + 0.0 + 2.0e-2 + 4.0e-2 + 6.0e-2 + 8.0e-2 + 0.1 + 0.12 + 0.14 + 0.16 + 0.18 + 0.2 + 0.2525 + 0.31 + 0.3725 + 0.44 + 0.5125 + 0.59 + 0.6725 + 0.76 + 0.8525 + 0.95 + 1.155 + 1.37 + 1.595 + 1.83 + 2.075 + 2.33 + 2.595 + 2.87 + 3.155 + 3.45 + 3.755 + 4.07 + 4.395 + 4.73 + 5.075 + 5.43 + 5.795 + 6.17 + 6.555 + 6.95 + 7.355 + 7.77 + 8.195 + 8.63 + 9.075 + 9.53 + 9.995 + 10.47 + 10.955 + 11.45 + 11.95 + ]; + }; +} diff --git a/hardware-specific/usb-automount.nix b/hardware-specific/usb-automount.nix new file mode 100644 index 0000000..dbacab6 --- /dev/null +++ b/hardware-specific/usb-automount.nix @@ -0,0 +1,9 @@ +# Config for automounting USB devices +{ config, pkgs, ... }: +{ + services = { + devmon.enable = true; + gvfs.enable = true; + udisks2.enable = true; + }; +} diff --git a/machine-confs/helium.nix b/machine-confs/helium.nix index 0447e48..6299e88 100644 --- a/machine-confs/helium.nix +++ b/machine-confs/helium.nix @@ -7,10 +7,12 @@ { networking = { hostName = "helium"; + firewall.allowedUDPPorts = [ 51820 51821 ]; + wg-quick.interfaces = { wg0 = { autostart = false; @@ -59,154 +61,35 @@ imports = [ ../base.nix ../users/vili.nix - ../services/syncthing.nix ../desktop.nix ../development.nix - ../misc/libinput.nix - ]; - disabledModules = [ "services/hardware/libinput.nix" ]; - - nixpkgs.overlays = [ - (final: prev: { - moonlight-qt = prev.moonlight-qt.overrideAttrs (old: { - patches = (old.patches or [ ]) ++ [ ../misc/mouse-accel.patch ]; - }); - }) + ../services/syncthing.nix + ../services/redshift.nix + ../services/game-streaming.nix + ../hardware-specific/keychron-q11.nix + ../hardware-specific/trackball.nix + ../hardware-specific/amd-laptop.nix + ../hardware-specific/usb-automount.nix ]; - environment.systemPackages = with pkgs; [ - zenmonitor - moonlight-qt - parsec-bin - via - ]; + services.xserver.displayManager.setupCommands = '' + ${pkgs.xorg.xrandr}/bin/xrandr --output DisplayPort-0 --auto --pos 0x0 --primary --output eDP --auto --pos 3840x360 + ''; - # HARDWARE SPECIFIC - boot.initrd.kernelModules = [ "amdgpu" ]; - hardware = { - opengl.extraPackages = with pkgs; [ rocmPackages.clr.icd ]; - logitech.wireless = { - enable = true; - enableGraphical = true; + boot = { + resumeDevice = "/dev/mapper/luks-f6e1979b-0dee-4ee9-8170-10490019854b"; + kernelParams = [ "resume_offset=44537856" ]; + + loader = { + systemd-boot.enable = true; + efi.canTouchEfiVariables = true; }; }; - services = { - xserver = { - videoDrivers = [ - "amdgpu" - "modesetting" - ]; - deviceSection = '' - Option "DRI" "2" - Option "TearFree" "true" - ''; - - displayManager.setupCommands = '' - ${pkgs.xorg.xrandr}/bin/xrandr --output DisplayPort-0 --auto --pos 0x0 --primary --output eDP --auto --pos 3840x360 - ''; - }; - - libinput.mouse = { - accelProfile = "custom"; - accelPointsMotion = [ - 0.0 - 2.0e-2 - 4.0e-2 - 6.0e-2 - 8.0e-2 - 0.1 - 0.12 - 0.14 - 0.16 - 0.18 - 0.2 - 0.2525 - 0.31 - 0.3725 - 0.44 - 0.5125 - 0.59 - 0.6725 - 0.76 - 0.8525 - 0.95 - 1.155 - 1.37 - 1.595 - 1.83 - 2.075 - 2.33 - 2.595 - 2.87 - 3.155 - 3.45 - 3.755 - 4.07 - 4.395 - 4.73 - 5.075 - 5.43 - 5.795 - 6.17 - 6.555 - 6.95 - 7.355 - 7.77 - 8.195 - 8.63 - 9.075 - 9.53 - 9.995 - 10.47 - 10.955 - 11.45 - 11.95 - ]; - accelStepMotion = 5.0e-2; - }; - - redshift = { - executable = "/bin/redshift-gtk"; - enable = true; - temperature = { - night = 2800; - day = 6500; - }; - brightness = { - night = "0.5"; - day = "1"; - }; - }; - - devmon.enable = true; - gvfs.enable = true; - udisks2.enable = true; - }; - location = { - latitude = 60.17; - longitude = 24.94; - }; - - # Swap + hibernate swapDevices = [ { device = "/var/lib/swapfile"; size = 16 * 1024; } ]; - boot.resumeDevice = "/dev/mapper/luks-f6e1979b-0dee-4ee9-8170-10490019854b"; - boot.kernelParams = [ "resume_offset=44537856" ]; - services.logind = { - lidSwitch = "hibernate"; - }; - - # Keychron Q11 - services.udev.extraRules = '' - KERNEL=="hidraw*", SUBSYSTEM=="hidraw", ATTRS{idVendor}=="3434", ATTRS{idProduct}=="01e0", MODE="0660", GROUP="users", TAG+="uaccess", TAG+="udev-acl" - ''; - - # Bootloader. - boot.loader.systemd-boot.enable = true; - boot.loader.efi.canTouchEfiVariables = true; } diff --git a/services/game-streaming.nix b/services/game-streaming.nix new file mode 100644 index 0000000..385a399 --- /dev/null +++ b/services/game-streaming.nix @@ -0,0 +1,8 @@ +# Game streaming software (and possibly services in future) +{ config, pkgs, ... }: +{ + environment.systemPackages = with pkgs; [ + moonlight-qt + parsec-bin + ]; +} diff --git a/services/redshift.nix b/services/redshift.nix new file mode 100644 index 0000000..d013455 --- /dev/null +++ b/services/redshift.nix @@ -0,0 +1,23 @@ +# Redshift bluelight reducer +{ config, pkgs, ... }: +{ + services = { + redshift = { + executable = "/bin/redshift-gtk"; + enable = true; + temperature = { + night = 2800; + day = 6500; + }; + brightness = { + night = "0.5"; + day = "1"; + }; + }; + }; + + location = { + latitude = 60.17; + longitude = 24.94; + }; +}