Add support for legacy rust-toolchain

Change to immutable URLs
wip/nixpkgs-raku
oxalica 3 years ago
parent 10d1db9e32
commit 926e333455
No known key found for this signature in database
GPG Key ID: CED392DE0C483D00
  1. 4
      README.md
  2. 8
      flake.nix
  3. 14
      rust-overlay.nix
  4. 1
      tests/rust-toolchain-legacy
  5. 0
      tests/rust-toolchain-toml

@ -87,9 +87,9 @@ Here's an example of using it in nixos configuration.
distRoot = "https://static.rust-lang.org/dist";
# Select a toolchain and aggregate components by rustup's `rust-toolchain` file format.
# See: https://rust-lang.github.io/rustup/overrides.html#the-toolchain-file
# See: https://github.com/ebroto/rustup/blob/c2db7dac6b38c99538eec472db9d23d18f918409/README.md#the-toolchain-file
fromRustupToolchain = { channel, components ? [], targets ? [] }: «derivation»;
# Same as `fromRustupToolchain` but read from a `rust-toolchain` TOML file.
# Same as `fromRustupToolchain` but read from a `rust-toolchain` file (legacy one-line string or in TOML).
fromRustupToolchainFile = rust-toolchain-file-path: «derivation»;
stable = {

@ -96,12 +96,16 @@
extensions = [ "rustfmt-preview" "rustc-dev" ];
targets = [ "wasm32-unknown-unknown" "aarch64-unknown-linux-gnu" ];
});
rustup-toolchain-customization-file = assertEq
(fromRustupToolchainFile ./tests/rust-toolchain)
rustup-toolchain-file-toml = assertEq
(fromRustupToolchainFile ./tests/rust-toolchain-toml)
(nightly."2020-07-10".rust.override {
extensions = [ "rustfmt-preview" "rustc-dev" ];
targets = [ "wasm32-unknown-unknown" "aarch64-unknown-linux-gnu" ];
});
rustup-toolchain-file-legacy = assertEq
(fromRustupToolchainFile ./tests/rust-toolchain-legacy)
nightly."2020-07-10".rust;
};
checkDrvs = {};

@ -34,13 +34,22 @@ let
else throw "Unknown channel: ${channel}";
# Select a toolchain and aggregate components by rustup's `rust-toolchain` file format.
# See: https://rust-lang.github.io/rustup/overrides.html#the-toolchain-file
# See: https://github.com/ebroto/rustup/blob/c2db7dac6b38c99538eec472db9d23d18f918409/README.md#the-toolchain-file
fromRustupToolchain = { channel, components ? [], targets ? [] }:
(toolchainFromManifest (selectManifest { inherit channel; })).rust.override {
extensions = components;
inherit targets;
};
# Same as `fromRustupToolchain` but read from a `rust-toolchain` file (legacy one-line string or in TOML).
fromRustupToolchainFile = path: let
inherit (builtins) readFile match fromTOML head;
content = readFile path;
legacy = match "([^\r\n]+)\r?\n?" content;
in if legacy != null
then fromRustupToolchain { channel = head legacy; }
else fromRustupToolchain (fromTOML content).toolchain;
getComponentsWithFixedPlatform = pkgs: pkgname: stdenv:
let
pkg = pkgs.${pkgname};
@ -315,8 +324,7 @@ in {
(super.rust-bin or {}) //
mapAttrs (channel: mapAttrs (version: toolchainFromManifest)) super.rust-bin.manifests //
{
fromRustupToolchainFile = path: fromRustupToolchain (fromTOML (readFile path)).toolchain;
inherit fromRustupToolchain;
inherit fromRustupToolchain fromRustupToolchainFile;
};
# All attributes below are for compatiblity with mozilla overlay.

@ -0,0 +1 @@
nightly-2020-07-10
Loading…
Cancel
Save