fan-extras.nix (1400B)
1 # modules/hosts/laptop/fan-extras.nix 2 # 3 # The part of the fan fix that `fanfix install` did imperatively on Arch and 4 # that fan-throttle-guard.nix (imported unchanged) does not carry: the 5 # "performance" power profile. power-profiles-daemon persists the choice, so 6 # this oneshot is idempotent; it runs after ppd is up and then re-applies the 7 # tmpfiles clock floor, because a profile switch rewrites per-policy boost and 8 # can lift scaling_max_freq (fanfix re-runs tmpfiles for the same reason; the 9 # stability guard would also catch it within a second). 10 { ... }: 11 { 12 flake.nixosModules.laptop-fan-extras = 13 { pkgs, lib, ... }: 14 { 15 systemd.services.fanfix-performance-profile = { 16 description = "fanfix: select the performance power profile and re-assert the clock floor"; 17 after = [ "power-profiles-daemon.service" "systemd-tmpfiles-setup.service" ]; 18 requires = [ "power-profiles-daemon.service" ]; 19 # graphical.target, not multi-user: on NixOS power-profiles-daemon is itself 20 # ordered After=multi-user.target, so multi-user here is an ordering cycle. 21 wantedBy = [ "graphical.target" ]; 22 serviceConfig = { 23 Type = "oneshot"; 24 ExecStart = "${pkgs.power-profiles-daemon}/bin/powerprofilesctl set performance"; 25 ExecStartPost = "${pkgs.systemd}/bin/systemd-tmpfiles --create --prefix=/sys/devices/system/cpu"; 26 }; 27 }; 28 } 29 ; 30 }