{"id":14968090,"url":"https://github.com/determinatesystems/magic-nix-cache-action","last_synced_at":"2025-05-15T05:06:07.197Z","repository":{"id":176526307,"uuid":"657706878","full_name":"DeterminateSystems/magic-nix-cache-action","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-05-12T10:21:14.000Z","size":16086,"stargazers_count":433,"open_issues_count":19,"forks_count":20,"subscribers_count":7,"default_branch":"main","last_synced_at":"2025-05-15T05:06:01.510Z","etag":null,"topics":["caching","continuous-integration","nix"],"latest_commit_sha":null,"homepage":"","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","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-06-23T16:48:28.000Z","updated_at":"2025-05-12T10:21:17.000Z","dependencies_parsed_at":null,"dependency_job_id":"943744a7-b0d3-41ce-81e9-5fa5f70ab9e1","html_url":"https://github.com/DeterminateSystems/magic-nix-cache-action","commit_stats":{"total_commits":195,"total_committers":11,"mean_commits":"17.727272727272727","dds":0.5846153846153845,"last_synced_commit":"9ab3ce70d6d64cd6e4f4506ccb757152453ccaa6"},"previous_names":["determinatesystems/magic-nix-cache-action"],"tags_count":9,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/DeterminateSystems%2Fmagic-nix-cache-action","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/DeterminateSystems%2Fmagic-nix-cache-action/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/DeterminateSystems%2Fmagic-nix-cache-action/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/DeterminateSystems%2Fmagic-nix-cache-action/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/DeterminateSystems","download_url":"https://codeload.github.com/DeterminateSystems/magic-nix-cache-action/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":254276447,"owners_count":22043867,"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":"2024-09-24T13:39:16.705Z","updated_at":"2025-05-15T05:06:02.185Z","avatar_url":"https://github.com/DeterminateSystems.png","language":"TypeScript","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\n- uses: DeterminateSystems/magic-nix-cache-action@main\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      id-token: \"write\"\n      contents: \"read\"\n    steps:\n      - uses: actions/checkout@v4\n      - uses: DeterminateSystems/nix-installer-action@main\n      - uses: DeterminateSystems/magic-nix-cache-action@main\n      - uses: DeterminateSystems/flake-checker-action@main\n      - name: Run `nix build`\n        run: nix build .\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## Concepts\n\n### Upstream cache\n\nWhen you configure an upstream cache for the Magic Nix Cache, any store paths fetched from that source are _not_ cached because they are known to be fetchable on future workflow runs.\nThe default is `https://cache.nixos.org` but you can set a different upstream:\n\n```yaml\n- uses: DeterminateSystems/magic-nix-cache-action@main\n  with:\n    upstream-cache: https://my-binary-cache.com\n```\n\n## Action Options\n\n\u003c!--\ncat action.yml| nix run nixpkgs#yq-go -- '[[ \"Parameter\", \"Description\", \"Required\", \"Default\" ], [\"-\", \"-\", \"-\", \"-\"]] + [.inputs | to_entries | sort_by(.key) | .[] | [\"`\" + .key + \"`\", .value.description, .value.required // \"\", .value.default // \"\"]] | map(join(\" | \")) | .[] | \"| \" + . + \" |\"' -r\n--\u003e\n\n| Parameter                   | Description                                                                                                     | Required | Default                                                  |\n| --------------------------- | --------------------------------------------------------------------------------------------------------------- | -------- | -------------------------------------------------------- |\n| `diagnostic-endpoint`       | Diagnostic endpoint url where diagnostics and performance data is sent. To disable set this to an empty string. |          | https://install.determinate.systems/magic-nix-cache/perf |\n| `diff-store`                | Whether or not to diff the store before and after Magic Nix Cache runs.                                         |          | `false`                                                  |\n| `flakehub-api-server`       | The FlakeHub API server.                                                                                        |          | https://api.flakehub.com                                 |\n| `flakehub-cache-server`     | The FlakeHub binary cache server.                                                                               |          | https://cache.flakehub.com                               |\n| `flakehub-flake-name`       | The name of your flake on FlakeHub. The empty string will autodetect your FlakeHub flake.                       |          | `\"\"`                                                     |\n| `listen`                    | The host and port to listen on.                                                                                 |          | 127.0.0.1:37515                                          |\n| `source-binary`             | Run a version of the cache binary from somewhere already on disk. Conflicts with all other `source-*` options.  |          |                                                          |\n| `source-branch`             | The branch of `magic-nix-cache` to use. Conflicts with all other `source-*` options.                            |          | main                                                     |\n| `source-pr`                 | The PR of `magic-nix-cache` to use. Conflicts with all other `source-*` options.                                |          |                                                          |\n| `source-revision`           | The revision of `nix-magic-nix-cache` to use. Conflicts with all other `source-*` options.                      |          |                                                          |\n| `source-tag`                | The tag of `magic-nix-cache` to use. Conflicts with all other `source-*` options.                               |          |                                                          |\n| `source-url`                | A URL pointing to a `magic-nix-cache` binary. Overrides all other `source-*` options.                           |          |                                                          |\n| `startup-notification-port` | The port magic-nix-cache uses for daemon startup notification.                                                  |          | 41239                                                    |\n| `upstream-cache`            | Your preferred upstream cache. Store paths in this store will not be cached in GitHub Actions' cache.           |          | https://cache.nixos.org                                  |\n| `use-flakehub`              | Whether to upload build results to FlakeHub Cache (private beta).                                               |          | true                                                     |\n| `use-gha-cache`             | Whether to upload build results to the GitHub Actions cache.                                                    |          | true                                                     |\n\n[gha-cache]: https://docs.github.com/en/rest/actions/cache\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-action","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdeterminatesystems%2Fmagic-nix-cache-action","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdeterminatesystems%2Fmagic-nix-cache-action/lists"}