Skip to content

Commit 4d9fdaf

Browse files
authored
Merge pull request #1007 from phip1611/nix-shell
nix: update rust-toolchain in shell
2 parents dffe588 + c26fb9e commit 4d9fdaf

File tree

6 files changed

+52
-20
lines changed

6 files changed

+52
-20
lines changed

.github/workflows/developer_productivity.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ jobs:
2525
#
2626
# It only runs if the "nix-src" output of the "changes" job is true.
2727
nix_shell_toolchain:
28-
name: "Nix toolchain: cargo xtask run works"
28+
name: "Nix toolchain: `cargo xtask run` works"
2929
needs: changes
3030
if: ${{ needs.changes.outputs.nix-src == 'true' }}
3131
runs-on: ubuntu-latest
@@ -45,6 +45,6 @@ jobs:
4545
run: nix-shell --pure --run "cargo --version"
4646
- name: Run VM tests
4747
run: |
48-
COMMAND="cargo +stable xtask run --target x86_64 --headless --ci --tpm=v1"
49-
echo "Executing in nix shell now: $COMMAND"
48+
COMMAND="cargo xtask run --target x86_64 --headless --ci --tpm=v1"
49+
echo "Executing in nix shell: $COMMAND"
5050
nix-shell --pure --run "$COMMAND"

nix/nixpkgs.nix

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
let
2+
sources = import ./sources.nix { };
3+
rust-overlay = import sources.rust-overlay;
4+
in
5+
import sources.nixpkgs { overlays = [ rust-overlay ]; }
6+

nix/rust-toolchain.nix

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
# Returns the Rust toolchain for Nix compliant to the rust-toolchain.toml file
2+
# but without rustup.
3+
4+
{
5+
# Comes from rust-overlay
6+
rust-bin
7+
}:
8+
9+
# Includes rustc, cargo, rustfmt, etc
10+
rust-bin.fromRustupToolchainFile ../rust-toolchain.toml

nix/sources.json

Lines changed: 24 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,26 @@
11
{
2-
"nixpkgs": {
3-
"branch": "nixos-23.05",
4-
"description": "Nix Packages collection",
5-
"homepage": null,
6-
"owner": "NixOS",
7-
"repo": "nixpkgs",
8-
"rev": "6b0edc9c690c1d8a729f055e0d73439045cfda55",
9-
"sha256": "1fdsnmkcz1h5wffjci29af4jrd68pzdvrhbs083niwqfd6ssm633",
10-
"type": "tarball",
11-
"url": "https://github.com/NixOS/nixpkgs/archive/6b0edc9c690c1d8a729f055e0d73439045cfda55.tar.gz",
12-
"url_template": "https://github.com/<owner>/<repo>/archive/<rev>.tar.gz"
13-
}
2+
"nixpkgs": {
3+
"branch": "nixos-23.05",
4+
"description": "Nix Packages collection",
5+
"homepage": null,
6+
"owner": "NixOS",
7+
"repo": "nixpkgs",
8+
"rev": "da4024d0ead5d7820f6bd15147d3fe2a0c0cec73",
9+
"sha256": "1y12a4hgxx2lixrcbyhycwxvrrfik1lxjnwkprar0r6173rwy9ax",
10+
"type": "tarball",
11+
"url": "https://github.com/NixOS/nixpkgs/archive/da4024d0ead5d7820f6bd15147d3fe2a0c0cec73.tar.gz",
12+
"url_template": "https://github.com/<owner>/<repo>/archive/<rev>.tar.gz"
13+
},
14+
"rust-overlay": {
15+
"branch": "master",
16+
"description": "Pure and reproducible nix overlay of binary distributed rust toolchains",
17+
"homepage": "",
18+
"owner": "oxalica",
19+
"repo": "rust-overlay",
20+
"rev": "e485313fc485700a9f1f9b8b272ddc0621d08357",
21+
"sha256": "1v1gq022rnni6mm42pxmw6c5yy9il4jb2l92irh154ax616x2rzd",
22+
"type": "tarball",
23+
"url": "https://github.com/oxalica/rust-overlay/archive/e485313fc485700a9f1f9b8b272ddc0621d08357.tar.gz",
24+
"url_template": "https://github.com/<owner>/<repo>/archive/<rev>.tar.gz"
25+
}
1426
}

rust-toolchain.toml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,5 @@
11
[toolchain]
2+
channel = "stable"
3+
# cargo, clippy, rustc, rust-docs, rustfmt, rust-std
4+
profile = "default"
25
targets = ["aarch64-unknown-uefi", "i686-unknown-uefi", "x86_64-unknown-uefi"]

shell.nix

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,11 @@
22
# "cargo xtask run|test|clippy". It uses rustup rather than a pinned rust
33
# toolchain.
44

5-
{ sources ? import ./nix/sources.nix { }
6-
, pkgs ? import sources.nixpkgs { }
7-
}:
8-
5+
let
6+
sources = import ./nix/sources.nix;
7+
pkgs = import ./nix/nixpkgs.nix;
8+
rustToolchain = pkgs.callPackage ./nix/rust-toolchain.nix {};
9+
in
910
pkgs.mkShell {
1011
nativeBuildInputs = with pkgs; [
1112
# nix related stuff (such as dependency management)
@@ -17,7 +18,7 @@ pkgs.mkShell {
1718
qemu
1819

1920
# Rust toolchain
20-
rustup
21+
rustToolchain
2122

2223
# Other
2324
yamlfmt

0 commit comments

Comments
 (0)