Merge commit '0689534b4e85d6a0b2742bbc6fcf7593914fa07f'

Rust overlay merge on 2022-06-08
main
Katharina Fey 2 years ago
commit 4d895823d3
Signed by: kookie
GPG Key ID: 90734A9E619C8A6C
  1. 140
      infra/libkookie/overlays/rust/.github/workflows/ci.yaml
  2. 28
      infra/libkookie/overlays/rust/.github/workflows/sync-channels.yaml
  3. 1
      infra/libkookie/overlays/rust/.gitignore
  4. 140
      infra/libkookie/overlays/rust/README.md
  5. 60
      infra/libkookie/overlays/rust/docs/cross_compilation.md
  6. 86
      infra/libkookie/overlays/rust/docs/reference.md
  7. 6
      infra/libkookie/overlays/rust/examples/cross-aarch64/.cargo/config
  8. 14
      infra/libkookie/overlays/rust/examples/cross-aarch64/Makefile
  9. 21
      infra/libkookie/overlays/rust/examples/cross-aarch64/shell.nix
  10. 7
      infra/libkookie/overlays/rust/examples/cross-aarch64/src/main.rs
  11. 7
      infra/libkookie/overlays/rust/examples/cross-mingw/Cargo.lock
  12. 4
      infra/libkookie/overlays/rust/examples/cross-mingw/Cargo.toml
  13. 11
      infra/libkookie/overlays/rust/examples/cross-mingw/Makefile
  14. 4
      infra/libkookie/overlays/rust/examples/cross-mingw/build.rs
  15. 19
      infra/libkookie/overlays/rust/examples/cross-mingw/shell.nix
  16. 3
      infra/libkookie/overlays/rust/examples/cross-mingw/src/main.rs
  17. 7
      infra/libkookie/overlays/rust/examples/cross-wasi/Cargo.lock
  18. 8
      infra/libkookie/overlays/rust/examples/cross-wasi/Cargo.toml
  19. 11
      infra/libkookie/overlays/rust/examples/cross-wasi/Makefile
  20. 22
      infra/libkookie/overlays/rust/examples/cross-wasi/shell.nix
  21. 3
      infra/libkookie/overlays/rust/examples/cross-wasi/src/main.rs
  22. 7
      infra/libkookie/overlays/rust/examples/hello-world/Cargo.lock
  23. 8
      infra/libkookie/overlays/rust/examples/hello-world/Cargo.toml
  24. 11
      infra/libkookie/overlays/rust/examples/hello-world/Makefile
  25. 10
      infra/libkookie/overlays/rust/examples/hello-world/shell.nix
  26. 7
      infra/libkookie/overlays/rust/examples/hello-world/src/main.rs
  27. 13
      infra/libkookie/overlays/rust/flake.lock
  28. 79
      infra/libkookie/overlays/rust/flake.nix
  29. 30
      infra/libkookie/overlays/rust/manifest.nix
  30. 1
      infra/libkookie/overlays/rust/manifests/beta/2021/2021-11-20.nix
  31. 1
      infra/libkookie/overlays/rust/manifests/beta/2021/2021-11-28.nix
  32. 1
      infra/libkookie/overlays/rust/manifests/beta/2021/2021-11-30.nix
  33. 1
      infra/libkookie/overlays/rust/manifests/beta/2021/2021-12-06.nix
  34. 1
      infra/libkookie/overlays/rust/manifests/beta/2022/2022-01-09.nix
  35. 1
      infra/libkookie/overlays/rust/manifests/beta/2022/2022-01-14.nix
  36. 1
      infra/libkookie/overlays/rust/manifests/beta/2022/2022-01-20.nix
  37. 1
      infra/libkookie/overlays/rust/manifests/beta/2022/2022-01-21.nix
  38. 1
      infra/libkookie/overlays/rust/manifests/beta/2022/2022-01-27.nix
  39. 1
      infra/libkookie/overlays/rust/manifests/beta/2022/2022-01-28.nix
  40. 1
      infra/libkookie/overlays/rust/manifests/beta/2022/2022-02-03.nix
  41. 1
      infra/libkookie/overlays/rust/manifests/beta/2022/2022-02-12.nix
  42. 1
      infra/libkookie/overlays/rust/manifests/beta/2022/2022-02-13.nix
  43. 1
      infra/libkookie/overlays/rust/manifests/beta/2022/2022-02-22.nix
  44. 1
      infra/libkookie/overlays/rust/manifests/beta/2022/2022-03-04.nix
  45. 1
      infra/libkookie/overlays/rust/manifests/beta/2022/2022-03-08.nix
  46. 1
      infra/libkookie/overlays/rust/manifests/beta/2022/2022-03-15.nix
  47. 1
      infra/libkookie/overlays/rust/manifests/beta/2022/2022-03-19.nix
  48. 1
      infra/libkookie/overlays/rust/manifests/beta/2022/2022-03-23.nix
  49. 1
      infra/libkookie/overlays/rust/manifests/beta/2022/2022-04-01.nix
  50. 1
      infra/libkookie/overlays/rust/manifests/beta/2022/2022-04-05.nix
  51. 1
      infra/libkookie/overlays/rust/manifests/beta/2022/2022-04-10.nix
  52. 1
      infra/libkookie/overlays/rust/manifests/beta/2022/2022-04-18.nix
  53. 1
      infra/libkookie/overlays/rust/manifests/beta/2022/2022-04-26.nix
  54. 1
      infra/libkookie/overlays/rust/manifests/beta/2022/2022-05-05.nix
  55. 1
      infra/libkookie/overlays/rust/manifests/beta/2022/2022-05-15.nix
  56. 1
      infra/libkookie/overlays/rust/manifests/beta/2022/2022-05-19.nix
  57. 1
      infra/libkookie/overlays/rust/manifests/beta/2022/2022-05-20.nix
  58. 1
      infra/libkookie/overlays/rust/manifests/beta/2022/2022-06-03.nix
  59. 31
      infra/libkookie/overlays/rust/manifests/beta/default.nix
  60. 1
      infra/libkookie/overlays/rust/manifests/nightly/2021/2021-11-20.nix
  61. 1
      infra/libkookie/overlays/rust/manifests/nightly/2021/2021-11-21.nix
  62. 1
      infra/libkookie/overlays/rust/manifests/nightly/2021/2021-11-22.nix
  63. 1
      infra/libkookie/overlays/rust/manifests/nightly/2021/2021-11-23.nix
  64. 1
      infra/libkookie/overlays/rust/manifests/nightly/2021/2021-11-24.nix
  65. 1
      infra/libkookie/overlays/rust/manifests/nightly/2021/2021-11-25.nix
  66. 1
      infra/libkookie/overlays/rust/manifests/nightly/2021/2021-11-26.nix
  67. 1
      infra/libkookie/overlays/rust/manifests/nightly/2021/2021-11-27.nix
  68. 1
      infra/libkookie/overlays/rust/manifests/nightly/2021/2021-11-28.nix
  69. 1
      infra/libkookie/overlays/rust/manifests/nightly/2021/2021-11-29.nix
  70. 1
      infra/libkookie/overlays/rust/manifests/nightly/2021/2021-11-30.nix
  71. 1
      infra/libkookie/overlays/rust/manifests/nightly/2021/2021-12-01.nix
  72. 1
      infra/libkookie/overlays/rust/manifests/nightly/2021/2021-12-02.nix
  73. 1
      infra/libkookie/overlays/rust/manifests/nightly/2021/2021-12-03.nix
  74. 1
      infra/libkookie/overlays/rust/manifests/nightly/2021/2021-12-04.nix
  75. 1
      infra/libkookie/overlays/rust/manifests/nightly/2021/2021-12-05.nix
  76. 1
      infra/libkookie/overlays/rust/manifests/nightly/2021/2021-12-06.nix
  77. 1
      infra/libkookie/overlays/rust/manifests/nightly/2021/2021-12-07.nix
  78. 1
      infra/libkookie/overlays/rust/manifests/nightly/2021/2021-12-08.nix
  79. 1
      infra/libkookie/overlays/rust/manifests/nightly/2021/2021-12-09.nix
  80. 1
      infra/libkookie/overlays/rust/manifests/nightly/2021/2021-12-10.nix
  81. 1
      infra/libkookie/overlays/rust/manifests/nightly/2021/2021-12-12.nix
  82. 1
      infra/libkookie/overlays/rust/manifests/nightly/2021/2021-12-13.nix
  83. 1
      infra/libkookie/overlays/rust/manifests/nightly/2021/2021-12-14.nix
  84. 1
      infra/libkookie/overlays/rust/manifests/nightly/2021/2021-12-15.nix
  85. 1
      infra/libkookie/overlays/rust/manifests/nightly/2021/2021-12-16.nix
  86. 1
      infra/libkookie/overlays/rust/manifests/nightly/2021/2021-12-17.nix
  87. 1
      infra/libkookie/overlays/rust/manifests/nightly/2021/2021-12-18.nix
  88. 1
      infra/libkookie/overlays/rust/manifests/nightly/2021/2021-12-19.nix
  89. 1
      infra/libkookie/overlays/rust/manifests/nightly/2021/2021-12-20.nix
  90. 1
      infra/libkookie/overlays/rust/manifests/nightly/2021/2021-12-21.nix
  91. 1
      infra/libkookie/overlays/rust/manifests/nightly/2021/2021-12-22.nix
  92. 1
      infra/libkookie/overlays/rust/manifests/nightly/2021/2021-12-23.nix
  93. 1
      infra/libkookie/overlays/rust/manifests/nightly/2021/2021-12-24.nix
  94. 1
      infra/libkookie/overlays/rust/manifests/nightly/2021/2021-12-25.nix
  95. 1
      infra/libkookie/overlays/rust/manifests/nightly/2021/2021-12-26.nix
  96. 1
      infra/libkookie/overlays/rust/manifests/nightly/2021/2021-12-27.nix
  97. 1
      infra/libkookie/overlays/rust/manifests/nightly/2021/2021-12-29.nix
  98. 1
      infra/libkookie/overlays/rust/manifests/nightly/2021/2021-12-30.nix
  99. 1
      infra/libkookie/overlays/rust/manifests/nightly/2021/2021-12-31.nix
  100. 1
      infra/libkookie/overlays/rust/manifests/nightly/2022/2022-01-01.nix
  101. Some files were not shown because too many files have changed in this diff Show More

