From 5d3b1b84f5dfc56d7bb8fd3b3fa448465b5824df Mon Sep 17 00:00:00 2001 From: Roger Qiu Date: Tue, 15 Dec 2015 23:07:08 +1100 Subject: [PATCH] zram: simplified totalmem calculation for zram.nix --- nixos/modules/config/zram.nix | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/nixos/modules/config/zram.nix b/nixos/modules/config/zram.nix index 22b74847f87..019932b04e8 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