blob: 55b12dc998fb733ba29954a4a927adc1e99fa782 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
|
#! /usr/bin/env sh
set -eu
notify-send "Running nix via the wrapper."
if [ "$_NIX_WRAPPER_FALLBACK" = "true" ]; then
# Allow skipping the size check.
nix "$@"
else
usage="$(btrfs filesystem usage /nix --raw 2>/dev/null)"
avail="$(echo "$usage" | grep 'Device size:' | cut -f 3 | sed 's/ //g')"
used="$(echo "$usage" | grep 'Used:' | cut -f 4 | head -n 1 | sed 's/ //g')"
perc="$(printf "scale=3\n%d / %d\n" "$used" "$avail" | bc)"
perc="$(printf "%d * 100\n" "$perc" | bc)"
if test -gt "$perc" "0.2"; then
nix "$@"
else
echo "Not enough space free, in nix store: Only, $perc is still free."
exit 3
fi
fi
# vim: ft=sh
|