Closed ghost closed 2 years ago
Yes! fenix provides fromToolchainFile
, it supports both rust-toolchain
and rust-toolchain.toml
you can use it like this
fromToolchainFile {
file = ./rust-toolchain.toml;
sha256 = lib.fakeSha256;
}
or this (impure without sha256)
fromToolchainFile { dir = ./.; }
Sweet, thanks for the documentation @figsoda. I'll close. As an aside, you may find my discourse question about which Rust overlay to prefer interesting.
rust-gpu uses a rust-toolchain.toml
file.
If I use rustup like this (following these instructions):
git clone https://github.com/EmbarkStudios/rust-gpu
cd rust-gpu
cat > shell.nix << EOF
let
pkgs = import <nixpkgs> {};
fenix = (import (fetchTarball "https://github.com/nix-community/fenix/archive/main.tar.gz") {});
in
pkgs.mkShell rec {
# spirv-tools-sys compiles with -Werror and that breaks on _FORTIFY_SOURCE
# without an optimization level. OPT_LEVEL might or might not work.
# https://github.com/NixOS/nixpkgs/issues/60919
hardeningDisable = [ "fortify" ];
RUST_BACKTRACE = 1;
# Necessary to find libvulkan.so.1 (RUST_LOG=wgpu_hal=debug).
LD_LIBRARY_PATH = pkgs.lib.makeLibraryPath buildInputs;
nativeBuildInputs = with pkgs; [
rustup
];
buildInputs = with pkgs; [
# For libvulkan.so.1 (RUST_LOG=wgpu_hal=debug).
vulkan-loader
# X
xorg.libX11 xorg.libXcursor xorg.libXi xorg.libXrandr
# Wayland
# https://github.com/gfx-rs/wgpu/issues/2519
# libxkbcommon wayland
];
}
EOF
nix-shell
cargo build
It builds.
But if I replace rustup with fenix:
git clone https://github.com/EmbarkStudios/rust-gpu
cd rust-gpu
cat > shell.nix << EOF
let
pkgs = import <nixpkgs> {};
fenix = (import (fetchTarball "https://github.com/nix-community/fenix/archive/main.tar.gz") {});
in
pkgs.mkShell rec {
# spirv-tools-sys compiles with -Werror and that breaks on _FORTIFY_SOURCE
# without an optimization level. OPT_LEVEL might or might not work.
# https://github.com/NixOS/nixpkgs/issues/60919
hardeningDisable = [ "fortify" ];
RUST_BACKTRACE = 1;
# Necessary to find libvulkan.so.1 (RUST_LOG=wgpu_hal=debug).
LD_LIBRARY_PATH = pkgs.lib.makeLibraryPath buildInputs;
nativeBuildInputs = with pkgs; [
(fenix.fromToolchainFile { dir = ./.; })
];
buildInputs = with pkgs; [
# For libvulkan.so.1 (RUST_LOG=wgpu_hal=debug).
vulkan-loader
# X
xorg.libX11 xorg.libXcursor xorg.libXi xorg.libXrandr
# Wayland
# https://github.com/gfx-rs/wgpu/issues/2519
# libxkbcommon wayland
];
}
EOF
nix-shell
cargo build
I'll hit https://github.com/EmbarkStudios/rust-gpu/issues/1047:
error[E0599]: no function or associated item named `from_u128` found for type parameter `P` in the current scope
--> crates/rustc_codegen_spirv/src/abi.rs:867:26
|
861 | fn const_int_value<'tcx, P: FromPrimitive>(
| - function or associated item `from_u128` not found for this type parameter
...
867 | match P::from_u128(value) {
| ^^^^^^^^^
| |
| function or associated item not found in `P`
| help: there is an associated function with a similar name: `from_u8`
I wanted to use the same version but with additional components, something along the lines of:
((fenix.toolchainOf {
channel = "nightly";
date = "2023-03-04";
sha256 = "sha256-s9/H9SHOZJdYyJsiqT+cMTspY0SzaaF64ydLiTSfDqQ=";
}).withComponents [
"cargo"
"clippy"
"llvm-tools-preview"
"rust-analyzer"
"rust-src"
"rustc"
"rustc-dev"
"rustfmt"
])
Which should be a superset of their rust-toolchain.toml
but obviously, I'm misunderstanding something.
https://github.com/nix-community/fenix/commit/b4616f7fa72bcda1b48511e4043d6813aa2d953b should be able to fix it once it gets into main
Thanks!
As a Rust developer I declare a project's toolchain in a toolchain file.
Does fenix support this file or would I need to copy the contents of that file into my
flake.nix
?Thanks!