Setting sysfs parameters in NixOS

Is there a way to declaratively set parameters in /sys in NixOS? I could only find one for sysctl in the options.

Luckily for my use-case it can also be done with kernelParams but I’d like to know for the future.

1 Like

I found an older mailing list post with some options: [Nix-dev] Directly configuring sysfs or /sys (not sysctl)

A more modern / systemd alternative is (example, setting maximum battery charge level):

systemd.tmpfiles.rules = [
  "w /sys/class/power_supply/BAT0/charge_control_end_threshold - - - - 80"
];

(Found via linux - how to make sysfs changes persistent in centos 7 (systemd) - Stack Overflow)