From 8a529f91e4f25ccc4345db0388c447f50fd6c8f1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jalil=20David=20Salam=C3=A9=20Messina?= Date: Sat, 14 Dec 2024 23:49:23 +0100 Subject: [PATCH 1/3] wip: report package sizes Added as a comment to the current pull request --- .forgejo/workflows/size-report.yml | 10 +++++++++ .gitignore | 1 + ci-scripts/report-size.sh | 36 ++++++++++++++++++++++++++++++ 3 files changed, 47 insertions(+) create mode 100644 .forgejo/workflows/size-report.yml create mode 100755 ci-scripts/report-size.sh 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..cec3e58 --- /dev/null +++ b/ci-scripts/report-size.sh @@ -0,0 +1,36 @@ +#!/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 + tea login add --url "$GITHUB_SERVER_URL" --token "$GITHUB_TOKEN" + pr_index=$(tea pulls -f index,head -o simple | grep "$GITHUB_HEAD_REF" | head -n1 | cut -d' ' -f 1) + tea comment "$pr_index" "$( + cat <<-EOF + ### NixOS Configurations sizes + + TODO + + ### Package sizes + + $(package_size_table) + EOF + )" +else + package_size_table +fi From 6bde92bd914122e755f2ff5a922cb22bc313e0fc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jalil=20David=20Salam=C3=A9=20Messina?= Date: Sun, 15 Dec 2024 03:00:55 +0100 Subject: [PATCH 2/3] [chore] flake.lock: update inputs MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Flake lock file updates: • Updated input 'nixpkgs': 'github:NixOS/nixpkgs/a0f3e10d94359665dba45b71b4227b0aeb851f8e' (2024-12-10) → 'github:NixOS/nixpkgs/314e12ba369ccdb9b352a4db26ff419f7c49fa84' (2024-12-13) • Updated input 'nixvim': 'github:nix-community/nixvim/c181014422fa9261db06fc9b5ecbf67f42c30ec3' (2024-12-13) → 'github:nix-community/nixvim/58d2a5ac9cc4ff987e6edb77f2b55d1dec05ce50' (2024-12-15) --- flake.lock | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) 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": { From e2dadc142b37def58afff55556e31bcb6abac380 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jalil=20David=20Salam=C3=A9=20Messina?= Date: Sat, 14 Dec 2024 23:49:23 +0100 Subject: [PATCH 3/3] wip: report package sizes Added as a comment to the current pull request --- .forgejo/workflows/size-report.yml | 10 ++++++++ .gitignore | 1 + ci-scripts/report-size.sh | 40 ++++++++++++++++++++++++++++++ 3 files changed, 51 insertions(+) create mode 100644 .forgejo/workflows/size-report.yml create mode 100755 ci-scripts/report-size.sh 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