{"id":13647662,"url":"https://github.com/oxalica/rust-overlay","last_synced_at":"2025-05-14T19:07:46.003Z","repository":{"id":37356836,"uuid":"325973252","full_name":"oxalica/rust-overlay","owner":"oxalica","description":"Pure and reproducible nix overlay of binary distributed rust toolchains","archived":false,"fork":false,"pushed_at":"2025-05-14T02:36:37.000Z","size":41663,"stargazers_count":1124,"open_issues_count":16,"forks_count":69,"subscribers_count":9,"default_branch":"master","last_synced_at":"2025-05-14T04:00:46.362Z","etag":null,"topics":["nix","nix-flakes","rust"],"latest_commit_sha":null,"homepage":"","language":"Nix","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/oxalica.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},"funding":{"patreon":"oxalica"}},"created_at":"2021-01-01T12:18:06.000Z","updated_at":"2025-05-14T02:36:41.000Z","dependencies_parsed_at":"2024-12-05T23:02:23.483Z","dependency_job_id":"49c1e5c8-c1fb-4977-a117-b9ce3a1a904d","html_url":"https://github.com/oxalica/rust-overlay","commit_stats":{"total_commits":1614,"total_committers":23,"mean_commits":70.17391304347827,"dds":0.1201982651796778,"last_synced_commit":"a00807363a8a6cae6c3fa84ff494bf9d96333674"},"previous_names":[],"tags_count":2,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/oxalica%2Frust-overlay","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/oxalica%2Frust-overlay/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/oxalica%2Frust-overlay/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/oxalica%2Frust-overlay/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/oxalica","download_url":"https://codeload.github.com/oxalica/rust-overlay/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":254209859,"owners_count":22032897,"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":["nix","nix-flakes","rust"],"created_at":"2024-08-02T01:03:41.802Z","updated_at":"2025-05-14T19:07:44.789Z","avatar_url":"https://github.com/oxalica.png","language":"Nix","funding_links":["https://patreon.com/oxalica"],"categories":["Nix","Programming Languages","rust"],"sub_categories":["Rust"],"readme":"# rust-overlay\n\n[![CI](https://github.com/oxalica/rust-overlay/actions/workflows/ci.yaml/badge.svg)](https://github.com/oxalica/rust-overlay/actions/workflows/ci.yaml)\n[![Sync channels](https://github.com/oxalica/rust-overlay/actions/workflows/sync-channels.yaml/badge.svg)](https://github.com/oxalica/rust-overlay/actions/workflows/sync-channels.yaml)\n\n*Pure and reproducible* packaging of binary distributed rust toolchains.\nA compatible but better replacement for rust overlay of [nixpkgs-mozilla],\nwith also non-overlay and [Nix Flake][flake] interfaces (despite the project name).\n\n[flake]: https://wiki.nixos.org/wiki/Flakes\n\nFor migration from [nixpkgs-mozilla], see [this section](#migration-from-nixpkgs-mozilla).\n\nFeatures:\n\n- Hashes of toolchain components are pre-fetched in tree, so the evaluation is\n  *pure* and no need to have network access.\n\n- These hashes are auto-updated daily using GitHub Actions.\n\n- Current oldest supported stable version is 1.29.0 which are randomly picked.\n\n  Stable versions will not be purged currently.\n\n- Current oldest supported nightly version is 2024-01-01.\n\n  To prevent significant repository size bloating, our current strategy is keep\n  only nightly and beta versions not earlier than `{current_year - 1}-01-01`.\n  Earlier versions may be accessed via\n  [old snapshot tags](https://github.com/oxalica/rust-overlay/tags).\n\n- We targets nixos-unstable and supported releases of NixOS, on x86\\_64-linux.\n  They are tested on CI. Other platforms and nixpkgs channels may also work but\n  is not guaranteed.\n\nDocumentations:\n\n- [API References](docs/reference.md)\n- [Cross compilation](docs/cross_compilation.md)\n\n## Installation\n\n### Classic Nix overlay\n\nYou can put the code below into your `~/.config/nixpkgs/overlays.nix`.\n```nix\n[ (import (builtins.fetchTarball \"https://github.com/oxalica/rust-overlay/archive/master.tar.gz\")) ]\n```\nThen the provided attribute paths are available in nix command.\n```bash\n$ nix-env -iA nixpkgs.rust-bin.stable.latest.default # `nixpkgs` (or `nixos`) is your nixpkgs channel name.\n```\n\nAlternatively, you can install it into nix channels.\n```bash\n$ nix-channel --add https://github.com/oxalica/rust-overlay/archive/master.tar.gz rust-overlay\n$ nix-channel --update\n```\nAnd then feel free to use it anywhere like\n`import \u003cnixpkgs\u003e { overlays = [ (import \u003crust-overlay\u003e) ]; }` in your nix shell environment.\n\n### Nix Flakes\n\n**Warning: Only the output `overlay`/`overlays` are currently stable. Use other outputs at your own risk!**\n\nFor a quick play, just use `nix shell` to bring the latest stable rust toolchain into scope.\n(All commands below requires preview version of Nix with flake support.)\n```shell\n$ nix shell github:oxalica/rust-overlay\n$ rustc --version # This is only an example. You may get a newer version here.\nrustc 1.49.0 (e1884a8e3 2020-12-29)\n$ cargo --version\ncargo 1.49.0 (d00d64df9 2020-12-05)\n```\n\n#### Use in NixOS Configuration\n\nHere's an example of using it in nixos configuration.\n```nix\n{\n  description = \"My configuration\";\n\n  inputs = {\n    nixpkgs.url = \"github:NixOS/nixpkgs/nixos-unstable\";\n    rust-overlay = {\n      url = \"github:oxalica/rust-overlay\";\n      inputs.nixpkgs.follows = \"nixpkgs\";\n    };\n  };\n\n  outputs = { nixpkgs, rust-overlay, ... }: {\n    nixosConfigurations = {\n      hostname = nixpkgs.lib.nixosSystem {\n        system = \"x86_64-linux\";\n        modules = [\n          ./configuration.nix # Your system configuration.\n          ({ pkgs, ... }: {\n            nixpkgs.overlays = [ rust-overlay.overlays.default ];\n            environment.systemPackages = [ pkgs.rust-bin.stable.latest.default ];\n          })\n        ];\n      };\n    };\n  };\n}\n```\n\n#### Use in `devShell` for `nix develop`\n\nRunning `nix develop` will create a shell with the default beta Rust toolchain installed:\n\n```nix\n{\n  description = \"A devShell example\";\n\n  inputs = {\n    nixpkgs.url      = \"github:NixOS/nixpkgs/nixos-unstable\";\n    rust-overlay.url = \"github:oxalica/rust-overlay\";\n    flake-utils.url  = \"github:numtide/flake-utils\";\n  };\n\n  outputs = { self, nixpkgs, rust-overlay, flake-utils, ... }:\n    flake-utils.lib.eachDefaultSystem (system:\n      let\n        overlays = [ (import rust-overlay) ];\n        pkgs = import nixpkgs {\n          inherit system overlays;\n        };\n      in\n      {\n        devShells.default = with pkgs; mkShell {\n          buildInputs = [\n            openssl\n            pkg-config\n            eza\n            fd\n            rust-bin.beta.latest.default\n          ];\n\n          shellHook = ''\n            alias ls=eza\n            alias find=fd\n          '';\n        };\n      }\n    );\n}\n\n```\n\n### Migration from [nixpkgs-mozilla]\n\n1. Change the channel URL to `https://github.com/oxalica/rust-overlay/archive/master.tar.gz`,\n   or flake URL to `github:oxalica/rust-overlay` for Nix Flakes.\n2. Good to go! `latest.*`, `rustChannel*.*` and friends are made compatible with [nixpkgs-mozilla].\n   You don't necessary need to change anything.\n3. You can also optionally change to [the `rust-bin` interface](#cheat-sheet-common-usage-of-rust-bin),\n   which provides more functionality like \"latest nightly with specific components available\" or\n   \"from `rust-toolchain` file\". It also has nix-aware cross-compilation support.\n\n## Cheat sheet: common usage of `rust-bin`\n\n- Latest stable or beta rust profile.\n\n  ```nix\n  rust-bin.stable.latest.default # Stable rust, default profile. If not sure, always choose this.\n  rust-bin.beta.latest.default   # Wanna test beta compiler.\n  rust-bin.stable.latest.minimal # I don't need anything other than rustc, cargo, rust-std. Bye rustfmt, clippy, etc.\n  rust-bin.beta.latest.minimal\n  ```\n\n  It provides the same components as which installed by `rustup install`'s `default` or `minimal` profiles.\n\n  Almost always, `default` is what you want for development.\n\n  *Note: For difference between `default` and `minimal` profiles, see\n  [rustup - Profiles][rust-profiles]*\n\n- Latest stable or beta rust profile, **with extra components or target support**.\n\n  ```nix\n  rust-bin.stable.latest.default.override {\n    extensions = [ \"rust-src\" ];\n    targets = [ \"arm-unknown-linux-gnueabihf\" ];\n  }\n  ```\n\n- Latest **nightly** rust profile.\n\n  ```nix\n  rust-bin.selectLatestNightlyWith (toolchain: toolchain.default) # or `toolchain.minimal`\n  ```\n\n  *Note: Don't use `rust-bin.nightly.latest`. Your build would fail when some components missing on some days.\n  Always use `selectLatestNightlyWith` instead.*\n\n- Latest **nightly** rust profile, **with extra components or target support**.\n\n  ```nix\n  rust-bin.selectLatestNightlyWith (toolchain: toolchain.default.override {\n    extensions = [ \"rust-src\" ];\n    targets = [ \"arm-unknown-linux-gnueabihf\" ];\n  })\n  ```\n\n- A specific version of rust:\n  ```nix\n  rust-bin.stable.\"1.48.0\".default\n  rust-bin.beta.\"2021-01-01\".default\n  rust-bin.nightly.\"2020-12-31\".default\n  ```\n\n  *Note: All of them are `override`-able like examples above.*\n\n- If you already have a [`rust-toolchain` file for rustup][rust-toolchain],\n  you can simply use `fromRustupToolchainFile` to get the customized toolchain derivation.\n\n  ```nix\n  rust-bin.fromRustupToolchainFile ./rust-toolchain\n  ```\n\n- Toolchain with specific rustc git revision.\n\n  This is useful for development of rust components like [MIRI][miri], which requires a specific revision of rust.\n  ```nix\n  rust-bin.fromRustcRev {\n    rev = \"a2cd91ceb0f156cb442d75e12dc77c3d064cdde4\";\n    components = {\n      rustc = \"sha256-x+OkPVStX00AiC3GupIdGzWluIK1BnI4ZCBbg72+ZuI=\";\n      rust-src = \"sha256-13PpzzYtd769Xkb0QzHpNfYCOnLMWFolc9QyYq98z2k=\";\n    };\n  }\n  ```\n\n  *Warning: This may not always work (including the example below) since upstream CI periodically purges old artifacts.*\n\n- There also an cross-compilation example in [`examples/cross-aarch64`].\n\n## License\n\nMIT licensed.\n\n[nixpkgs-mozilla]: https://github.com/mozilla/nixpkgs-mozilla\n[rust-toolchain]: https://rust-lang.github.io/rustup/overrides.html#the-toolchain-file\n[rust-profiles]: https://rust-lang.github.io/rustup/concepts/profiles.html\n[miri]: https://github.com/rust-lang/miri\n[`examples/cross-aarch64`]: https://github.com/oxalica/rust-overlay/tree/master/examples/cross-aarch64\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Foxalica%2Frust-overlay","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Foxalica%2Frust-overlay","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Foxalica%2Frust-overlay/lists"}