### Complete GitHub Actions Workflow with Magic Nix Cache Source: https://github.com/determinatesystems/magic-nix-cache/blob/main/README.md A full example of a GitHub Actions workflow demonstrating the integration of Magic Nix Cache for CI jobs on Linux and macOS. This setup automatically caches Nix builds. ```yaml name: CI on: push: pull_request: jobs: check: runs-on: ubuntu-22.04 permissions: contents: read id-token: write steps: - uses: actions/checkout@v4 - uses: DeterminateSystems/nix-installer-action@main - uses: DeterminateSystems/magic-nix-cache-action@main - run: nix flake check ``` -------------------------------- ### Local Development: Copy Bash to Local Cache Source: https://github.com/determinatesystems/magic-nix-cache/blob/main/README.md Command to copy the 'bash' executable to a local Magic Nix Cache instance running at http://127.0.0.1:3000. This is part of the local development setup. ```shell nix copy --to 'http://127.0.0.1:3000' $(which bash) ``` -------------------------------- ### Integrate Magic Nix Cache Action in GitHub Workflow Source: https://github.com/determinatesystems/magic-nix-cache/blob/main/README.md Add this action after installing Nix in your GitHub Actions workflow to enable automatic caching of Nix builds. Ensure necessary permissions are granted. ```yaml permissions: contents: read id-token: write steps: - uses: actions/checkout@v4 - uses: DeterminateSystems/nix-installer-action@main - uses: DeterminateSystems/magic-nix-cache-action@main - run: nix flake check ``` -------------------------------- ### Handle GitHub Actions Cache Rate Limit Error Source: https://github.com/determinatesystems/magic-nix-cache/blob/main/README.md Example of an error message indicating that the GitHub Actions Cache API rate limit has been exceeded. The Magic Nix Cache and Nix handle this gracefully, preventing CI failures. ```text error: unable to download 'http://127.0.0.1:37515/<...>': HTTP error 418 response body: GitHub API error: API error (429 Too Many Requests): StructuredApiError { message: "Request was blocked due to exceeding usage of resource 'Count' in namespace ''." } ``` -------------------------------- ### Local Development: Build Release Binaries for Nix Cache Source: https://github.com/determinatesystems/magic-nix-cache/blob/main/README.md Commands to build the Magic Nix Cache release binaries for different architectures (x86_64-unknown-linux-gnu and aarch64-unknown-linux-gnu). ```shell cargo build --release --target x86_64-unknown-linux-gnu ``` ```shell cargo build --release --target aarch64-unknown-linux-gnu ``` -------------------------------- ### Local Development: Nix Store Operation with Local Cache Source: https://github.com/determinatesystems/magic-nix-cache/blob/main/README.md Command to perform a Nix store operation, referencing a local cache at http://localhost:3000 and disabling signature requirements. Used for local testing. ```shell nix-store --store $PWD/test-root --extra-substituters 'http://localhost:3000' --option require-sigs false -r $(which bash) ``` -------------------------------- ### Local Development: Run Magic Nix Cache with Upstream Cache Source: https://github.com/determinatesystems/magic-nix-cache/blob/main/README.md Command to run the Magic Nix Cache locally for development, specifying credentials and an upstream cache. This is useful for testing and debugging. ```shell cargo run -- -c creds.json --upstream https://cache.nixos.org ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.