on e94de40 help sign in
haskell.nix/scripts/check-closure-size.nix
29 lines 574 B history raw
1{ stdenv, writeScript, coreutils, gawk, nix
2, nix-tools
3, limitMB ? 525
4}:
6with stdenv.lib;
8writeScript "check-closure-size.sh" ''
9 #!${stdenv.shell}
11 set -euo pipefail
13 export PATH="${makeBinPath [ coreutils gawk nix ]}"
15 get_closure_size() {
16 du -scm $(nix-store -qR $1) | sort -n | tail -n25
17 }
19 nt="$(get_closure_size ${nix-tools})"
20 echo ' ${nix-tools}'
21 echo "$nt"
23 total=$(awk '$2 == "total" { print $1; }' <<< "$nt")
25 if [ $total -gt ${toString limitMB} ]; then
26 echo "Closure size exceeds limit of ${toString limitMB}MB!"
27 exit 1
28 fi
29''