diff options
author | Roger Qiu <roger.qiu@polycademy.com> | 2015-12-15 23:07:08 +1100 |
---|---|---|
committer | Roger Qiu <roger.qiu@polycademy.com> | 2016-01-29 22:41:20 +1100 |
commit | 5d3b1b84f5dfc56d7bb8fd3b3fa448465b5824df (patch) | |
tree | d429348f8b5d882ea70c1e7d77effa1e1ff0c013 /nixos/modules/config/zram.nix | |
parent | a7ff459335cf4d60dd6d7f2651cad91261c6db7d (diff) |
zram: simplified totalmem calculation for zram.nix
Diffstat (limited to 'nixos/modules/config/zram.nix')
-rw-r--r-- | nixos/modules/config/zram.nix | 6 |
1 files changed, 2 insertions, 4 deletions
diff --git a/nixos/modules/config/zram.nix b/nixos/modules/config/zram.nix index 22b74847f871..019932b04e8d 100644 --- a/nixos/modules/config/zram.nix +++ b/nixos/modules/config/zram.nix @@ -98,11 +98,9 @@ in script = '' set -u set -o pipefail - - PATH=${pkgs.procps}/bin:${pkgs.gnugrep}/bin:${pkgs.gnused}/bin - + # Calculate memory to use for zram - totalmem=$(free | grep -e "^Mem:" | sed -e 's/^Mem: *//' -e 's/ *.*//') + totalmem=$(${pkgs.gnugrep}/bin/grep 'MemTotal: ' /proc/meminfo | ${pkgs.gawk}/bin/awk '{print $2}') mem=$(((totalmem * ${toString cfg.memoryPercent} / 100 / ${toString cfg.numDevices}) * 1024)) echo $mem > /sys/class/block/${dev}/disksize |