Project import generated by Copybara.

GitOrigin-RevId: 34ad166a830d3ac1541dcce571c52231f2f0865a
This commit is contained in:
Default email 2020-11-02 21:18:15 -05:00
parent b2384d844d
commit fec59b0297

View file

@ -80,15 +80,6 @@ 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 { priority = mkOption {
default = 5; default = 5;
type = types.int; type = types.int;
@ -155,12 +146,7 @@ in
# Calculate memory to use for zram # Calculate memory to use for zram
mem=$(${pkgs.gawk}/bin/awk '/MemTotal: / { mem=$(${pkgs.gawk}/bin/awk '/MemTotal: / {
value=int($2*${toString cfg.memoryPercent}/100.0/${toString devicesCount}*1024); print 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) }' /proc/meminfo)
${pkgs.utillinux}/sbin/zramctl --size $mem --algorithm ${cfg.algorithm} /dev/${dev} ${pkgs.utillinux}/sbin/zramctl --size $mem --algorithm ${cfg.algorithm} /dev/${dev}