{"id":27958408,"url":"https://github.com/determinatesystems/magic-nix-cache","last_synced_at":"2025-05-07T18:23:19.645Z","repository":{"id":177072719,"uuid":"637968831","full_name":"DeterminateSystems/magic-nix-cache","owner":"DeterminateSystems","description":"Save 30-50%+ of CI time without any effort or cost. Use Magic Nix Cache, a totally free and zero-configuration binary cache for Nix on GitHub Actions.","archived":false,"fork":false,"pushed_at":"2025-04-27T00:35:16.000Z","size":683,"stargazers_count":273,"open_issues_count":15,"forks_count":18,"subscribers_count":6,"default_branch":"main","last_synced_at":"2025-05-01T19:39:08.194Z","etag":null,"topics":["caching","continuous-integration","nix"],"latest_commit_sha":null,"homepage":"","language":"Rust","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/DeterminateSystems.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2023-05-08T19:54:31.000Z","updated_at":"2025-04-24T16:09:12.000Z","dependencies_parsed_at":"2023-12-20T06:51:26.049Z","dependency_job_id":"48e1a83c-f1b8-42af-a92c-7f028d9ffc2b","html_url":"https://github.com/DeterminateSystems/magic-nix-cache","commit_stats":null,"previous_names":["determinatesystems/magic-nix-cache"],"tags_count":9,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/DeterminateSystems%2Fmagic-nix-cache","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/DeterminateSystems%2Fmagic-nix-cache/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/DeterminateSystems%2Fmagic-nix-cache/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/DeterminateSystems%2Fmagic-nix-cache/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/DeterminateSystems","download_url":"https://codeload.github.com/DeterminateSystems/magic-nix-cache/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":252932209,"owners_count":21827249,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["caching","continuous-integration","nix"],"created_at":"2025-05-07T18:23:18.985Z","updated_at":"2025-05-07T18:23:19.632Z","avatar_url":"https://github.com/DeterminateSystems.png","language":"Rust","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Magic Nix Cache\n\n\u003e [!WARNING]\n\u003e The [Magic Nix Cache will will stop working](https://determinate.systems/posts/magic-nix-cache-free-tier-eol) on **February 1st, 2025** unless you're on [GitHub Enterprise Server](https://github.com/enterprise).\n\u003e\n\u003e You can upgrade to [FlakeHub Cache](https://flakehub.com/cache) and get **one month free** using the coupon code **`FHC`**.\n\u003e\n\u003e For more information, read [this blog post](https://determinate.systems/posts/magic-nix-cache-free-tier-eol/).\n\nSave 30-50%+ of CI time without any effort or cost.\nUse Magic Nix Cache, a totally free and zero-configuration binary cache for Nix on GitHub Actions.\n\nAdd our [GitHub Action][action] after installing Nix, in your workflow, like this:\n\n```yaml\npermissions:\n  contents: read\n  id-token: write\nsteps:\n  - uses: actions/checkout@v4\n  - uses: DeterminateSystems/nix-installer-action@main\n  - uses: DeterminateSystems/magic-nix-cache-action@main\n  - run: nix flake check\n```\n\nSee [Usage](#usage) for a detailed example.\n\n## Why use the Magic Nix Cache?\n\nMagic Nix Cache uses the GitHub Actions [built-in cache][ghacache] to share builds between Workflow runs, and has many advantages over alternatives.\n\n1. Totally free: backed by GitHub Actions' cache, there is no additional service to pay for.\n1. Zero configuration: add our action to your workflow.\n   That's it.\n   Everything built in your workflow will be cached.\n1. No secrets: Forks and pull requests benefit from the cache, too.\n1. Secure: Magic Nix Cache follows the [same semantics as the GitHub Actions cache][semantics], and malicious pull requests cannot pollute your project.\n1. Private: The cache is stored in the GitHub Actions cache, not with an additional third party.\n\n\u003e **Note:** the Magic Nix Cache doesn't offer a publicly available cache.\n\u003e This means the cache is only usable in CI.\n\u003e [Zero to Nix][z2n] has an article on binary caching if you want to [share Nix builds][z2ncache] with users outside of CI.\n\n## Usage\n\nAdd it to your Linux and macOS GitHub Actions workflows, like this:\n\n```yaml\nname: CI\n\non:\n  push:\n  pull_request:\n\njobs:\n  check:\n    runs-on: ubuntu-22.04\n    permissions:\n      contents: read\n      id-token: write\n    steps:\n      - uses: actions/checkout@v4\n      - uses: DeterminateSystems/nix-installer-action@main\n      - uses: DeterminateSystems/magic-nix-cache-action@main\n      - run: nix flake check\n```\n\nThat's it.\nEverything built in your workflow will be cached.\n\n## Usage Notes\n\nThe GitHub Actions Cache has a rate limit on reads and writes.\nOccasionally, large projects or large rebuilds may exceed those rate-limits, and you'll see evidence of that in your logs.\nThe error looks like this:\n\n```\nerror: unable to download 'http://127.0.0.1:37515/\u003c...\u003e': HTTP error 418\n       response body:\n       GitHub API error: API error (429 Too Many Requests): StructuredApiError { message: \"Request was blocked due to exceeding usage of resource 'Count' in namespace ''.\" }\n```\n\nThe caching daemon and Nix both handle this gracefully, and won't cause your CI to fail.\nWhen the rate limit is exceeded while pulling dependencies, your workflow may perform more builds than usual.\nWhen the rate limit is exceeded while uploading to the cache, the remainder of those store paths will be uploaded on the next run of the workflow.\n\n## Development\n\nThis project depends on the GitHub Actions Cache API.\nFor local development, see `gha-cache/README.md` for more details on how to obtain the required tokens.\n\n```shell\ncargo run -- -c creds.json --upstream https://cache.nixos.org\ncargo build --release --target x86_64-unknown-linux-gnu\ncargo build --release --target aarch64-unknown-linux-gnu\nnix copy --to 'http://127.0.0.1:3000' $(which bash)\nnix-store --store $PWD/test-root --extra-substituters 'http://localhost:3000' --option require-sigs false -r $(which bash)\n```\n\n## Acknowledgement\n\nMagic Nix Cache is a collaboration with [Zhaofeng Li][zhaofeng].\nZhaofeng is a major contributor to the Nix community, having authored [Attic][attic] and [Colmena][colmena].\nWe'd like to express our deep gratitude to Zhaofeng for his tremendous work on this project.\n\n## Telemetry\n\nThe goal of Magic Nix Cache is to help teams save time in CI.\nThe cache daemon collects a little bit of telemetry information to help us make that true.\n\nHere is a table of the [telemetry data we collect][telemetry]:\n\n| Field                            | Use                                                                                                              |\n| -------------------------------- | ---------------------------------------------------------------------------------------------------------------- |\n| `distinct_id`                    | An opaque string that represents your project, anonymized by sha256 hashing repository and organization details. |\n| `version`                        | The version of Magic Nix Cache.                                                                                  |\n| `is_ci`                          | Whether the Magic Nix Cache is being used in CI (i.e.: GitHub Actions).                                          |\n| `elapsed_seconds`                | How long the cache daemon was running.                                                                           |\n| `narinfos_served`                | Number of narinfos served from the cache daemon.                                                                 |\n| `narinfos_sent_upstream`         | Number of narinfo requests forwarded to the upstream cache.                                                      |\n| `narinfos_negative_cache_hits`   | Effectiveness of an internal data structure which minimizes cache requests.                                      |\n| `narinfos_negative_cache_misses` | Effectiveness of an internal data structure which minimizes cache requests.                                      |\n| `narinfos_uploaded`              | Number of new narinfo files cached during this run.                                                              |\n| `nars_served`                    | Number of nars served from the cache daemon.                                                                     |\n| `nars_sent_upstream`             | Number of nar requests forwarded to the upstream cache.                                                          |\n| `nars_uploaded`                  | Number of nars uploaded during this run.                                                                         |\n| `num_original_paths`             | Number of store paths that existed on startup.                                                                   |\n| `num_final_paths`                | Number of store paths that existed on shutdown.                                                                  |\n| `num_new_paths`                  | The difference between `num_original_paths` and `num_final_paths`.                                               |\n\nTo disable diagnostic reporting, set the diagnostics URL to an empty string by passing `--diagnostic-endpoint=\"\"`.\n\nYou can read the full privacy policy for [Determinate Systems][detsys], the creators of this tool and the [Determinate Nix Installer][installer], [here][privacy].\n\n[detsys]: https://determinate.systems/\n[action]: https://github.com/DeterminateSystems/magic-nix-cache-action/\n[installer]: https://github.com/DeterminateSystems/nix-installer/\n[ghacache]: https://docs.github.com/en/actions/using-workflows/caching-dependencies-to-speed-up-workflows\n[privacy]: https://determinate.systems/policies/privacy\n[telemetry]: https://github.com/DeterminateSystems/magic-nix-cache/blob/main/magic-nix-cache/src/telemetry.rs\n[semantics]: https://docs.github.com/en/actions/using-workflows/caching-dependencies-to-speed-up-workflows#restrictions-for-accessing-a-cache\n[z2ncache]: https://zero-to-nix.com/concepts/caching#binary-caches\n[zhaofeng]: https://github.com/zhaofengli/\n[attic]: https://github.com/zhaofengli/attic\n[colmena]: https://github.com/zhaofengli/colmena\n[z2n]: https://zero-to-nix.com\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdeterminatesystems%2Fmagic-nix-cache","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdeterminatesystems%2Fmagic-nix-cache","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdeterminatesystems%2Fmagic-nix-cache/lists"}