@ -16,38 +16,43 @@ on:
- master - master
jobs: jobs:
check-flake: flake-check:
name: Check flake name: Flake check
if: ${{ github.event.workflow_run.conclusion != 'failure' }}
runs-on: ubuntu-latest runs-on: ubuntu-latest
steps: steps:
- name: Checkout - name: Checkout
uses: actions/checkout@v2 uses: actions/checkout@v2
with: with:
fetch-depth: 0 # Nix Flakes doesn't work on shallow clones fetch-depth: 0 # Nix Flakes doesn't work on shallow clones
- name: Install Nix (flakes, nixpkgs-unstable) - name: Install Nix (flakes, nixpkgs-unstable)
uses: cachix/install-nix-action@v12 uses: cachix/install-nix-action@v16
with: with:
install_url: https://github.com/numtide/nix-flakes-installer/releases/download/nix-2.4pre20201221_9fab14a/install install_url: https://github.com/numtide/nix-flakes-installer/releases/download/nix-2.4pre20201221_9fab14a/install
extra_nix_config: | extra_nix_config: |
experimental-features = nix-command flakes experimental-features = nix-command flakes
nix_path: nixpkgs=channel:nixpkgs-unstable nix_path: nixpkgs=channel:nixpkgs-unstable
- name: Check flake - name: Check flake
run: nix flake check -v --show-trace --no-update-lock-file run: nix flake check -v --show-trace --no-update-lock-file
check-sync-script: check-sync-script:
name: Check sync script name: Check sync script is deterministic
if: ${{ github.event.workflow_run.conclusion != 'failure' }}
runs-on: ubuntu-latest runs-on: ubuntu-latest
steps: steps:
- name: Checkout - name: Checkout
uses: actions/checkout@v2 uses: actions/checkout@v2
- name: Install python - name: Install python
uses: actions/setup-python@v2 uses: actions/setup-python@v2
with: with:
python-version: '3.8' python-version: '3.x'
- name: Install python packages - name: Install python packages
run: pip3 install -r ./scripts/requirements.txt run: pip3 install -r ./scripts/requirements.txt
- name: Clean the latest version of each channel - name: Clean the latest version of each channel
run: | run: |
for channel in stable beta nightly; do for channel in stable beta nightly; do
@ -60,12 +65,16 @@ jobs:
rm "./manifests/$channel/${version%%-*}/$version.nix" rm "./manifests/$channel/${version%%-*}/$version.nix"
fi fi
done done
- name: Re-fetch latest stable - name: Re-fetch latest stable
run: python3 ./scripts/fetch.py stable run: python3 ./scripts/fetch.py stable
- name: Re-fetch latest beta - name: Re-fetch latest beta
run: python3 ./scripts/fetch.py beta run: python3 ./scripts/fetch.py beta
- name: Re-fetch latest nightly - name: Re-fetch latest nightly
run: python3 ./scripts/fetch.py nightly run: python3 ./scripts/fetch.py nightly
- name: Check file changes - name: Check file changes
run: | run: |
short_status=$(git status --short) short_status=$(git status --short)
@ -84,63 +93,92 @@ jobs:
esac esac
done <<<"$short_status" done <<<"$short_status"
check-build: test-rust:
name: Check build Rust name: Test Rust
if: ${{ github.event.workflow_run.conclusion != 'failure' }}
strategy: strategy:
fail-fast: false fail-fast: false
matrix: matrix:
os: [ubuntu-latest, macos-latest] os: [ubuntu-latest, macos-latest]
channel: [stable, beta] rust-channel: [stable, beta, nightly]
build_pkg: [minimal, default] profile: [minimal, default]
nixpkgs-channel: [nixpkgs-unstable, nixos-21.11]
exclude:
- os: macos-latest
nixpkgs-channel: nixos-21.11
runs-on: ${{ matrix.os }} runs-on: ${{ matrix.os }}
env: env:
build_expr: (import <nixpkgs> { overlays = [ (import ./.) ]; }).rust-bin.${{ matrix.channel }}.latest.${{ matrix.build_pkg }} NIX_SHELL_CMD: nix-shell --pure --argstr channel ${{ matrix.rust-channel }} --argstr profile ${{ matrix.profile }}
steps: steps:
- name: Checkout - name: Checkout
uses: actions/checkout@v2 uses: actions/checkout@v2
- name: Get locked nixpkgs revision
id: nixpkgs_rev
run: |
rev=$(jq '.nodes.nixpkgs.locked.rev' --raw-output flake.lock)
echo "Revision: $rev"
echo "::set-output name=rev::$rev"
- name: Install Nix - name: Install Nix
uses: cachix/install-nix-action@v12 uses: cachix/install-nix-action@v16
with: with:
nix_path: nixpkgs=https://github.com/NixOS/nixpkgs/archive/${{ steps.nixpkgs_rev.outputs.rev }}.tar.gz nix_path: nixpkgs=channel:${{ matrix.nixpkgs-channel }}
- name: Instantiate derivation
id: instantiate # Workaround for https://github.com/oxalica/rust-overlay/issues/54
- name: Don't let ~/.cargo/bin mess things up
run: rm -rf ~/.cargo/bin
- name: Prepare nix-shell
run: | run: |
drv_path=$(nix-instantiate -E "$build_expr") cd examples/hello-world
echo "::set-output name=drv_path::$drv_path" $NIX_SHELL_CMD --command true
- name: Cache derivation status
id: cache-drv-status - name: Test cargo build
uses: actions/cache@v2
with:
key: drv-check-build-0-${{ steps.instantiate.outputs.drv_path }}
path: successful
- name: Build Rust
if: steps.cache-drv-status.outputs.cache-hit != 'true'
run: | run: |
nix-build -E "$build_expr" cd examples/hello-world
./result/bin/rustc --version set -o pipefail
$NIX_SHELL_CMD --command "make run" | tee out
[[ "$(< out)" == *"Hello, world!"* ]]
- name: Test cargo fmt
if: matrix.profile == 'default'
run: |
cd examples/hello-world
$NIX_SHELL_CMD --command "cargo fmt -- --check"
- name: Test cargo clippy
if: matrix.profile == 'default'
run: |
cd examples/hello-world
set -o pipefail
$NIX_SHELL_CMD --command "cargo clippy -- --cap-lints=warn" 2>&1 | tee out
[[ "$(< out)" == *"warning: this loop never actually loops"* ]]
test-cross-examples:
name: Test cross compilation examples
if: ${{ github.event.workflow_run.conclusion != 'failure' }}
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
example: [cross-aarch64, cross-wasi, cross-mingw]
steps:
- name: Checkout
uses: actions/checkout@v2
- name: Install Nix
uses: cachix/install-nix-action@v16
with:
nix_path: nixpkgs=channel:nixpkgs-unstable
# Workaround for https://github.com/oxalica/rust-overlay/issues/54
- name: Don't let ~/.cargo/bin mess things up
run: rm -rf ~/.cargo/bin
- name: Prepare nix-shell - name: Prepare nix-shell
if: steps.cache-drv-status.outputs.cache-hit != 'true'
run: nix-shell -p "$build_expr" --pure --command "exit"
- name: Check `rustc` works
if: steps.cache-drv-status.outputs.cache-hit != 'true'
run: | run: |
echo 'fn main() { println!("hello, world"); }' >./test.rs cd examples/${{ matrix.example }}
# Use nix-shell to bring propagatedBuildInputs into scope. nix-shell --pure --command true
nix-shell -p "$build_expr" --pure --command "rustc test.rs -o test"
[[ "$(./test)" == "hello, world" ]] - name: Build and run example
- name: Check `clippy` works
if: matrix.build_pkg == 'default' && steps.cache-drv-status.outputs.cache-hit != 'true'
run: | run: |
echo 'fn main() { loop { break; } }' >./test.rs cd examples/${{ matrix.example }}
nix-shell -p "$build_expr" --pure --command 'clippy-driver test.rs -W clippy::never-loop' 2>&1 | tee msg set -o pipefail
[[ ${PIPESTATUS[0]} -eq 0 && "$(cat msg)" == *"warning: this loop never actually loops"* ]] # No --pure since it requires CA cert access for crates downloading.
- name: Mark a successful build for cache nix-shell --command "make run" | tee out
if: steps.cache-drv-status.outputs.cache-hit != 'true' [[ "$(< out)" == *"Hello, world!"* ]]
run: echo "1" >./successful

