tangled
alpha
login
or
join now
pyrox.dev
/
nixpkgs
0
fork
atom
lol
0
fork
atom
overview
issues
pulls
pipelines
zram: simplified totalmem calculation for zram.nix
Roger Qiu
10 years ago
5d3b1b84
a7ff4593
+2
-4
1 changed file
expand all
collapse all
unified
split
nixos
modules
config
zram.nix
+2
-4
nixos/modules/config/zram.nix
···
98
98
script = ''
99
99
set -u
100
100
set -o pipefail
101
101
-
102
102
-
PATH=${pkgs.procps}/bin:${pkgs.gnugrep}/bin:${pkgs.gnused}/bin
103
103
-
101
101
+
104
102
# Calculate memory to use for zram
105
105
-
totalmem=$(free | grep -e "^Mem:" | sed -e 's/^Mem: *//' -e 's/ *.*//')
103
103
+
totalmem=$(${pkgs.gnugrep}/bin/grep 'MemTotal: ' /proc/meminfo | ${pkgs.gawk}/bin/awk '{print $2}')
106
104
mem=$(((totalmem * ${toString cfg.memoryPercent} / 100 / ${toString cfg.numDevices}) * 1024))
107
105
108
106
echo $mem > /sys/class/block/${dev}/disksize