5 runCommand "nixpkgs-metrics"
6 { nativeBuildInputs = with pkgs.lib; map getBin [ nix time jq ];
7 # see https://github.com/NixOS/nixpkgs/issues/52436
8 #requiredSystemFeatures = [ "benchmark" ]; # dedicated `t2a` machine, by @vcunat
11 export NIX_STORE_DIR=$TMPDIR/store
12 export NIX_STATE_DIR=$TMPDIR/state
16 mkdir -p $out/nix-support
17 touch $out/nix-support/hydra-build-products
26 # Redirect stdout to /dev/null to avoid hitting "Output Limit
28 nix-env.qaDrv|nix-env.qaDrvAggressive)
29 NIX_SHOW_STATS=1 NIX_SHOW_STATS_PATH=stats-nix time -o stats-time "$@" >/dev/null ;;
31 NIX_SHOW_STATS=1 NIX_SHOW_STATS_PATH=stats-nix time -o stats-time "$@" ;;
34 cat stats-nix; echo; cat stats-time; echo
36 x=$(jq '.cpuTime' < stats-nix)
38 echo "$name.time $x s" >> $out/nix-support/hydra-metrics
40 x=$(sed -e 's/.* \([0-9]\+\)maxresident.*/\1/ ; t ; d' < stats-time)
42 echo "$name.maxresident $x KiB" >> $out/nix-support/hydra-metrics
44 # nix-2.2 also outputs .symbols.bytes but that wasn't summed originally
45 # https://github.com/NixOS/nix/pull/2392/files#diff-8e6ba8c21672fc1a5f6f606e1e101c74L1762
46 x=$(jq '[.envs,.list,.values,.sets] | map(.bytes) | add' < stats-nix)
48 echo "$name.allocations $x B" >> $out/nix-support/hydra-metrics
50 x=$(jq '.values.number' < stats-nix)
52 echo "$name.values $x" >> $out/nix-support/hydra-metrics
55 run nixos.smallContainer nix-instantiate --dry-run ${nixpkgs}/nixos/release.nix \
56 -A closures.smallContainer.x86_64-linux --show-trace
57 run nixos.kde nix-instantiate --dry-run ${nixpkgs}/nixos/release.nix \
58 -A closures.kde.x86_64-linux --show-trace
59 run nixos.lapp nix-instantiate --dry-run ${nixpkgs}/nixos/release.nix \
60 -A closures.lapp.x86_64-linux --show-trace
61 run nix-env.qa nix-env -f ${nixpkgs} -qa
62 run nix-env.qaDrv nix-env -f ${nixpkgs} -qa --drv-path --meta --xml
64 # It's slightly unclear which of the set to track: qaCount, qaCountDrv, qaCountBroken.
65 num=$(nix-env -f ${nixpkgs} -qa | wc -l)
66 echo "nix-env.qaCount $num" >> $out/nix-support/hydra-metrics
67 qaCountDrv=$(nix-env -f ${nixpkgs} -qa --drv-path | wc -l)
68 num=$((num - $qaCountDrv))
69 echo "nix-env.qaCountBroken $num" >> $out/nix-support/hydra-metrics
71 # TODO: this has been ignored for some time
72 # GC Warning: Bad initial heap size 128k - ignoring it.
73 #export GC_INITIAL_HEAP_SIZE=128k
74 run nix-env.qaAggressive nix-env -f ${nixpkgs} -qa
75 run nix-env.qaDrvAggressive nix-env -f ${nixpkgs} -qa --drv-path --meta --xml
77 lines=$(find ${nixpkgs} -name "*.nix" -type f | xargs cat | wc -l)
78 echo "loc $lines" >> $out/nix-support/hydra-metrics