From b65cac29bfb89f416ab4f75a64f60f1f89a5775e Mon Sep 17 00:00:00 2001 From: Philipp Schuster Date: Tue, 14 Nov 2023 12:51:43 +0100 Subject: [PATCH 1/3] nix: get rust toolchain from rust-overlay Now, a nix-shell always has the latest rust stable version, compliant to our rust-toolchain.toml file. --- nix/nixpkgs.nix | 6 ++++++ nix/rust-toolchain.nix | 10 ++++++++++ nix/sources.json | 36 ++++++++++++++++++++++++------------ rust-toolchain.toml | 3 +++ shell.nix | 11 ++++++----- 5 files changed, 49 insertions(+), 17 deletions(-) create mode 100644 nix/nixpkgs.nix create mode 100644 nix/rust-toolchain.nix diff --git a/nix/nixpkgs.nix b/nix/nixpkgs.nix new file mode 100644 index 000000000..68090c5b8 --- /dev/null +++ b/nix/nixpkgs.nix @@ -0,0 +1,6 @@ +let + sources = import ./sources.nix { }; + rust-overlay = import sources.rust-overlay; +in +import sources.nixpkgs { overlays = [ rust-overlay ]; } + diff --git a/nix/rust-toolchain.nix b/nix/rust-toolchain.nix new file mode 100644 index 000000000..b3acb0c32 --- /dev/null +++ b/nix/rust-toolchain.nix @@ -0,0 +1,10 @@ +# Returns the Rust toolchain for Nix compliant to the rust-toolchain.toml file +# but without rustup. + +{ + # Comes from rust-overlay + rust-bin +}: + +# Includes rustc, cargo, rustfmt, etc +rust-bin.fromRustupToolchainFile ../rust-toolchain.toml diff --git a/nix/sources.json b/nix/sources.json index 6726f83ed..13fa0279f 100644 --- a/nix/sources.json +++ b/nix/sources.json @@ -1,14 +1,26 @@ { - "nixpkgs": { - "branch": "nixos-23.05", - "description": "Nix Packages collection", - "homepage": null, - "owner": "NixOS", - "repo": "nixpkgs", - "rev": "6b0edc9c690c1d8a729f055e0d73439045cfda55", - "sha256": "1fdsnmkcz1h5wffjci29af4jrd68pzdvrhbs083niwqfd6ssm633", - "type": "tarball", - "url": "https://github.com/NixOS/nixpkgs/archive/6b0edc9c690c1d8a729f055e0d73439045cfda55.tar.gz", - "url_template": "https://github.com///archive/.tar.gz" - } + "nixpkgs": { + "branch": "nixos-23.05", + "description": "Nix Packages collection", + "homepage": null, + "owner": "NixOS", + "repo": "nixpkgs", + "rev": "6b0edc9c690c1d8a729f055e0d73439045cfda55", + "sha256": "1fdsnmkcz1h5wffjci29af4jrd68pzdvrhbs083niwqfd6ssm633", + "type": "tarball", + "url": "https://github.com/NixOS/nixpkgs/archive/6b0edc9c690c1d8a729f055e0d73439045cfda55.tar.gz", + "url_template": "https://github.com///archive/.tar.gz" + }, + "rust-overlay": { + "branch": "master", + "description": "Pure and reproducible nix overlay of binary distributed rust toolchains", + "homepage": "", + "owner": "oxalica", + "repo": "rust-overlay", + "rev": "e485313fc485700a9f1f9b8b272ddc0621d08357", + "sha256": "1v1gq022rnni6mm42pxmw6c5yy9il4jb2l92irh154ax616x2rzd", + "type": "tarball", + "url": "https://github.com/oxalica/rust-overlay/archive/e485313fc485700a9f1f9b8b272ddc0621d08357.tar.gz", + "url_template": "https://github.com///archive/.tar.gz" + } } diff --git a/rust-toolchain.toml b/rust-toolchain.toml index e756ee7e3..268c6ea8b 100644 --- a/rust-toolchain.toml +++ b/rust-toolchain.toml @@ -1,2 +1,5 @@ [toolchain] +channel = "stable" +# cargo, clippy, rustc, rust-docs, rustfmt, rust-std +profile = "default" targets = ["aarch64-unknown-uefi", "i686-unknown-uefi", "x86_64-unknown-uefi"] diff --git a/shell.nix b/shell.nix index 5d94d1038..f16ba337c 100644 --- a/shell.nix +++ b/shell.nix @@ -2,10 +2,11 @@ # "cargo xtask run|test|clippy". It uses rustup rather than a pinned rust # toolchain. -{ sources ? import ./nix/sources.nix { } -, pkgs ? import sources.nixpkgs { } -}: - +let + sources = import ./nix/sources.nix; + pkgs = import ./nix/nixpkgs.nix; + rustToolchain = pkgs.callPackage ./nix/rust-toolchain.nix {}; +in pkgs.mkShell { nativeBuildInputs = with pkgs; [ # nix related stuff (such as dependency management) @@ -17,7 +18,7 @@ pkgs.mkShell { qemu # Rust toolchain - rustup + rustToolchain # Other yamlfmt From 9968231e5b3682867e9c603422bd9ab205c2ecbc Mon Sep 17 00:00:00 2001 From: Philipp Schuster Date: Tue, 14 Nov 2023 12:52:10 +0100 Subject: [PATCH 2/3] niv: update nixpkgs --- nix/sources.json | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/nix/sources.json b/nix/sources.json index 13fa0279f..e71c8d931 100644 --- a/nix/sources.json +++ b/nix/sources.json @@ -5,10 +5,10 @@ "homepage": null, "owner": "NixOS", "repo": "nixpkgs", - "rev": "6b0edc9c690c1d8a729f055e0d73439045cfda55", - "sha256": "1fdsnmkcz1h5wffjci29af4jrd68pzdvrhbs083niwqfd6ssm633", + "rev": "da4024d0ead5d7820f6bd15147d3fe2a0c0cec73", + "sha256": "1y12a4hgxx2lixrcbyhycwxvrrfik1lxjnwkprar0r6173rwy9ax", "type": "tarball", - "url": "https://github.com/NixOS/nixpkgs/archive/6b0edc9c690c1d8a729f055e0d73439045cfda55.tar.gz", + "url": "https://github.com/NixOS/nixpkgs/archive/da4024d0ead5d7820f6bd15147d3fe2a0c0cec73.tar.gz", "url_template": "https://github.com///archive/.tar.gz" }, "rust-overlay": { From c26fb9e6267c3358ae9363082698c80ec8899b81 Mon Sep 17 00:00:00 2001 From: Philipp Schuster Date: Tue, 14 Nov 2023 13:00:14 +0100 Subject: [PATCH 3/3] ci: fix "+stable" is no longer available as the rustup proxy binary is no longer used. --- .github/workflows/developer_productivity.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/developer_productivity.yml b/.github/workflows/developer_productivity.yml index 06297dd7d..c3213a3fb 100644 --- a/.github/workflows/developer_productivity.yml +++ b/.github/workflows/developer_productivity.yml @@ -25,7 +25,7 @@ jobs: # # It only runs if the "nix-src" output of the "changes" job is true. nix_shell_toolchain: - name: "Nix toolchain: cargo xtask run works" + name: "Nix toolchain: `cargo xtask run` works" needs: changes if: ${{ needs.changes.outputs.nix-src == 'true' }} runs-on: ubuntu-latest @@ -45,6 +45,6 @@ jobs: run: nix-shell --pure --run "cargo --version" - name: Run VM tests run: | - COMMAND="cargo +stable xtask run --target x86_64 --headless --ci --tpm=v1" - echo "Executing in nix shell now: $COMMAND" + COMMAND="cargo xtask run --target x86_64 --headless --ci --tpm=v1" + echo "Executing in nix shell: $COMMAND" nix-shell --pure --run "$COMMAND"