diff --git a/hosts/gaming/default.nix b/hosts/gaming/default.nix index b7087d0..a0b644b 100644 --- a/hosts/gaming/default.nix +++ b/hosts/gaming/default.nix @@ -6,10 +6,10 @@ ../../modules/japanese.nix ../../modules/gc.nix ../../modules/steam.nix + ../../modules/guitar.nix ]; networking.hostName = "gaming"; - boot.kernelPackages = pkgs.linuxPackages_zen; services.displayManager.gdm.enable = true; services.desktopManager.gnome.enable = true; diff --git a/modules/guitar.nix b/modules/guitar.nix new file mode 100644 index 0000000..34699d2 --- /dev/null +++ b/modules/guitar.nix @@ -0,0 +1,55 @@ +{ pkgs, config, ... }: +{ + # PipeWire with JACK support + services.pipewire = { + enable = true; + alsa.enable = true; + pulse.enable = true; + jack.enable = true; + wireplumber.enable = true; + + # Low-latency: ~5ms at 48kHz + extraConfig.pipewire."92-low-latency" = { + "context.properties" = { + "default.clock.rate" = 48000; + "default.clock.quantum" = 128; + "default.clock.min-quantum" = 64; + "default.clock.max-quantum" = 512; + }; + }; + + extraConfig.pipewire-pulse."92-low-latency" = { + "pulse.properties" = { + "pulse.min.req" = "64/48000"; + "pulse.default.req" = "64/48000"; + "pulse.max.req" = "128/48000"; + }; + }; + }; + + # Real-time scheduling + security.rtkit.enable = true; + security.pam.loginLimits = [ + { domain = "@audio"; item = "memlock"; type = "-"; value = "unlimited"; } + { domain = "@audio"; item = "rtprio"; type = "-"; value = "95"; } + ]; + + users.users.fredrikr.extraGroups = [ "audio" ]; # <-- change yourname + + # Zen kernel = better real-time perf + boot.kernelPackages = pkgs.linuxPackages_zen; + boot.kernelParams = [ + "threadirqs" + "usbcore.autosuspend=-1" # prevent USB interface from sleeping + ]; + powerManagement.cpuFreqGovernor = "performance"; + + environment.systemPackages = with pkgs; [ + qpwgraph # visual patchbay - connect guitar in → amp → out + pavucontrol # set Scarlett to "Pro Audio" profile + guitarix # amp sim, use instead of Ableton + lsp-plugins # EQ, compressor, etc. + alsa-scarlett-gui # Scarlett hardware mixer + ]; +} +