diff --git a/configuration.nix b/configuration.nix index 6d5f971..f41ec0d 100644 --- a/configuration.nix +++ b/configuration.nix @@ -1,4 +1,6 @@ self: { pkgs, ... }: { + imports = [ ./modules/options.nix ]; + # List packages installed in system profile. To search by name, run: # $ nix-env -qaP | grep wget environment.systemPackages = diff --git a/modules/default.nix b/modules/default.nix index e76d59b..f39db14 100644 --- a/modules/default.nix +++ b/modules/default.nix @@ -2,12 +2,13 @@ { imports = [ + ./options.nix + hardware/intel-cpu.nix hardware/amd-cpu.nix hardware/no-mitigations.nix hardware/acer-undervolt.nix - system/roles.nix system/nixpkgs.nix system/location.nix system/shell.nix diff --git a/modules/desktop/audio-rt.nix b/modules/desktop/audio-rt.nix index 9a94e9e..a7a8e56 100644 --- a/modules/desktop/audio-rt.nix +++ b/modules/desktop/audio-rt.nix @@ -38,72 +38,7 @@ let in -{ - options.lumpiasty.audioRt = { - enable = lib.mkEnableOption "Audio RT scheduling and CPU isolation"; - - audioCpus = lib.mkOption { - type = lib.types.str; - default = "12-15"; - description = "CPU list reserved for audio services (systemd cpuset syntax)."; - }; - - nonAudioCpus = lib.mkOption { - type = lib.types.str; - default = "0-11"; - description = "CPU list for everything else."; - }; - - # ------ Individual optimization toggles ------ - - cpuPartitioning = lib.mkOption { - type = lib.types.bool; - default = cfg.enable; - description = '' - Cgroup-based CPU partitioning via dedicated audio.slice and - restricted app/session/background slices. - ''; - }; - - rtLimits = lib.mkOption { - type = lib.types.bool; - default = cfg.enable; - description = '' - Raise rlimits (RTPRIO=95, MEMLOCK=infinity) for the audio group - so PipeWire's module-rt can set SCHED_FIFO 88 directly instead - of going through RTKit's priority-10 ceiling. - ''; - }; - - performanceGovernor = lib.mkOption { - type = lib.types.bool; - default = cfg.enable; - description = '' - Keep cpufreq governor `performance` on the audio cores so they - stay boosted regardless of measured utilization. - ''; - }; - - ananicy = lib.mkOption { - type = lib.types.bool; - default = cfg.enable; - description = '' - Run ananicy-cpp with a rule that pins easyeffects to nice -12 so - its non-RT DSP threads get scheduler preference under load. - ''; - }; - - optimisedBinaries = lib.mkOption { - type = lib.types.bool; - default = cfg.enable; - description = '' - Rebuild easyeffects and its DSP dependencies with -march=znver4 -O3 - (and LTO for cmake builds, target-cpu for rust builds). - ''; - }; - }; - - config = lib.mkMerge [ +{ config = lib.mkMerge [ # --- Optimised binary builds --------------------------------------------- (lib.mkIf (cfg.enable && cfg.optimisedBinaries) { diff --git a/modules/desktop/gnome.nix b/modules/desktop/gnome.nix index 0fdbf8a..be45b1f 100644 --- a/modules/desktop/gnome.nix +++ b/modules/desktop/gnome.nix @@ -1,8 +1,6 @@ { config, lib, pkgs, modulesPath, ... }: { - options.lumpiasty.enableGnome = lib.mkEnableOption "Enable Gnome desktop"; - config = lib.mkIf config.lumpiasty.enableGnome { # Enable the X11 windowing system. services.xserver.enable = true; diff --git a/modules/desktop/plasma.nix b/modules/desktop/plasma.nix index f086457..91399de 100644 --- a/modules/desktop/plasma.nix +++ b/modules/desktop/plasma.nix @@ -1,8 +1,6 @@ { config, lib, pkgs, modulesPath, ... }: { - options.lumpiasty.enablePlasma = lib.mkEnableOption "Enable Plasma6 desktop"; - config = lib.mkIf config.lumpiasty.enablePlasma { # Enable the X11 windowing system. services.xserver.enable = true; diff --git a/modules/desktop/pulseaudio.nix b/modules/desktop/pulseaudio.nix index 7a1b530..7ae4015 100644 --- a/modules/desktop/pulseaudio.nix +++ b/modules/desktop/pulseaudio.nix @@ -2,8 +2,6 @@ { - options.lumpiasty.enablePulseaudio = lib.mkEnableOption "Enable Plasma6 desktop"; - config = lib.mkIf config.lumpiasty.enablePulseaudio { # Enable sound with pipewire. Dont forget after 24.05 services.pulseaudio.enable = false; diff --git a/modules/desktop/tailscale.nix b/modules/desktop/tailscale.nix index 4b256ef..6281f74 100644 --- a/modules/desktop/tailscale.nix +++ b/modules/desktop/tailscale.nix @@ -1,8 +1,6 @@ { config, lib, pkgs, modulesPath, ... }: { - options.lumpiasty.enableTailscale = lib.mkEnableOption "Enable Tailscale VPN"; - config = lib.mkIf config.lumpiasty.enableTailscale { services.tailscale = { enable = true; diff --git a/modules/desktop/touchpad.nix b/modules/desktop/touchpad.nix index 22cf897..294a648 100644 --- a/modules/desktop/touchpad.nix +++ b/modules/desktop/touchpad.nix @@ -1,177 +1,6 @@ -{ config, lib, pkgs, modulesPath, ... }: +{ ... }: -# Touch pad configuration interface - -let - scrollMethods = { - twoFingers = "twoFingers"; - touchPadEdges = "touchPadEdges"; - }; - rightClickMethods = { - bottomRight = "bottomRight"; - twoFingers = "twoFingers"; - }; - accelerationProfiles = { - none = "none"; - default = "default"; - }; -in +# Touch pad configuration interface. +# Options are declared in ./options.nix; config is applied by home-modules/plasma.nix. { - # Copy of https://github.com/nix-community/plasma-manager/blob/trunk/modules/input.nix#L69 - options.lumpiasty.touchPad = { - enable = lib.mkOption { - type = with lib.types; nullOr bool; - default = null; - example = true; - description = '' - Whether to enable the touchpad. - ''; - }; - name = lib.mkOption { - type = with lib.types; nullOr str; - default = null; - example = "PNP0C50:00 0911:5288 Touchpad"; - description = '' - The name of the touchpad. - - This can be found by looking at the `Name` attribute in the section in - the `/proc/bus/input/devices` path belonging to the touchpad. - ''; - }; - vendorId = lib.mkOption { - type = with lib.types; nullOr str; - default = null; - example = "0911"; - description = '' - The vendor ID of the touchpad. - - This can be found by looking at the `Vendor` attribute in the section in - the `/proc/bus/input/devices` path belonging to the touchpad. - ''; - }; - productId = lib.mkOption { - type = with lib.types; nullOr str; - default = null; - example = "5288"; - description = '' - The product ID of the touchpad. - - This can be found by looking at the `Product` attribute in the section in - the `/proc/bus/input/devices` path belonging to the touchpad. - ''; - }; - disableWhileTyping = lib.mkOption { - type = with lib.types; nullOr bool; - default = null; - example = true; - description = '' - Whether to disable the touchpad while typing. - ''; - }; - leftHanded = lib.mkOption { - type = with lib.types; nullOr bool; - default = null; - example = false; - description = '' - Whether to swap the left and right buttons. - ''; - }; - middleButtonEmulation = lib.mkOption { - type = with lib.types; nullOr bool; - default = null; - example = false; - description = '' - Whether to enable middle mouse click emulation by pressing the left and right buttons at the same time. - Activating this increases the click latency by 50ms. - ''; - }; - pointerSpeed = lib.mkOption { - type = with lib.types; nullOr (numbers.between (-1) 1); - default = null; - example = "0"; - description = '' - How fast the pointer moves. - ''; - }; - accelerationProfile = lib.mkOption { - type = with lib.types; nullOr (enum (builtins.attrNames accelerationProfiles)); - default = null; - example = "none"; - description = "Set the touchpad acceleration profile."; - apply = profile: if (profile == null) then null else accelerationProfiles."${profile}"; - }; - naturalScroll = lib.mkOption { - type = with lib.types; nullOr bool; - default = null; - example = true; - description = '' - Whether to enable natural scrolling for the touchpad. - ''; - }; - tapToClick = lib.mkOption { - type = with lib.types; nullOr bool; - default = null; - example = true; - description = '' - Whether to enable tap-to-click for the touchpad. - ''; - }; - tapAndDrag = lib.mkOption { - type = with lib.types; nullOr bool; - default = null; - example = true; - description = '' - Whether to enable tap-and-drag for the touchpad. - ''; - }; - tapDragLock = lib.mkOption { - type = with lib.types; nullOr bool; - default = null; - example = true; - description = '' - Whether to enable the tap-and-drag lock for the touchpad. - ''; - }; - scrollMethod = lib.mkOption { - type = with lib.types; nullOr (enum (builtins.attrNames scrollMethods)); - default = null; - example = "touchPadEdges"; - description = '' - Configure how scrolling is performed on the touchpad. - ''; - apply = method: if (method == null) then null else scrollMethods."${method}"; - }; - scrollSpeed = lib.mkOption { - type = with lib.types; nullOr (numbers.between 0.1 20); - default = null; - example = 0.1; - description = '' - Configure the scrolling speed of the touchpad. Lower is slower. - If unset, KDE Plasma will default to 0.3. - ''; - }; - rightClickMethod = lib.mkOption { - type = with lib.types; nullOr (enum (builtins.attrNames rightClickMethods)); - default = null; - example = "twoFingers"; - description = '' - Configure how right-clicking is performed on the touchpad. - ''; - apply = method: if (method == null) then null else rightClickMethods."${method}"; - }; - twoFingerTap = lib.mkOption { - type = - with lib.types; - nullOr (enum [ - "rightClick" - "middleClick" - ]); - default = null; - example = "twoFingers"; - description = '' - Configure what a two-finger tap maps to on the touchpad. - ''; - apply = v: if (v == null) then null else (v == "middleClick"); - }; - }; } diff --git a/modules/hardware/acer-undervolt.nix b/modules/hardware/acer-undervolt.nix index ad25374..7e7ebec 100644 --- a/modules/hardware/acer-undervolt.nix +++ b/modules/hardware/acer-undervolt.nix @@ -18,8 +18,6 @@ # persist values across boot / resume. { - options.lumpiasty.acerUndervolt = lib.mkEnableOption "ryzenadj + ryzen_smu tooling for Acer 8845HS"; - config = lib.mkIf config.lumpiasty.acerUndervolt { boot.kernelModules = [ "ryzen_smu" ]; boot.extraModulePackages = [ config.boot.kernelPackages.ryzen-smu ]; diff --git a/modules/hardware/amd-cpu.nix b/modules/hardware/amd-cpu.nix index 0481b8d..9cb6820 100644 --- a/modules/hardware/amd-cpu.nix +++ b/modules/hardware/amd-cpu.nix @@ -1,8 +1,6 @@ { config, lib, pkgs, modulesPath, ... }: { - options.lumpiasty.amdCpu = lib.mkEnableOption "Enable amd CPU"; - config = lib.mkIf config.lumpiasty.amdCpu { nixpkgs.hostPlatform = lib.mkDefault "x86_64-linux"; hardware.cpu.amd.updateMicrocode = true; diff --git a/modules/hardware/intel-cpu.nix b/modules/hardware/intel-cpu.nix index 1af3b8f..cc84e38 100644 --- a/modules/hardware/intel-cpu.nix +++ b/modules/hardware/intel-cpu.nix @@ -1,8 +1,6 @@ { config, lib, pkgs, modulesPath, ... }: { - options.lumpiasty.intelCpu = lib.mkEnableOption "Enable intel CPU"; - config = lib.mkIf config.lumpiasty.intelCpu { nixpkgs.hostPlatform = lib.mkDefault "x86_64-linux"; # hardware.cpu.intel.updateMicrocode = true; diff --git a/modules/hardware/no-mitigations.nix b/modules/hardware/no-mitigations.nix index c53ce78..a047285 100644 --- a/modules/hardware/no-mitigations.nix +++ b/modules/hardware/no-mitigations.nix @@ -1,8 +1,6 @@ { config, lib, pkgs, modulesPath, ... }: { - options.lumpiasty.noMitigations = lib.mkEnableOption "Disable mitigations"; - config = lib.mkIf config.lumpiasty.noMitigations { boot.kernelParams = [ "mitigations=off" diff --git a/modules/options.nix b/modules/options.nix new file mode 100644 index 0000000..940bbd6 --- /dev/null +++ b/modules/options.nix @@ -0,0 +1,258 @@ +{ config, lib, ... }: + +let + scrollMethods = { + twoFingers = "twoFingers"; + touchPadEdges = "touchPadEdges"; + }; + rightClickMethods = { + bottomRight = "bottomRight"; + twoFingers = "twoFingers"; + }; + accelerationProfiles = { + none = "none"; + default = "default"; + }; +in +{ + options.lumpiasty = { + pc = lib.mkEnableOption "Enable options specific to personal computers"; + laptop = lib.mkEnableOption "Enable options specific to laptops"; + intelCpu = lib.mkEnableOption "Enable intel CPU"; + amdCpu = lib.mkEnableOption "Enable amd CPU"; + noMitigations = lib.mkEnableOption "Disable mitigations"; + acerUndervolt = lib.mkEnableOption "ryzenadj + ryzen_smu tooling for Acer 8845HS"; + enablePlasma = lib.mkEnableOption "Enable Plasma6 desktop"; + enableGnome = lib.mkEnableOption "Enable Gnome desktop"; + enablePulseaudio = lib.mkEnableOption "Enable Pulseaudio/Pipewire"; + enableTailscale = lib.mkEnableOption "Enable Tailscale VPN"; + sshd = lib.mkEnableOption "Enable OpenSSH server"; + gaming = lib.mkEnableOption "Enable options specific to gaming computers"; + scx = lib.mkEnableOption "Enable sched-ext"; + ipv6Mostly = lib.mkEnableOption "Enable IPv6-mostly (RFC 8925 + CLAT/464XLAT) support in NetworkManager"; + + users = { + user = lib.mkEnableOption "Create user \"user\""; + drugi = lib.mkEnableOption "Create user \"drugi\""; + }; + + touchPad = { + enable = lib.mkOption { + type = with lib.types; nullOr bool; + default = null; + example = true; + description = '' + Whether to enable the touchpad. + ''; + }; + name = lib.mkOption { + type = with lib.types; nullOr str; + default = null; + example = "PNP0C50:00 0911:5288 Touchpad"; + description = '' + The name of the touchpad. + + This can be found by looking at the `Name` attribute in the section in + the `/proc/bus/input/devices` path belonging to the touchpad. + ''; + }; + vendorId = lib.mkOption { + type = with lib.types; nullOr str; + default = null; + example = "0911"; + description = '' + The vendor ID of the touchpad. + + This can be found by looking at the `Vendor` attribute in the section in + the `/proc/bus/input/devices` path belonging to the touchpad. + ''; + }; + productId = lib.mkOption { + type = with lib.types; nullOr str; + default = null; + example = "5288"; + description = '' + The product ID of the touchpad. + + This can be found by looking at the `Product` attribute in the section in + the `/proc/bus/input/devices` path belonging to the touchpad. + ''; + }; + disableWhileTyping = lib.mkOption { + type = with lib.types; nullOr bool; + default = null; + example = true; + description = '' + Whether to disable the touchpad while typing. + ''; + }; + leftHanded = lib.mkOption { + type = with lib.types; nullOr bool; + default = null; + example = false; + description = '' + Whether to swap the left and right buttons. + ''; + }; + middleButtonEmulation = lib.mkOption { + type = with lib.types; nullOr bool; + default = null; + example = false; + description = '' + Whether to enable middle mouse click emulation by pressing the left and right buttons at the same time. + Activating this increases the click latency by 50ms. + ''; + }; + pointerSpeed = lib.mkOption { + type = with lib.types; nullOr (numbers.between (-1) 1); + default = null; + example = "0"; + description = '' + How fast the pointer moves. + ''; + }; + accelerationProfile = lib.mkOption { + type = with lib.types; nullOr (enum (builtins.attrNames accelerationProfiles)); + default = null; + example = "none"; + description = "Set the touchpad acceleration profile."; + apply = profile: if (profile == null) then null else accelerationProfiles."${profile}"; + }; + naturalScroll = lib.mkOption { + type = with lib.types; nullOr bool; + default = null; + example = true; + description = '' + Whether to enable natural scrolling for the touchpad. + ''; + }; + tapToClick = lib.mkOption { + type = with lib.types; nullOr bool; + default = null; + example = true; + description = '' + Whether to enable tap-to-click for the touchpad. + ''; + }; + tapAndDrag = lib.mkOption { + type = with lib.types; nullOr bool; + default = null; + example = true; + description = '' + Whether to enable tap-and-drag for the touchpad. + ''; + }; + tapDragLock = lib.mkOption { + type = with lib.types; nullOr bool; + default = null; + example = true; + description = '' + Whether to enable the tap-and-drag lock for the touchpad. + ''; + }; + scrollMethod = lib.mkOption { + type = with lib.types; nullOr (enum (builtins.attrNames scrollMethods)); + default = null; + example = "touchPadEdges"; + description = '' + Configure how scrolling is performed on the touchpad. + ''; + apply = method: if (method == null) then null else scrollMethods."${method}"; + }; + scrollSpeed = lib.mkOption { + type = with lib.types; nullOr (numbers.between 0.1 20); + default = null; + example = 0.1; + description = '' + Configure the scrolling speed of the touchpad. Lower is slower. + If unset, KDE Plasma will default to 0.3. + ''; + }; + rightClickMethod = lib.mkOption { + type = with lib.types; nullOr (enum (builtins.attrNames rightClickMethods)); + default = null; + example = "twoFingers"; + description = '' + Configure how right-clicking is performed on the touchpad. + ''; + apply = method: if (method == null) then null else rightClickMethods."${method}"; + }; + twoFingerTap = lib.mkOption { + type = + with lib.types; + nullOr (enum [ + "rightClick" + "middleClick" + ]); + default = null; + example = "twoFingers"; + description = '' + Configure what a two-finger tap maps to on the touchpad. + ''; + apply = v: if (v == null) then null else (v == "middleClick"); + }; + }; + + audioRt = { + enable = lib.mkEnableOption "Audio RT scheduling and CPU isolation"; + + audioCpus = lib.mkOption { + type = lib.types.str; + default = "12-15"; + description = "CPU list reserved for audio services (systemd cpuset syntax)."; + }; + + nonAudioCpus = lib.mkOption { + type = lib.types.str; + default = "0-11"; + description = "CPU list for everything else."; + }; + + cpuPartitioning = lib.mkOption { + type = lib.types.bool; + default = config.lumpiasty.audioRt.enable; + description = '' + Cgroup-based CPU partitioning via dedicated audio.slice and + restricted app/session/background slices. + ''; + }; + + rtLimits = lib.mkOption { + type = lib.types.bool; + default = config.lumpiasty.audioRt.enable; + description = '' + Raise rlimits (RTPRIO=95, MEMLOCK=infinity) for the audio group + so PipeWire's module-rt can set SCHED_FIFO 88 directly instead + of going through RTKit's priority-10 ceiling. + ''; + }; + + performanceGovernor = lib.mkOption { + type = lib.types.bool; + default = config.lumpiasty.audioRt.enable; + description = '' + Keep cpufreq governor `performance` on the audio cores so they + stay boosted regardless of measured utilization. + ''; + }; + + ananicy = lib.mkOption { + type = lib.types.bool; + default = config.lumpiasty.audioRt.enable; + description = '' + Run ananicy-cpp with a rule that pins easyeffects to nice -12 so + its non-RT DSP threads get scheduler preference under load. + ''; + }; + + optimisedBinaries = lib.mkOption { + type = lib.types.bool; + default = config.lumpiasty.audioRt.enable; + description = '' + Rebuild easyeffects and its DSP dependencies with -march=znver4 -O3 + (and LTO for cmake builds, target-cpu for rust builds). + ''; + }; + }; + }; +} diff --git a/modules/system/gaming.nix b/modules/system/gaming.nix index 5d93363..6f2a4e7 100644 --- a/modules/system/gaming.nix +++ b/modules/system/gaming.nix @@ -1,8 +1,5 @@ { config, lib, pkgs, modulesPath, ... }: { - options.lumpiasty.gaming = lib.mkEnableOption "Enable options specific to gaming computers"; - options.lumpiasty.scx = lib.mkEnableOption "Enable sched-ext"; - config = lib.mkIf config.lumpiasty.gaming { # https://github.com/NixOS/nixpkgs/blob/10e687235226880ed5e9f33f1ffa71fe60f2638a/nixos/modules/programs/steam.nix hardware.graphics = { diff --git a/modules/system/ipv6-mostly.nix b/modules/system/ipv6-mostly.nix index 9c1583f..b403c8a 100644 --- a/modules/system/ipv6-mostly.nix +++ b/modules/system/ipv6-mostly.nix @@ -6,8 +6,6 @@ # defaults, mirroring the Fedora 45 change: # https://fedoraproject.org/wiki/Changes/IPv6-Mostly_Support_In_NetworkManager { - options.lumpiasty.ipv6Mostly = lib.mkEnableOption "Enable IPv6-mostly (RFC 8925 + CLAT/464XLAT) support in NetworkManager"; - config = lib.mkIf config.lumpiasty.ipv6Mostly { # Use the patched NM build with CLAT support, without replacing pkgs.networkmanager # globally (which would cascade rebuilds across the entire system closure). diff --git a/modules/system/roles.nix b/modules/system/roles.nix deleted file mode 100644 index 1536845..0000000 --- a/modules/system/roles.nix +++ /dev/null @@ -1,6 +0,0 @@ -{config, lib, pkgs, modulesPath, ... }: - -{ - options.lumpiasty.pc = lib.mkEnableOption "Enable options specific to personal computers"; - options.lumpiasty.laptop = lib.mkEnableOption "Enable options specific to laptops"; -} \ No newline at end of file diff --git a/modules/system/ssh.nix b/modules/system/ssh.nix index bd39637..4ce6b4a 100644 --- a/modules/system/ssh.nix +++ b/modules/system/ssh.nix @@ -1,8 +1,6 @@ { config, lib, pkgs, modulesPath, ... }: { - options.lumpiasty.sshd = lib.mkEnableOption "Enable intel CPU"; - config = lib.mkIf config.lumpiasty.sshd { services.openssh = { enable = true; diff --git a/modules/system/users.nix b/modules/system/users.nix index d0f0a3c..4847caf 100644 --- a/modules/system/users.nix +++ b/modules/system/users.nix @@ -10,12 +10,6 @@ let mkUser = import ../../lib/mkUser.nix { inherit lib; }; in { - options.lumpiasty.users = { - user = lib.mkEnableOption "Create user \"user\""; - drugi = lib.mkEnableOption "Create user \"drugi\""; - }; - - config = { # Install system-wide docker because rootless causes issues with binfmt virtualisation.docker.enable = config.lumpiasty.pc;