{ writeShellApplication, nix_2_3, gawk }:

writeShellApplication {
  name = "nixos-size";
  runtimeInputs = [ nix_2_3 gawk ];
  text = ''
    test -e /run/booted-system || exit 0

    combined_path="$(nix-build ${./combined.nix} --no-out-link --arg builder ${./combined-builder.sh})"

    echo "nixos_closure_size{type=\"booted-system\"} $(nix path-info -S /run/booted-system | awk '{ print $2 }')"
    echo "nixos_closure_size{type=\"current-system\"} $(nix path-info -S /run/current-system | awk '{ print $2 }')"
    echo "nixos_closure_size{type=\"combined\"} $(nix path-info -S "$combined_path" | awk '{ print $2 }')"
  '';
}