3p/nixpkgs: revert zram module

This commit is contained in:
Luke Granger-Brown 2020-11-06 05:03:19 +00:00
parent 65c2fce8a7
commit 6c89368a90

View file

@ -80,6 +80,15 @@ in
'';
};
memoryMax = mkOption {
default = null;
type = with types; nullOr int;
description = ''
Maximum total amount of memory (in bytes) that can be used by the zram
swap devices.
'';
};
priority = mkOption {
default = 5;
type = types.int;
@ -146,7 +155,12 @@ in
# Calculate memory to use for zram
mem=$(${pkgs.gawk}/bin/awk '/MemTotal: / {
print int($2*${toString cfg.memoryPercent}/100.0/${toString devicesCount}*1024)
value=int($2*${toString cfg.memoryPercent}/100.0/${toString devicesCount}*1024);
${if cfg.memoryMax != null then ''
memory_max=int(${toString cfg.memoryMax}/${toString devicesCount});
if (value > memory_max) { value = memory_max }
'' else ""}
print value
}' /proc/meminfo)
${pkgs.utillinux}/sbin/zramctl --size $mem --algorithm ${cfg.algorithm} /dev/${dev}