@ -12,29 +12,43 @@ jobs:
sync-channels: sync-channels:
name: Sync channels and prefetch toolchains name: Sync channels and prefetch toolchains
runs-on: ubuntu-latest runs-on: ubuntu-latest
steps: steps:
- name: Checkout - name: Checkout
uses: actions/checkout@v2 uses: actions/checkout@v2
with: with:
ref: master ref: master
persist-credentials: false # otherwise, the token used is the GITHUB_TOKEN, instead of your personal token persist-credentials: false # otherwise, the token used is the GITHUB_TOKEN, instead of your personal token
- name: Install python - name: Install python
uses: actions/setup-python@v2 uses: actions/setup-python@v2
with: with:
python-version: '3.8' python-version: '3.x'
- name: Install python packages - name: Install python packages
run: pip3 install -r ./scripts/requirements.txt run: pip3 install -r ./scripts/requirements.txt
- name: Install Nix - name: Install Nix
uses: cachix/install-nix-action@v12 uses: cachix/install-nix-action@v16
with:
nix_path: nixpkgs=channel:nixpkgs-unstable
# Workaround for https://github.com/oxalica/rust-overlay/issues/54
- name: Don't let ~/.cargo/bin mess things up
run: rm -rf ~/.cargo/bin
- name: Sync stable channel - name: Sync stable channel
timeout-minutes: 5 timeout-minutes: 5
run: python3 ./scripts/fetch.py stable run: python3 ./scripts/fetch.py stable
- name: Sync beta channel - name: Sync beta channel
timeout-minutes: 5 timeout-minutes: 5
run: python3 ./scripts/fetch.py beta run: python3 ./scripts/fetch.py beta
- name: Sync nightly channel - name: Sync nightly channel
timeout-minutes: 5 timeout-minutes: 5
run: python3 ./scripts/fetch.py nightly run: python3 ./scripts/fetch.py nightly
- name: Check and commit changes - name: Check and commit changes
id: commit id: commit
continue-on-error: true continue-on-error: true
@ -43,6 +57,7 @@ jobs:
git config --local user.name "GitHub Action" git config --local user.name "GitHub Action"
git add manifests git add manifests
git commit -m "manifest: update" git commit -m "manifest: update"
- name: Validate nix files changed - name: Validate nix files changed
if: steps.commit.outcome == 'success' if: steps.commit.outcome == 'success'
run: | run: |
@ -51,6 +66,15 @@ jobs:
if [[ "${#files[*]}" -ne 0 ]]; then if [[ "${#files[*]}" -ne 0 ]]; then
nix-instantiate --parse "${files[@]}" >/dev/null nix-instantiate --parse "${files[@]}" >/dev/null
fi fi
- name: Test stable Rust
if: steps.commit.outcome == 'success'
run: |
cd examples/hello-world
set -o pipefail
nix-shell --pure --command "make run" | tee out
[[ "$(< out)" == *"Hello, world!"* ]]
- name: Push changes - name: Push changes
if: steps.commit.outcome == 'success' if: steps.commit.outcome == 'success'
uses: ad-m/github-push-action@master uses: ad-m/github-push-action@master

@ -1,3 +1,4 @@
target
result result
result-* result-*
*.tmp *.tmp

