feat: reclaim additional space

Use nothing-but-nix on linux and `rm -rf` on darwin

Move nix's build-dir into /nix to workaround
https://github.com/wimpysworld/nothing-but-nix/issues/18

Co-authored-by: Matt Sturgeon <matt@sturgeon.me.uk>
This commit is contained in:
Defelo 2025-07-03 17:58:34 +02:00
commit 43db4ed61b
No known key found for this signature in database
GPG key ID: 2A05272471204DD3
3 changed files with 94 additions and 27 deletions

67
.github/actions/setup-nix/action.yml vendored Normal file
View file

@ -0,0 +1,67 @@
name: setup-nix
inputs:
system:
type: string
required: true
sandbox:
type: string
default: "true"
runs:
using: composite
steps:
- name: reclaim space (linux)
if: runner.os == 'Linux'
uses: wimpysworld/nothing-but-nix@main
with:
hatchet-protocol: rampage
- name: reclaim space (darwin)
if: runner.os == 'macOS'
shell: bash
run: |
echo "::group::disk space (before)"
sudo df -h
echo "::endgroup::"
echo "::group::disable mds"
sudo mdutil -i off -a || echo "mdutil failed"
sudo launchctl unload -w /System/Library/LaunchDaemons/com.apple.metadata.mds.plist \
|| echo "launchctl unload failed"
echo "::endgroup::"
echo "Background space expansion started. /nix will grow as space becomes available."
sudo rm -rf \
/Applications/Xcode_* \
/Library/Developer/CoreSimulator \
/Library/Frameworks \
/Users/runner/.dotnet \
/Users/runner/.rustup \
/Users/runner/Library/Android \
/Users/runner/Library/Caches \
/Users/runner/Library/Developer/CoreSimulator \
/Users/runner/hostedtoolcache &
- name: install nix
uses: cachix/install-nix-action@v31
with:
# Putting build-dir in /nix is a workaround for https://github.com/wimpysworld/nothing-but-nix/issues/18
extra_nix_config: |
build-dir = /nix/build
sandbox = ${{ inputs.sandbox }}
system = ${{ inputs.system }}
- name: create build-dir
shell: bash
run: sudo mkdir -p /nix/build
- name: post setup-nix
if: runner.os == 'macOS'
uses: srz-zumix/post-run-action@v2
with:
shell: bash -e {0}
post-run: |
echo "::group::disk space (after)"
sudo df -h
echo "::endgroup::"

View file

@ -68,21 +68,20 @@ jobs:
|| (matrix.system == 'aarch64-darwin' && 'macos-latest') }}
steps:
- name: prepare /nix
run: sudo mkdir /mnt/nix && sudo mount -m -o bind /mnt/nix /nix
if: ${{ matrix.system == 'x86_64-linux' || matrix.system == 'aarch64-linux' }}
- name: install nix
uses: cachix/install-nix-action@v31
- uses: actions/checkout@v4
with:
extra_nix_config: |
system = ${{ matrix.system }}
sandbox = ${{
(matrix.system == 'x86_64-darwin' && inputs.x86_64-darwin == 'yes_sandbox_false'
|| matrix.system == 'aarch64-darwin' && inputs.aarch64-darwin == 'yes_sandbox_false') && 'false'
|| (matrix.system == 'x86_64-darwin' && inputs.x86_64-darwin == 'yes_sandbox_relaxed'
|| matrix.system == 'aarch64-darwin' && inputs.aarch64-darwin == 'yes_sandbox_relaxed') && 'relaxed'
|| 'true' }}
sparse-checkout: .github/actions
- name: setup nix
uses: ./.github/actions/setup-nix
with:
system: ${{ matrix.system }}
sandbox: ${{
(matrix.system == 'x86_64-darwin' && inputs.x86_64-darwin == 'yes_sandbox_false'
|| matrix.system == 'aarch64-darwin' && inputs.aarch64-darwin == 'yes_sandbox_false') && 'false'
|| (matrix.system == 'x86_64-darwin' && inputs.x86_64-darwin == 'yes_sandbox_relaxed'
|| matrix.system == 'aarch64-darwin' && inputs.aarch64-darwin == 'yes_sandbox_relaxed') && 'relaxed'
|| 'true' }}
- name: nix build
run: nix build --keep-going -L ${{ inputs.packages }}

View file

@ -99,22 +99,21 @@ jobs:
fetch_cmd_aarch64-darwin: ${{ steps.report.outputs.fetch_cmd_aarch64-darwin }}
steps:
- name: prepare /nix
run: sudo mkdir /mnt/nix && sudo mount -m -o bind /mnt/nix /nix
if: ${{ matrix.system == 'x86_64-linux' || matrix.system == 'aarch64-linux' }}
- name: install nix
uses: cachix/install-nix-action@v31
- uses: actions/checkout@v4
with:
extra_nix_config: |
system = ${{ matrix.system }}
sandbox = ${{
(matrix.system == 'x86_64-darwin' && inputs.x86_64-darwin == 'yes_sandbox_false'
|| matrix.system == 'aarch64-darwin' && inputs.aarch64-darwin == 'yes_sandbox_false') && 'false'
|| (matrix.system == 'x86_64-darwin' && inputs.x86_64-darwin == 'yes_sandbox_relaxed'
|| matrix.system == 'aarch64-darwin' && inputs.aarch64-darwin == 'yes_sandbox_relaxed') && 'relaxed'
|| 'true' }}
sparse-checkout: .github/actions
- name: setup nix
uses: ./.github/actions/setup-nix
with:
system: ${{ matrix.system }}
sandbox: ${{
(matrix.system == 'x86_64-darwin' && inputs.x86_64-darwin == 'yes_sandbox_false'
|| matrix.system == 'aarch64-darwin' && inputs.aarch64-darwin == 'yes_sandbox_false') && 'false'
|| (matrix.system == 'x86_64-darwin' && inputs.x86_64-darwin == 'yes_sandbox_relaxed'
|| matrix.system == 'aarch64-darwin' && inputs.aarch64-darwin == 'yes_sandbox_relaxed') && 'relaxed'
|| 'true' }}
- name: install packages
run: |
pkgs=(coreutils nixpkgs-review jq gnused)
@ -131,6 +130,7 @@ jobs:
uses: actions/checkout@v4
with:
repository: NixOS/nixpkgs
path: nixpkgs
persist-credentials: false
- name: run nixpkgs-review ${{ inputs.extra-args }}
@ -143,6 +143,7 @@ jobs:
--build-args="-L" \
$EXTRA_ARGS \
|| true
working-directory: nixpkgs
env:
GITHUB_TOKEN: ${{ github.token }}
EXTRA_ARGS: ${{ inputs.extra-args }}