From 05af1a15f1046507459e6c36a2ac66d490887d6a Mon Sep 17 00:00:00 2001 From: osbm Date: Mon, 15 Sep 2025 17:03:56 +0300 Subject: [PATCH] use custom action --- .github/actions/setup-nix/action.yml | 67 ++++++++++++++++++++++++++++ .github/workflows/ci.yml | 8 ++-- 2 files changed, 72 insertions(+), 3 deletions(-) create mode 100644 .github/actions/setup-nix/action.yml diff --git a/.github/actions/setup-nix/action.yml b/.github/actions/setup-nix/action.yml new file mode 100644 index 0000000..dfd6c22 --- /dev/null +++ b/.github/actions/setup-nix/action.yml @@ -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::" \ No newline at end of file diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 6ce7662..3d7fa42 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -24,9 +24,11 @@ jobs: - name: Checkout the repository uses: actions/checkout@v2 - - name: Install nix - uses: cachix/install-nix-action@v27 - + - name: setup nix + uses: ./.github/actions/setup-nix + with: + system: ${{ matrix.system }} + - name: Login to tailscale uses: tailscale/github-action@v3.2.3 with: