Comment the size of nix flake output derivations on a PR
|
All checks were successful
/ check (treefmt) (pull_request) Successful in 36s
/ report-size-pr (pull_request) Successful in 2s
/ prebuilt-drv (pull_request) Successful in 2s
/ report-download-check-pr (pull_request) Successful in 0s
/ report-size (push) Successful in 2s
/ report-download-check (push) Successful in 0s
|
||
|---|---|---|
| .forgejo/workflows | ||
| scripts | ||
| .editorconfig | ||
| .gitignore | ||
| action.yml | ||
| compare.jq | ||
| example-comment.png | ||
| flake.lock | ||
| flake.nix | ||
| README.md | ||
| renovate.json | ||
Nix Flake outputs size
Use nix path-info to query the size of flake outputs and produce a report.
This repost can be posted to a PR (as formatted markdown) and/or uploaded as a workflow artifact.
Requires nix, jq, curl, sed, gunzip, tar and coreutils to be in the runner's path.
Example
- name: Generate size report
uses: https://git.salame.cl/jalil/nix-flake-outputs-size@main
with: # Default values
comment-on-pr: 'true'
generate-artifact: 'false'
artifact-name: 'size-report.md'
# If you want to enable comparisons set this to true
do-comparison: 'false'
job-name: '' # required if do-comparison is true
# This is the branch that will be compared against
base-branch: ${{ github.base_ref }} # or default branch if missing
For more details see the action.yaml file.
How it looks:
Example output as text:
Flake output sizes
Definitions:
Name: the name of the package/configuration.Size: the closure size (size on disk/NAR size + all transitive dependencies).NAR Size: the size of the build output (package without the dependencies).[NAR] Size Change: the amount changed compared to the main branch.
Tips on reading this data:
- For NixOS configurations you generally care only about the
Size(closure size/size on disk).- Reduce the
Sizeby disabling unneeded services/default packages.
- Reduce the
- For Packages you care about both the
Sizeand theNAR Size.- Reduce the
NAR Sizeby reducing the size of the build outputs, e.g. don't copy unnecessary data to the $out dir, optimize binaries for size, etc. - Reduce the
Sizeby reducing the dependencies (e.g.buildInputs). - Don't worry too much about size, some dependencies are deduplicated, e.g.
glibcadds ~40MiB to theSize, but is generally shared by ~every binary on the system, so, chances are, you are already including it from somewhere else and statically linking with e.g.muslis not gonna improve things.
- Reduce the
NixOS Configurations
| Name | Size | Size Change | NAR Size | NAR Size Change |
|---|---|---|---|---|
gemini |
11Gi | -2.4Mi | 28Ki | 0 |
leo |
1.6Gi | 0 | 25Ki | 0 |
libra |
9.4Gi | -2.4Mi | 28Ki | 0 |
taurus |
7.6Gi | 0 | 34Ki | 0 |