@ -1,20 +1,28 @@
# rust-overlay # rust-overlay
![CI](https://github.com/oxalica/rust-overlay/workflows/CI/badge.svg) [![CI status](https://github.com/oxalica/rust-overlay/workflows/CI/badge.svg)](https://github.com/oxalica/rust-overlay/actions/workflows/ci.yaml)
![sync-channels](https://github.com/oxalica/rust-overlay/workflows/sync-channels/badge.svg) [![sync-channels status](https://github.com/oxalica/rust-overlay/workflows/sync-channels/badge.svg)](https://github.com/oxalica/rust-overlay/actions/workflows/sync-channels.yaml)
*Pure and reproducible* overlay for binary distributed rust toolchains. *Pure and reproducible* overlay for binary distributed rust toolchains.
A compatible but better replacement for rust overlay of [mozilla/nixpkgs-mozilla][mozilla]. A compatible but better replacement for rust overlay of [nixpkgs-mozilla].
Hashes of toolchain components are pre-fetched (and compressed) in tree (`manifests` directory), Hashes of toolchain components are pre-fetched in tree, so the evaluation is *pure* and
so the evaluation is *pure* and no need to have network (but [nixpkgs-mozilla][mozilla] does). no need to have network access. It also works well with [Nix Flakes](https://nixos.wiki/wiki/Flakes).
It also works well with [Nix Flakes](https://nixos.wiki/wiki/Flakes).
- The toolchain hashes are auto-updated daily using GitHub Actions. - The toolchain hashes are auto-updated daily using GitHub Actions.
- Current oldest supported version is stable 1.29.0 and beta/nightly 2018-09-13 - Current oldest supported version is stable 1.29.0 and beta/nightly 2018-09-13
(which are randomly chosen). (which are randomly picked and may change over time).
## Use as a classic Nix overlay rust-overlay is targeting these channels and they are tested on CI.
Other channels may be supported but are not guarenteed.
- nixpkgs-unstable
- nixos-21.11 (for Linux)
For migration from [nixpkgs-mozilla], see [this section](#migration-from-nixpkgs-mozilla).
## Installation
### Classic Nix overlay
You can put the code below into your `~/.config/nixpkgs/overlays.nix`. You can put the code below into your `~/.config/nixpkgs/overlays.nix`.
```nix ```nix
@ -33,7 +41,7 @@ $ nix-channel --update
And then feel free to use it anywhere like And then feel free to use it anywhere like
`import <nixpkgs> { overlays = [ (import <rust-overlay>) ]; }` in your nix shell environment. `import <nixpkgs> { overlays = [ (import <rust-overlay>) ]; }` in your nix shell environment.
## Use with Nix Flakes ### Nix Flakes
This repository already has flake support. This repository already has flake support.
@ -50,7 +58,7 @@ $ cargo --version
cargo 1.49.0 (d00d64df9 2020-12-05) cargo 1.49.0 (d00d64df9 2020-12-05)
``` ```
### Flake example: NixOS Configuration #### Use in NixOS Configuration
Here's an example of using it in nixos configuration. Here's an example of using it in nixos configuration.
```nix ```nix
@ -58,7 +66,7 @@ Here's an example of using it in nixos configuration.
description = "My configuration"; description = "My configuration";
inputs = { inputs = {
nixpkgs.url = "github:nixos/nixpkgs/nixos-unstable"; nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable";
rust-overlay.url = "github:oxalica/rust-overlay"; rust-overlay.url = "github:oxalica/rust-overlay";
}; };
@ -79,7 +87,7 @@ Here's an example of using it in nixos configuration.
} }
``` ```
### Flake example: Using `devShell` and `nix develop` #### Use in `devShell` for `nix develop`
Running `nix develop` will create a shell with the default nightly Rust toolchain installed: Running `nix develop` will create a shell with the default nightly Rust toolchain installed:
@ -88,7 +96,7 @@ Running `nix develop` will create a shell with the default nightly Rust toolchai
description = "A devShell example"; description = "A devShell example";
inputs = { inputs = {
nixpkgs.url = "github:nixos/nixpkgs/nixos-unstable"; nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable";
rust-overlay.url = "github:oxalica/rust-overlay"; rust-overlay.url = "github:oxalica/rust-overlay";
flake-utils.url = "github:numtide/flake-utils"; flake-utils.url = "github:numtide/flake-utils";
}; };
@ -103,7 +111,7 @@ Running `nix develop` will create a shell with the default nightly Rust toolchai
in in
with pkgs; with pkgs;
{ {
devShell = mkShell { devShells.default = mkShell {
buildInputs = [ buildInputs = [
openssl openssl
pkgconfig pkgconfig
@ -123,7 +131,17 @@ Running `nix develop` will create a shell with the default nightly Rust toolchai
``` ```
## Usage Examples ### Migration from [nixpkgs-mozilla]
1. Change the channel URL to `https://github.com/oxalica/rust-overlay/archive/master.tar.gz`,
or flake URL to `github:oxalica/rust-overlay` for Nix Flakes.
2. Good to go! `latest.*`, `rustChannel*.*` and friends are made compatible with [nixpkgs-mozilla].
You don't necessary need to change anything.
3. You can also optionally change to [the `rust-bin` interface](#cheat-sheet-common-usage-of-rust-bin),
which provides more functionality like "latest nightly with specific components available" or
"from `rust-toolchain` file". It also has nix-aware cross-compilation support.
## Cheat sheet: common usage of `rust-bin`
- Latest stable or beta rust profile. - Latest stable or beta rust profile.
@ -186,8 +204,6 @@ Running `nix develop` will create a shell with the default nightly Rust toolchai
- Toolchain with specific rustc git revision. - Toolchain with specific rustc git revision.
**Warning: This may not always work (including the example below) since upstream CI periodly purges old artifacts.**
This is useful for development of rust components like [MIRI][miri], which requires a specific revision of rust. This is useful for development of rust components like [MIRI][miri], which requires a specific revision of rust.
```nix ```nix
rust-bin.fromRustcRev { rust-bin.fromRustcRev {
@ -199,94 +215,16 @@ Running `nix develop` will create a shell with the default nightly Rust toolchai
} }
``` ```
- There also an cross-compilation example in [`examples/cross-aarch64`]. *Warning: This may not always work (including the example below) since upstream CI periodically purges old artifacts.*
## Reference: All attributes provided by the overlay
```nix - There also an cross-compilation example in [`examples/cross-aarch64`].
{
rust-bin = {
# The default dist url for fetching.
# Override it if you want to use a mirror server.
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
fromRustupToolchain = { channel, components ? [], targets ? [] }: «derivation»;
# Same as `fromRustupToolchain` but read from a `rust-toolchain` file (legacy one-line string or in TOML).
fromRustupToolchainFile = rust-toolchain-file-path: «derivation»;
# Select the latest nightly toolchain which have specific components or profile available.
# This helps nightly users in case of latest nightly may not contains all components they want.
#
# `selectLatestNightlyWith (toolchain: toolchain.default)` selects the latest nightly toolchain
# with all `default` components (rustc, cargo, rustfmt, ...) available.
selectLatestNightlyWith = selector: «derivation»;
# Custom toolchain from a specific rustc git revision.
# This does almost the same thing as `rustup-toolchain-install-master`. (https://crates.io/crates/rustup-toolchain-install-master)
# Parameter `components` should be an attrset with component name as key and its SRI hash as value.
fromRustcRev = { pname ? …, rev, components, target ? … }: «derivation»;
stable = {
# The latest stable toolchain.
latest = {
# Profiles, predefined component sets.
# See: https://rust-lang.github.io/rustup/concepts/profiles.html
minimal = «derivation»; # Only `cargo`, `rustc` and `rust-std`.
default = «derivation»; # The default profile of `rustup`. Good for general use.
complete = «derivation»; # Do not use it. It almost always fails.
# Pre-aggregated package provided by upstream, the most commonly used package in `mozilla-overlay`.
# It consists of an uncertain number of components, usually more than the `default` profile of `rustup`
# but less than `complete` profile.
rust = «derivation»;
# Individial components.
rustc = «derivation»;
cargo = «derivation»;
rust-std = «derivation»;
# ... other components
};
"1.49.0" = { /* toolchain */ };
"1.48.0" = { /* toolchain */ };
# ... other versions.
};
beta = {
# The latest beta toolchain.
latest = { /* toolchain */ };
"2021-01-01" = { /* toolchain */ };
"2020-12-30" = { /* toolchain */ };
# ... other versions.
};
nightly = {
# The latest nightly toolchain.
# It is preferred to use `selectLatestNightlyWith` instead of this since
# nightly toolchain may have components (like `rustfmt` or `rls`) missing,
# making `default` profile unusable.
latest = { /* toolchain */ };
"2020-12-31" = { /* toolchain */ };
"2020-12-30" = { /* toolchain */ };
# ... other versions.
};
# ... Some internal attributes omitted.
};
# These are for compatibility with nixpkgs-mozilla and ## More documentations
# provide same toolchains as `rust-bin.*`.
latest.rustChannels = /* ... */;
rustChannelOf = /* ... */;
rustChannelOfTargets = /* ... */;
rustChannels = /* ... */;
}
```
For more details, see also the source code of `./rust-overlay.nix`. - [Reference of all public attributes](docs/reference.md)
- [Cross compilation](docs/cross_compilation.md)
[mozilla]: https://github.com/mozilla/nixpkgs-mozilla [nixpkgs-mozilla]: https://github.com/mozilla/nixpkgs-mozilla
[rust-toolchain]: https://rust-lang.github.io/rustup/overrides.html#the-toolchain-file [rust-toolchain]: https://rust-lang.github.io/rustup/overrides.html#the-toolchain-file
[rust-profiles]: https://rust-lang.github.io/rustup/concepts/profiles.html [rust-profiles]: https://rust-lang.github.io/rustup/concepts/profiles.html
[miri]: https://github.com/rust-lang/miri [miri]: https://github.com/rust-lang/miri

@ -0,0 +1,60 @@
# Cross compilation with `rust-overlay`
There are examples for cross compilation in [`example` directory](../examples).
To try examples,
1. `cd` into `example/cross-aarch64` (or other directory).
2. `nix-shell` to enter the development environment.
3. `make run` to build and run the program in an emulater.
The structure of `shell.nix` should like this,
```nix
# Import from global `<nixpkgs>`. Can also be from flake input if you like.
(import <nixpkgs> {
# Target triple in nixpkgs format, can be abbreviated.
# Some special targets, like `wasm32-wasi`, need special configurations here, check
# `examples/cross-wasi/shell.nix` for details.
crossSystem = "aarch64-linux";
# Apply `rust-overlay`.
overlays = [ (import ../..) ];
# Workaround: we need `callPackage` to enable auto package-splicing, thus we don't need to manually prefix
# everything in `nativeBuildInputs` with `buildPackages.`.
# See: https://github.com/NixOS/nixpkgs/issues/49526
}).callPackage (
{ mkShell, stdenv, rust-bin, pkg-config, openssl, qemu }:
mkShell {
# Build-time dependencies. build = host = your-machine, target = aarch64
# Typically contains,
# - Configure-related: cmake, pkg-config
# - Compiler-related: gcc, rustc, binutils
# - Code generators run at build time: yacc, bision
nativeBuildInputs = [
# `minimal` is enough for basic building and running.
# Can also be `default` to bring other components like `rustfmt`, `clippy`, and etc.
rust-bin.stable.latest.minimal
pkg-config
];
# Build-time tools which are target agnostic. build = host = target = your-machine.
# Emulaters should essentially also go `nativeBuildInputs`. But with some packaging issue,
# currently it would cause some rebuild.
# We put them here just for a workaround.
# See: https://github.com/NixOS/nixpkgs/pull/146583
depsBuildBuild = [ qemu ];
# Run-time dependencies. build = your-matchine, host = target = aarch64
# Usually are libraries to be linked.
buildInputs = [ openssl ];
# Tell cargo about the linker and an optional emulater. So they can be used in `cargo build`
# and `cargo run`.
# Environment variables are in format `CARGO_TARGET_<UPPERCASE_UNDERSCORE_RUST_TRIPLE>_LINKER`.
# They can also be set in `.cargo/config.toml` instead.
# See: https://doc.rust-lang.org/cargo/reference/config.html#target
CARGO_TARGET_AARCH64_UNKNOWN_LINUX_GNU_LINKER = "${stdenv.cc.targetPrefix}cc";
CARGO_TARGET_AARCH64_UNKNOWN_LINUX_GNU_RUNNER = "qemu-aarch64";
}) {}
```
For more details about these different kinds of dependencies,
see also [Nix Wiki - Cross Compiling](https://nixos.wiki/wiki/Cross_Compiling#How_to_specify_dependencies).

@ -0,0 +1,86 @@
# `rust-overlay` reference
All public attributes provided by the overlay are below. Fields not defined here are for internal usage.
```nix
{
rust-bin = {
# The default dist url for fetching.
# Override it if you want to use a mirror server.
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
fromRustupToolchain = { channel, components ? [], targets ? [] }: «derivation»;
# Same as `fromRustupToolchain` but read from a `rust-toolchain` file (legacy one-line string or in TOML).
fromRustupToolchainFile = rust-toolchain-file-path: «derivation»;
# Select the latest nightly toolchain which have specific components or profile available.
# This helps nightly users in case of latest nightly may not contains all components they want.
#
# `selectLatestNightlyWith (toolchain: toolchain.default)` selects the latest nightly toolchain
# with all `default` components (rustc, cargo, rustfmt, ...) available.
selectLatestNightlyWith = selector: «derivation»;
# Custom toolchain from a specific rustc git revision.
# This does almost the same thing as `rustup-toolchain-install-master`. (https://crates.io/crates/rustup-toolchain-install-master)
# Parameter `components` should be an attrset with component name as key and its SRI hash as value.
fromRustcRev = { pname ? …, rev, components, target ? … }: «derivation»;
stable = {
# The latest stable toolchain.
latest = {
# Profiles, predefined component sets.
# See: https://rust-lang.github.io/rustup/concepts/profiles.html
minimal = «derivation»; # Only `cargo`, `rustc` and `rust-std`.
default = «derivation»; # The default profile of `rustup`. Good for general use.
complete = «derivation»; # Do not use it. It almost always fails.
# Pre-aggregated package provided by upstream, the most commonly used package in `mozilla-overlay`.
# It consists of an uncertain number of components, usually more than the `default` profile of `rustup`
# but less than `complete` profile.
rust = «derivation»;
# Individial components.
rustc = «derivation»;
cargo = «derivation»;
rust-std = «derivation»;
# ... other components
};
"1.49.0" = { /* toolchain */ };
"1.48.0" = { /* toolchain */ };
# ... other versions.
};
beta = {
# The latest beta toolchain.
latest = { /* toolchain */ };
"2021-01-01" = { /* toolchain */ };
"2020-12-30" = { /* toolchain */ };
# ... other versions.
};
nightly = {
# The latest nightly toolchain.
# It is preferred to use `selectLatestNightlyWith` instead of this since
# nightly toolchain may have components (like `rustfmt` or `rls`) missing,
# making `default` profile unusable.
latest = { /* toolchain */ };
"2020-12-31" = { /* toolchain */ };
"2020-12-30" = { /* toolchain */ };
# ... other versions.
};
# ... Some internal attributes omitted.
};
# These are for compatibility with nixpkgs-mozilla and
# provide same toolchains as `rust-bin.*`.
latest.rustChannels = /* ... */;
rustChannelOf = /* ... */;
rustChannelOfTargets = /* ... */;
rustChannels = /* ... */;
}
```
For more details, see also the source code of [`rust-overlay.nix`](../rust-overlay.nix).

@ -1,6 +0,0 @@
[build]
target-dir = "target"
[target.aarch64-unknown-linux-gnu]
linker = "aarch64-unknown-linux-gnu-gcc"
runner = "qemu-aarch64"

@ -1,9 +1,11 @@
.PHONY: all test # This Makefile is expected to be run inside nix-shell.
test: all CARGO_FLAGS := --target aarch64-unknown-linux-gnu
nix-shell ./shell.nix --command \
"cargo test --target aarch64-unknown-linux-gnu"
.PHONY: all
all: Cargo.toml Cargo.lock src/main.rs all: Cargo.toml Cargo.lock src/main.rs
nix-shell ./shell.nix --command \ cargo build $(CARGO_FLAGS)
"cargo test --target aarch64-unknown-linux-gnu --no-run"
.PHONY: test
run: all
cargo run $(CARGO_FLAGS)

@ -1,22 +1,19 @@
# See docs/cross_compilation.md for details.
(import <nixpkgs> { (import <nixpkgs> {
crossSystem = "aarch64-linux"; crossSystem = "aarch64-linux";
overlays = [ (import ../..) ]; overlays = [ (import ../..) ];
}).callPackage ( }).callPackage (
{ mkShell, rust-bin, pkg-config, openssl, pkgsBuildBuild }: { mkShell, stdenv, rust-bin, pkg-config, openssl, qemu }:
mkShell { mkShell {
nativeBuildInputs = [ nativeBuildInputs = [
# Manual `buildPackages` is required here. See: https://github.com/NixOS/nixpkgs/issues/49526
# build = host = x86_64, target = aarch64
rust-bin.stable.latest.minimal rust-bin.stable.latest.minimal
pkg-config pkg-config
# build = host = target = x86_64
# qemu itself is multi-platform and `target` doesn't matter for it.
# Use build system's to avoid rebuild.
pkgsBuildBuild.qemu
];
buildInputs = [
# build = x86_64, host = target = aarch64
openssl
]; ];
depsBuildBuild = [ qemu ];
buildInputs = [ openssl ];
CARGO_TARGET_AARCH64_UNKNOWN_LINUX_GNU_LINKER = "${stdenv.cc.targetPrefix}cc";
CARGO_TARGET_AARCH64_UNKNOWN_LINUX_GNU_RUNNER = "qemu-aarch64";
}) {} }) {}

@ -1,7 +1,6 @@
#[test] fn main() {
fn test_openssl_version() { // Test linking against OpenSSL.
openssl::init(); openssl::init();
assert!(openssl::version::version().starts_with("OpenSSL ")); assert!(openssl::version::version().starts_with("OpenSSL "));
println!("Hello, world!");
} }
fn main() {}

@ -0,0 +1,7 @@
# This file is automatically @generated by Cargo.
# It is not intended for manual editing.
version = 3
[[package]]
name = "cross-mingw"
version = "0.1.0"

@ -0,0 +1,4 @@
[package]
name = "cross-mingw"
version = "0.1.0"
edition = "2018"

@ -0,0 +1,11 @@
# This Makefile is expected to be run inside nix-shell.
CARGO_FLAGS := --target x86_64-pc-windows-gnu
.PHONY: all
all: Cargo.toml Cargo.lock src/main.rs
cargo build $(CARGO_FLAGS)
.PHONY: test
run: all
cargo run $(CARGO_FLAGS)

@ -0,0 +1,4 @@
fn main() {
println!("See https://github.com/oxalica/rust-overlay/issues/59!");
}

@ -0,0 +1,19 @@
# See docs/cross_compilation.md for details.
(import <nixpkgs> {
crossSystem = {
config = "x86_64-w64-mingw32";
};
overlays = [ (import ../..) ];
}).callPackage (
{ mkShell, stdenv, rust-bin, windows, wine64 }:
mkShell {
nativeBuildInputs = [
rust-bin.stable.latest.minimal
];
depsBuildBuild = [ wine64 ];
buildInputs = [ windows.pthreads ];
CARGO_TARGET_X86_64_PC_WINDOWS_GNU_LINKER = "${stdenv.cc.targetPrefix}cc";
CARGO_TARGET_X86_64_PC_WINDOWS_GNU_RUNNER = "wine64";
}) {}

@ -0,0 +1,3 @@
fn main() {
println!("Hello, world!");
}

@ -0,0 +1,7 @@
# This file is automatically @generated by Cargo.
# It is not intended for manual editing.
version = 3
[[package]]
name = "cross-wasi"
version = "0.1.0"

@ -0,0 +1,8 @@
[package]
name = "cross-wasi"
version = "0.1.0"
edition = "2021"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
[dependencies]

@ -0,0 +1,11 @@
# This Makefile is expected to be run inside nix-shell.
CARGO_FLAGS := --target wasm32-wasi
.PHONY: all
all: Cargo.toml Cargo.lock src/main.rs
cargo build $(CARGO_FLAGS)
.PHONY: test
run: all
cargo run $(CARGO_FLAGS)

@ -0,0 +1,22 @@
# See docs/cross_compilation.md for details.
(import <nixpkgs> {
crossSystem = {
config = "wasm32-wasi";
# Nixpkgs currently only supports LLVM lld linker for wasm32-wasi.
useLLVM = true;
};
overlays = [ (import ../..) ];
}).callPackage (
# We don't need WASI C compiler from nixpkgs, so use `mkShellNoCC`.
{ mkShellNoCC, stdenv, rust-bin, wasmtime }:
mkShellNoCC {
nativeBuildInputs = [ rust-bin.stable.latest.minimal ];
depsBuildBuild = [ wasmtime ];
# This is optional for wasm32-like targets, since rustc will automatically use
# the bundled `lld` for linking.
# CARGO_TARGET_WASM32_WASI_LINKER = "${stdenv.cc.targetPrefix}cc";
CARGO_TARGET_WASM32_WASI_RUNNER = "wasmtime";
}) {}

@ -0,0 +1,3 @@
fn main() {
println!("Hello, world!");
}

@ -0,0 +1,7 @@
# This file is automatically @generated by Cargo.
# It is not intended for manual editing.
version = 3
[[package]]
name = "hello-world"
version = "0.1.0"

@ -0,0 +1,8 @@
[package]
name = "hello-world"
version = "0.1.0"
edition = "2021"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
[dependencies]

@ -0,0 +1,11 @@
# This Makefile is expected to be run inside nix-shell.
CARGO_FLAGS := -v
.PHONY: all
all: Cargo.toml Cargo.lock src/main.rs
cargo build $(CARGO_FLAGS)
.PHONY: test
run: all
cargo run $(CARGO_FLAGS)

@ -0,0 +1,10 @@
{ channel ? "stable", profile ? "default" }:
with import <nixpkgs> { overlays = [ (import ../..) ]; };
mkShell {
nativeBuildInputs = [
(if channel == "nightly" then
rust-bin.selectLatestNightlyWith (toolchain: toolchain.${profile})
else
rust-bin.${channel}.latest.${profile})
];
}

@ -0,0 +1,7 @@
fn main() {
// Trigger a clippy warning.
loop {
break;
}
println!("Hello, world!");
}

@ -2,11 +2,11 @@
"nodes": { "nodes": {
"flake-utils": { "flake-utils": {
"locked": { "locked": {
"lastModified": 1623875721, "lastModified": 1637014545,
"narHash": "sha256-A8BU7bjS5GirpAUv4QA+QnJ4CceLHkcXdRp4xITDB0s=", "narHash": "sha256-26IZAc5yzlD9FlDT54io1oqG/bBoyka+FJk5guaX4x4=",
"owner": "numtide", "owner": "numtide",
"repo": "flake-utils", "repo": "flake-utils",
"rev": "f7e004a55b120c02ecb6219596820fcd32ca8772", "rev": "bba5dcc8e0b20ab664967ad83d24d64cb64ec4f4",
"type": "github" "type": "github"
}, },
"original": { "original": {
@ -17,15 +17,16 @@
}, },
"nixpkgs": { "nixpkgs": {
"locked": { "locked": {
"lastModified": 1628186154, "lastModified": 1637453606,
"narHash": "sha256-r2d0wvywFnL9z4iptztdFMhaUIAaGzrSs7kSok0PgmE=", "narHash": "sha256-Gy6cwUswft9xqsjWxFYEnx/63/qzaFUwatcbV5GF/GQ=",
"owner": "NixOS", "owner": "NixOS",
"repo": "nixpkgs", "repo": "nixpkgs",
"rev": "06552b72346632b6943c8032e57e702ea12413bf", "rev": "8afc4e543663ca0a6a4f496262cd05233737e732",
"type": "github" "type": "github"
}, },
"original": { "original": {
"owner": "NixOS", "owner": "NixOS",
"ref": "nixpkgs-unstable",
"repo": "nixpkgs", "repo": "nixpkgs",
"type": "github" "type": "github"
} }

@ -5,12 +5,13 @@
''; '';
inputs = { inputs = {
nixpkgs.url = "github:NixOS/nixpkgs"; nixpkgs.url = "github:NixOS/nixpkgs/nixpkgs-unstable";
flake-utils.url = "github:numtide/flake-utils"; flake-utils.url = "github:numtide/flake-utils";
}; };
outputs = { self, nixpkgs, flake-utils }: let outputs = { self, nixpkgs, flake-utils }: let
inherit (nixpkgs) lib; inherit (nixpkgs.lib)
elem filter filterAttrs head isDerivation isString mapAttrs' mapAttrsToList optionalAttrs replaceStrings;
overlay = import ./.; overlay = import ./.;
@ -42,73 +43,56 @@
defaultPackage = packages.rust; defaultPackage = packages.rust;
packages = let packages = let
inherit (builtins) tryEval;
defaultPkg = comps:
if comps ? default then
if (tryEval comps.default.drvPath).success then
comps.default
else if (tryEval comps.minimal.drvPath).success then
comps.minimal
else
null
else if (tryEval comps.rust.drvPath).success then
comps.rust
else
null;
result = result =
lib.mapAttrs' (version: comps: { mapAttrs' (version: comps: {
name = "rust-${lib.replaceStrings ["."] ["-"] version}"; name = "rust-${replaceStrings ["."] ["-"] version}";
value = defaultPkg comps; value = comps.default or null;
}) pkgs.rust-bin.stable // }) pkgs.rust-bin.stable //
lib.mapAttrs' (version: comps: { mapAttrs' (version: comps: {
name = "rust-nightly-${version}"; name = "rust-nightly-${version}";
value = defaultPkg comps; value = comps.default or null;
}) pkgs.rust-bin.nightly // }) pkgs.rust-bin.nightly //
lib.mapAttrs' (version: comps: { mapAttrs' (version: comps: {
name = "rust-beta-${version}"; name = "rust-beta-${version}";
value = defaultPkg comps; value = comps.default or null;
}) pkgs.rust-bin.beta // }) pkgs.rust-bin.beta //
{ {
rust = result.rust-latest; rust = result.rust-latest;
rust-nightly = result.rust-nightly-latest; rust-nightly = result.rust-nightly-latest;
rust-beta = result.rust-beta-latest; rust-beta = result.rust-beta-latest;
}; };
in lib.filterAttrs (name: drv: drv != null) result; in filterAttrs (name: drv: drv != null) result;
checks = let checks = let
inherit (pkgs) rust-bin rustChannelOf; inherit (pkgs) rust-bin rustChannelOf;
inherit (pkgs.rust-bin) fromRustupToolchain fromRustupToolchainFile stable beta nightly; inherit (pkgs.rust-bin) fromRustupToolchain fromRustupToolchainFile stable beta nightly;
rustTarget = pkgs.rust.toRustTarget pkgs.hostPlatform; rustHostPlatform = pkgs.rust.toRustTarget pkgs.hostPlatform;
assertEq = lhs: rhs: { assertEq = lhs: rhs: {
assertion = lhs == rhs; assertion = lhs == rhs;
message = "`${lhs}` != `${rhs}`"; message = "`${lhs}` != `${rhs}`";
}; };
assertUrl = drv: url: let assertUrl = drv: url: let
srcUrl = lib.head drv.src.urls; srcUrl = head drv.src.urls;
in assertEq srcUrl url; in assertEq srcUrl url;
assertions = {
url-no-arch = assertUrl stable."1.48.0".rust-src "https://static.rust-lang.org/dist/2020-11-19/rust-src-1.48.0.tar.xz";
url-kind-nightly = assertUrl nightly."2021-01-01".rustc "https://static.rust-lang.org/dist/2021-01-01/rustc-nightly-${rustTarget}.tar.xz";
url-kind-beta = assertUrl beta."2021-01-01".rustc "https://static.rust-lang.org/dist/2021-01-01/rustc-beta-${rustTarget}.tar.xz";
# Check only tier 1 targets. # Check only tier 1 targets.
} // lib.optionalAttrs (lib.elem system [ "aarch64-linux" "x86_64-linux" ]) { assertions = optionalAttrs (elem system [ "aarch64-linux" "x86_64-linux" ]) {
url-no-arch = assertUrl stable."1.48.0".rust-src "https://static.rust-lang.org/dist/2020-11-19/rust-src-1.48.0.tar.xz";
url-kind-nightly = assertUrl nightly."2021-01-01".rustc "https://static.rust-lang.org/dist/2021-01-01/rustc-nightly-${rustHostPlatform}.tar.xz";
url-kind-beta = assertUrl beta."2021-01-01".rustc "https://static.rust-lang.org/dist/2021-01-01/rustc-beta-${rustHostPlatform}.tar.xz";
name-stable = assertEq stable."1.48.0".rustc.name "rustc-1.48.0"; name-stable = assertEq stable."1.48.0".rustc.name "rustc-1.48.0-${rustHostPlatform}";
name-beta = assertEq beta."2021-01-01".rustc.name "rustc-1.50.0-beta.2-2021-01-01"; name-beta = assertEq beta."2021-01-01".rustc.name "rustc-1.50.0-beta.2-2021-01-01-${rustHostPlatform}";
name-nightly = assertEq nightly."2021-01-01".rustc.name "rustc-1.51.0-nightly-2021-01-01"; name-nightly = assertEq nightly."2021-01-01".rustc.name "rustc-1.51.0-nightly-2021-01-01-${rustHostPlatform}";
name-stable-profile-default = assertEq stable."1.51.0".default.name "rust-default-1.51.0"; name-stable-profile-default = assertEq stable."1.51.0".default.name "rust-default-1.51.0";
name-stable-profile-minimal = assertEq stable."1.51.0".minimal.name "rust-minimal-1.51.0"; name-stable-profile-minimal = assertEq stable."1.51.0".minimal.name "rust-minimal-1.51.0";
url-kind-2 = assertUrl stable."1.48.0".cargo "https://static.rust-lang.org/dist/2020-11-19/cargo-1.48.0-${rustTarget}.tar.xz"; url-kind-2 = assertUrl stable."1.48.0".cargo "https://static.rust-lang.org/dist/2020-11-19/cargo-1.48.0-${rustHostPlatform}.tar.xz";
url-kind-0 = assertUrl stable."1.47.0".cargo "https://static.rust-lang.org/dist/2020-10-08/cargo-0.48.0-${rustTarget}.tar.xz"; url-kind-0 = assertUrl stable."1.47.0".cargo "https://static.rust-lang.org/dist/2020-10-08/cargo-0.48.0-${rustHostPlatform}.tar.xz";
url-kind-1 = assertUrl stable."1.34.2".llvm-tools-preview "https://static.rust-lang.org/dist/2019-05-14/llvm-tools-1.34.2%20(6c2484dc3%202019-05-13)-${rustTarget}.tar.xz"; url-kind-1 = assertUrl stable."1.34.2".llvm-tools-preview "https://static.rust-lang.org/dist/2019-05-14/llvm-tools-1.34.2%20(6c2484dc3%202019-05-13)-${rustHostPlatform}.tar.xz";
url-fix = assertUrl nightly."2019-01-10".rustc "https://static.rust-lang.org/dist/2019-01-10/rustc-nightly-${rustTarget}.tar.xz"; url-fix = assertUrl nightly."2019-01-10".rustc "https://static.rust-lang.org/dist/2019-01-10/rustc-nightly-${rustHostPlatform}.tar.xz";
rename-available = assertEq stable."1.48.0".rustfmt stable."1.48.0".rustfmt-preview; rename-available = assertEq stable."1.48.0".rustfmt stable."1.48.0".rustfmt-preview;
rename-unavailable = { rename-unavailable = {
@ -163,15 +147,24 @@
extensions = [ "rustfmt" "rustc-dev" ]; extensions = [ "rustfmt" "rustc-dev" ];
targets = [ "aarch64-unknown-linux-gnu" ]; targets = [ "aarch64-unknown-linux-gnu" ];
}); });
} // optionalAttrs (system == "aarch64-darwin") {
url-forward = assertUrl
nightly."2022-02-02".rust-docs
"https://static.rust-lang.org/dist/2022-02-02/rust-docs-nightly-x86_64-apple-darwin.tar.xz";
}; };
checkDrvs = lib.optionalAttrs (lib.elem system [ "aarch64-linux" "x86_64-linux" ]) { checkDrvs = optionalAttrs (elem system [ "aarch64-linux" "x86_64-linux" ]) {
latest-nightly-default = rust-bin.selectLatestNightlyWith (toolchain: toolchain.default); latest-nightly-default = rust-bin.selectLatestNightlyWith (toolchain: toolchain.default);
} // optionalAttrs (system == "aarch64-darwin") {
aarch64-darwin-use-x86-docs = rust-bin.stable."1.51.0".default.override {
targets = [ "x86_64-apple-darwin" ];
targetExtensions = [ "rust-docs" ];
};
}; };
failedAssertions = failedAssertions =
lib.filter (msg: msg != null) ( filter (msg: msg != null) (
lib.mapAttrsToList mapAttrsToList
(name: { assertion, message }: if assertion (name: { assertion, message }: if assertion
then null then null
else "Assertion `${name}` failed: ${message}\n") else "Assertion `${name}` failed: ${message}\n")

@ -1,7 +1,10 @@
final: prev: final: prev:
with (prev.lib);
with builtins;
let let
inherit (builtins) match isString toString;
inherit (final.lib)
attrNames concatMap elemAt filter hasAttr mapAttrs mapAttrs' removeSuffix;
targets = import ./manifests/targets.nix // { _ = "*"; }; targets = import ./manifests/targets.nix // { _ = "*"; };
renamesList = import ./manifests/renames.nix; renamesList = import ./manifests/renames.nix;
profilesList = import ./manifests/profiles.nix; profilesList = import ./manifests/profiles.nix;
@ -52,7 +55,7 @@ let
}@manifest: rec { }@manifest: rec {
# Version used for derivation. # Version used for derivation.
version = if builtins.match ".*(nightly|beta).*" v != null version = if match ".*(nightly|beta).*" v != null
then "${v}-${d}" # 1.51.0-nightly-2021-01-01, 1.52.0-beta.2-2021-03-27 then "${v}-${d}" # 1.51.0-nightly-2021-01-01, 1.52.0-beta.2-2021-03-27
else v; # 1.51.0 else v; # 1.51.0
@ -64,8 +67,8 @@ let
# We use rustc version for all components to reduce manifest size. # We use rustc version for all components to reduce manifest size.
# This version is just used for component derivation name. # This version is just used for component derivation name.
version = "${v} (000000000 ${d})"; # "<version> (<commit-hash> yyyy-mm-dd)" version = "${v} (000000000 ${d})"; # "<version> (<commit-hash> yyyy-mm-dd)"
target = target = let
mapAttrs' (targetIdx: hash: let results = mapAttrs' (targetIdx: hash: let
target = targets.${targetIdx}; target = targets.${targetIdx};
pkgNameStripped = removeSuffix "-preview" pkgName; pkgNameStripped = removeSuffix "-preview" pkgName;
targetTail = if targetIdx == "_" then "" else "-" + target; targetTail = if targetIdx == "_" then "" else "-" + target;
@ -75,11 +78,20 @@ let
else channel; # Otherwise, for beta/nightly channel, default to be "beta"/"nightly". else channel; # Otherwise, for beta/nightly channel, default to be "beta"/"nightly".
in { in {
name = target; name = target;
value = { value =
xz_url = "${distRoot}/${date}/${pkgNameStripped}-${urlVersion}${targetTail}.tar.xz"; # Normally, hash is just the hash.
xz_hash = hash; if isString hash then
} // (if pkgName == "rust" then rustPkgExtra pkg target else {}); {
xz_url = "${distRoot}/${date}/${pkgNameStripped}-${urlVersion}${targetTail}.tar.xz";
xz_hash = hash;
} // (if pkgName == "rust" then rustPkgExtra pkg target else {})
# But hash can be an integer to forward to another URL.
# This occurs in aarch64-apple-darwin rust-docs on 2022-02-02.
else
results.${targets."_${toString hash}"};
}) (removeAttrs hashes ["u"]); }) (removeAttrs hashes ["u"]);
in
results;
}) (removeAttrs manifest ["v" "d" "r" "p"]); }) (removeAttrs manifest ["v" "d" "r" "p"]);
profiles = if p == null profiles = if p == null

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

@ -183,5 +183,34 @@
"2021-10-19" = import ./2021/2021-10-19.nix; "2021-10-19" = import ./2021/2021-10-19.nix;
"2021-10-22" = import ./2021/2021-10-22.nix; "2021-10-22" = import ./2021/2021-10-22.nix;
"2021-11-02" = import ./2021/2021-11-02.nix; "2021-11-02" = import ./2021/2021-11-02.nix;
latest = "2021-11-02"; "2021-11-20" = import ./2021/2021-11-20.nix;
"2021-11-28" = import ./2021/2021-11-28.nix;
"2021-11-30" = import ./2021/2021-11-30.nix;
"2021-12-06" = import ./2021/2021-12-06.nix;
"2022-01-09" = import ./2022/2022-01-09.nix;
"2022-01-14" = import ./2022/2022-01-14.nix;
"2022-01-20" = import ./2022/2022-01-20.nix;
"2022-01-21" = import ./2022/2022-01-21.nix;
"2022-01-27" = import ./2022/2022-01-27.nix;
"2022-01-28" = import ./2022/2022-01-28.nix;
"2022-02-03" = import ./2022/2022-02-03.nix;
"2022-02-12" = import ./2022/2022-02-12.nix;
"2022-02-13" = import ./2022/2022-02-13.nix;
"2022-02-22" = import ./2022/2022-02-22.nix;
"2022-03-04" = import ./2022/2022-03-04.nix;
"2022-03-08" = import ./2022/2022-03-08.nix;
"2022-03-15" = import ./2022/2022-03-15.nix;
"2022-03-19" = import ./2022/2022-03-19.nix;
"2022-03-23" = import ./2022/2022-03-23.nix;
"2022-04-01" = import ./2022/2022-04-01.nix;
"2022-04-05" = import ./2022/2022-04-05.nix;
"2022-04-10" = import ./2022/2022-04-10.nix;
"2022-04-18" = import ./2022/2022-04-18.nix;
"2022-04-26" = import ./2022/2022-04-26.nix;
"2022-05-05" = import ./2022/2022-05-05.nix;
"2022-05-15" = import ./2022/2022-05-15.nix;
"2022-05-19" = import ./2022/2022-05-19.nix;
"2022-05-20" = import ./2022/2022-05-20.nix;
"2022-06-03" = import ./2022/2022-06-03.nix;
latest = "2022-06-03";
} }

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

Some files were not shown because too many files have changed in this diff Show More

Loading…
Cancel
Save