diff --git a/.forgejo/workflows/size-report.yml b/.forgejo/workflows/size-report.yml new file mode 100644 index 0000000..1bf2a41 --- /dev/null +++ b/.forgejo/workflows/size-report.yml @@ -0,0 +1,10 @@ +on: + pull_request: +jobs: + report-size: + runs-on: nixos + steps: + - uses: "https://git.salame.cl/actions/checkout@v4" + - run: nix --version + - name: Report Size + run: ci-scripts/report-size.sh diff --git a/.gitignore b/.gitignore index 880066b..040b2e1 100644 --- a/.gitignore +++ b/.gitignore @@ -1,4 +1,5 @@ result +result-* .direnv/ .pre-commit-config.yaml # ignore vm images diff --git a/ci-scripts/report-size.sh b/ci-scripts/report-size.sh new file mode 100755 index 0000000..778cb55 --- /dev/null +++ b/ci-scripts/report-size.sh @@ -0,0 +1,40 @@ +#!/bin/sh + +package_size_table() { + packages=$(nix flake show --json 2>/dev/null | jq --raw-output '.packages."x86_64-linux" | ".#" + keys[]') + # we want to split the words as each of them is a different installable + # shellcheck disable=SC2086 + nix build $packages + # shellcheck disable=SC2086 + table=$(nix path-info --size --closure-size --human-readable \ + $packages | + sed 's/^\(\S\+\)\(\s\+\)\(\S\+\)\(\s\+\)\(\S\+\)$/| \1\2| \3 | \4\5 |/') + + cat <<-EOF + | Nix Store Path | NAR Size | Closure Size | + |----------------|---------:|-------------:| + $table + EOF +} + +if [ "$CI" = "true" ]; then + echo "Logging in to $GITHUB_SERVER_URL with default token" + tea login add --url "$GITHUB_SERVER_URL" --token "$GITHUB_TOKEN" + echo "Retrieving PR index for $GITHUB_HEAD_REF" + pr_index=$(tea pulls -f index,head -o simple | grep "$GITHUB_HEAD_REF" | head -n1 | cut -d' ' -f 1) + echo "Retrieved index: $pr_index" + echo "Expected PR URL: $GITHUB_SERVER_URL/$GITHUB_REPOSITORY/pulls/$pr_index" + tea comment "$pr_index" "$( + cat <<-EOF + ### NixOS Configurations sizes + + TODO + + ### Package sizes + + $(package_size_table) + EOF + )" +else + package_size_table +fi diff --git a/flake.lock b/flake.lock index 2b0a22c..fbf262a 100644 --- a/flake.lock +++ b/flake.lock @@ -212,11 +212,11 @@ }, "nixpkgs": { "locked": { - "lastModified": 1733808091, - "narHash": "sha256-KWwINTQelKOoQgrXftxoqxmKFZb9pLVfnRvK270nkVk=", + "lastModified": 1734083684, + "narHash": "sha256-5fNndbndxSx5d+C/D0p/VF32xDiJCJzyOqorOYW4JEo=", "owner": "NixOS", "repo": "nixpkgs", - "rev": "a0f3e10d94359665dba45b71b4227b0aeb851f8e", + "rev": "314e12ba369ccdb9b352a4db26ff419f7c49fa84", "type": "github" }, "original": { @@ -246,11 +246,11 @@ ] }, "locked": { - "lastModified": 1734103614, - "narHash": "sha256-H5JN0fajkKZLir/GN6QHmLsR3cW+/EIOR+W/VmwHKfI=", + "lastModified": 1734223742, + "narHash": "sha256-vp3wSbCVU/4y5W+YI6H9PSix3WD7XbcIyesmB7W0ZWo=", "owner": "nix-community", "repo": "nixvim", - "rev": "c181014422fa9261db06fc9b5ecbf67f42c30ec3", + "rev": "58d2a5ac9cc4ff987e6edb77f2b55d1dec05ce50", "type": "github" }, "original": {