diff --git a/flake.lock b/flake.lock index aabf236a..eea4dcee 100644 --- a/flake.lock +++ b/flake.lock @@ -221,22 +221,6 @@ } }, "flake-compat_3": { - "flake": false, - "locked": { - "lastModified": 1767039857, - "narHash": "sha256-vNpUSpF5Nuw8xvDLj2KCwwksIbjua2LZCqhV1LNRDns=", - "owner": "NixOS", - "repo": "flake-compat", - "rev": "5edf11c44bc78a0d334f6334cdaf7d60d732daab", - "type": "github" - }, - "original": { - "owner": "NixOS", - "repo": "flake-compat", - "type": "github" - } - }, - "flake-compat_4": { "locked": { "lastModified": 1761640442, "narHash": "sha256-AtrEP6Jmdvrqiv4x2xa5mrtaIp3OEe8uBYCDZDS+hu8=", @@ -251,7 +235,7 @@ "type": "github" } }, - "flake-compat_5": { + "flake-compat_4": { "flake": false, "locked": { "lastModified": 1767039857, @@ -289,24 +273,6 @@ } }, "flake-parts_2": { - "inputs": { - "nixpkgs-lib": "nixpkgs-lib" - }, - "locked": { - "lastModified": 1790898470, - "narHash": "sha256-zTwuwezD0w3hpga6a6P8emidzAZFyWqlNeRBlpWOOl8=", - "owner": "hercules-ci", - "repo": "flake-parts", - "rev": "024633cd702b10285db5cb19b40ad48d2399ba60", - "type": "github" - }, - "original": { - "owner": "hercules-ci", - "repo": "flake-parts", - "type": "github" - } - }, - "flake-parts_3": { "inputs": { "nixpkgs-lib": [ "nixpak", @@ -345,31 +311,6 @@ "type": "github" } }, - "git-hooks": { - "inputs": { - "flake-compat": [ - "nix-gaming", - "flake-compat" - ], - "nixpkgs": [ - "nix-gaming", - "nixpkgs" - ] - }, - "locked": { - "lastModified": 1791909798, - "narHash": "sha256-VAhpCOmrun/KXimYfR8NM88bciKCui7CqHHhThSzgag=", - "owner": "cachix", - "repo": "git-hooks.nix", - "rev": "1ba1dbfe28738c9a71c266be6efa5b89e75491a9", - "type": "github" - }, - "original": { - "owner": "cachix", - "repo": "git-hooks.nix", - "type": "github" - } - }, "haumea": { "inputs": { "nixpkgs": [ @@ -607,29 +548,6 @@ "type": "github" } }, - "nix-gaming": { - "inputs": { - "flake-compat": "flake-compat_3", - "flake-parts": "flake-parts_2", - "git-hooks": "git-hooks", - "nixpkgs": [ - "nixpkgs" - ] - }, - "locked": { - "lastModified": 1793250639, - "narHash": "sha256-5ZT7ZVSqM0OFq7D7LtETkrV3TNQ6NoFsptFOI0OFK+Q=", - "owner": "fufexan", - "repo": "nix-gaming", - "rev": "46024210a12bf7203036f6e4d4d9318f96f488e7", - "type": "github" - }, - "original": { - "owner": "fufexan", - "repo": "nix-gaming", - "type": "github" - } - }, "nix-github-actions": { "inputs": { "nixpkgs": [ @@ -674,7 +592,7 @@ }, "nixos-apple-silicon": { "inputs": { - "flake-compat": "flake-compat_4", + "flake-compat": "flake-compat_3", "nixpkgs": [ "nixpkgs" ] @@ -695,7 +613,7 @@ }, "nixpak": { "inputs": { - "flake-parts": "flake-parts_3", + "flake-parts": "flake-parts_2", "hercules-ci-effects": "hercules-ci-effects", "nixpkgs": [ "nixpkgs" @@ -763,21 +681,6 @@ "type": "github" } }, - "nixpkgs-lib": { - "locked": { - "lastModified": 1790477367, - "narHash": "sha256-oujbxmVKDhci2E4EM3KyAbRUgp5/IsCoiA/LfEF7OOk=", - "owner": "nix-community", - "repo": "nixpkgs.lib", - "rev": "f7cd230690d9fc982d06129f9189b101fddcfa3b", - "type": "github" - }, - "original": { - "owner": "nix-community", - "repo": "nixpkgs.lib", - "type": "github" - } - }, "nixpkgs-master": { "locked": { "lastModified": 1793545910, @@ -956,7 +859,7 @@ }, "pre-commit-hooks": { "inputs": { - "flake-compat": "flake-compat_5", + "flake-compat": "flake-compat_4", "nixpkgs": [ "nixpkgs" ] @@ -1009,7 +912,6 @@ "my-asahi-firmware": "my-asahi-firmware", "mysecrets": "mysecrets", "nix-darwin": "nix-darwin", - "nix-gaming": "nix-gaming", "nix-x86-on-aarch64": "nix-x86-on-aarch64", "nixos-apple-silicon": "nixos-apple-silicon", "nixpak": "nixpak", diff --git a/flake.nix b/flake.nix index d643a91a..377f6181 100644 --- a/flake.nix +++ b/flake.nix @@ -137,11 +137,6 @@ # -------------- Gaming --------------------- - nix-gaming = { - url = "github:fufexan/nix-gaming"; - inputs.nixpkgs.follows = "nixpkgs"; - }; - # x86/x86_64 emulation on 16K-page ARM64 (Apple Silicon). FEX cannot run # natively with 16K pages, so this wraps FEX in a 4K-page muvm microVM and # exposes an `x86pkgs` set plus Steam/Wine launchers. Used by shoukei; see diff --git a/modules/nixos/desktop/gaming.nix b/modules/nixos/desktop/gaming.nix index 4af537fc..301b8e6b 100644 --- a/modules/nixos/desktop/gaming.nix +++ b/modules/nixos/desktop/gaming.nix @@ -1,6 +1,5 @@ { pkgs, - nix-gaming, config, lib, ... @@ -10,11 +9,6 @@ let cfg = config.modules.desktop.gaming; in { - imports = [ - nix-gaming.nixosModules.pipewireLowLatency - nix-gaming.nixosModules.platformOptimizations - ]; - options.modules.desktop = { gaming = { enable = mkEnableOption "desktop gaming support"; @@ -75,9 +69,52 @@ in capSysNice = true; }; - # see https://github.com/fufexan/nix-gaming/#pipewire-low-latency - services.pipewire.lowLatency.enable = true; - programs.steam.platformOptimizations.enable = true; + # The sysctls SteamOS ships in steamos-customizations-jupiter (file names + # below), as carried by nix-gaming's platformOptimizations module. + boot.kernel.sysctl = { + # 20-shed.conf + "kernel.sched_cfs_bandwidth_slice_us" = 3000; + # 20-net-timeout.conf: lets a game that was killed and restarted quickly + # rebind its TCP ports. + "net.ipv4.tcp_fin_timeout" = 5; + # 30-splitlock.conf: no deliberate slowdown when a game hits a split lock. + "kernel.split_lock_mitigate" = 0; + # 30-vm.conf: MAX_INT - MAPCOUNT_ELF_CORE_MARGIN, see include/linux/mm.h. + "vm.max_map_count" = 2147483642; + }; + + # Low-latency PipeWire: a 64/48000 minimum quantum plus realtime scheduling, + # as in nix-gaming's pipewireLowLatency module. + services.pipewire.extraConfig = { + pipewire."99-lowlatency" = { + "context.properties"."default.clock.min-quantum" = 64; + "context.modules" = [ + { + name = "libpipewire-module-rt"; + flags = [ + "ifexists" + "nofail" + ]; + args = { + "nice.level" = -15; + "rt.prio" = 88; + "rt.time.soft" = 200000; + "rt.time.hard" = 200000; + }; + } + ]; + }; + pipewire-pulse."99-lowlatency"."pulse.properties" = { + "server.address" = [ "unix:native" ]; + "pulse.min.req" = "64/48000"; + "pulse.min.quantum" = "64/48000"; + "pulse.min.frag" = "64/48000"; + }; + client."99-lowlatency"."stream.properties" = { + "node.latency" = "64/48000"; + "resample.quality" = 1; + }; + }; # Optimise Linux system performance on demand # https://github.com/FeralInteractive/GameMode