Files
haskell.nix/scripts/check-closure-size.nix
Hamish Mackenzie 89f50a96dd Use pkgs.lib instead of stdenv.lib (#1031)
Fixes:

Warning: `stdenv.lib` is deprecated and will be removed in the next release. Please use `pkgs.lib` instead. For more information see https://github.com/NixOS/nixpkgs/issues/108938
2021-02-11 01:07:16 +13:00

30 lines
572 B
Nix

{ stdenv, lib, writeScript, coreutils, gawk, nix
, nix-tools
, limitMB ? 525
}:
with lib;
writeScript "check-closure-size.sh" ''
#!${stdenv.shell}
set -euo pipefail
export PATH="${makeBinPath [ coreutils gawk nix ]}"
get_closure_size() {
du -scm $(nix-store -qR $1) | sort -n | tail -n25
}
nt="$(get_closure_size ${nix-tools})"
echo ' ${nix-tools}'
echo "$nt"
total=$(awk '$2 == "total" { print $1; }' <<< "$nt")
if [ $total -gt ${toString limitMB} ]; then
echo "Closure size exceeds limit of ${toString limitMB}MB!"
exit 1
fi
''