Merge pull request #188958 from lheckemann/zram-builtin

nixos/zram: support built-in zram
This commit is contained in:
Linus Heckemann 2022-12-09 19:57:44 +01:00 committed by GitHub
commit 2ee8b6ee74
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -132,6 +132,8 @@ in
options zram num_devices=${toString cfg.numDevices} options zram num_devices=${toString cfg.numDevices}
''; '';
boot.kernelParams = ["zram.num_devices=${toString cfg.numDevices}"];
services.udev.extraRules = '' services.udev.extraRules = ''
KERNEL=="zram[0-9]*", ENV{SYSTEMD_WANTS}="zram-init-%k.service", TAG+="systemd" KERNEL=="zram[0-9]*", ENV{SYSTEMD_WANTS}="zram-init-%k.service", TAG+="systemd"
''; '';
@ -178,9 +180,9 @@ in
serviceConfig = { serviceConfig = {
Type = "oneshot"; Type = "oneshot";
RemainAfterExit = true; RemainAfterExit = true;
ExecStartPre = "${modprobe} -r zram"; ExecStartPre = "-${modprobe} -r zram";
ExecStart = "${modprobe} zram"; ExecStart = "-${modprobe} zram";
ExecStop = "${modprobe} -r zram"; ExecStop = "-${modprobe} -r zram";
}; };
restartTriggers = [ restartTriggers = [
cfg.numDevices cfg.numDevices