52 lines
1.6 KiB
Nix
52 lines
1.6 KiB
Nix
|
|
{
|
||
|
|
description = "An example of a shell environment with a Fenix toolchain";
|
||
|
|
|
||
|
|
inputs = {
|
||
|
|
rust.url = "git+https://forgejo.alt0r.com/braunse/rust-part";
|
||
|
|
nixpkgs.follows = "rust/nixpkgs";
|
||
|
|
parts.follows = "rust/parts";
|
||
|
|
rustManifest.follows = "rust/rustManifest";
|
||
|
|
};
|
||
|
|
|
||
|
|
outputs = inputs: inputs.parts.lib.mkFlake { inherit inputs; } {
|
||
|
|
imports = [ inputs.rust.flakeModules.fenix ];
|
||
|
|
|
||
|
|
systems = [ "x86_64-linux" ];
|
||
|
|
|
||
|
|
rust.fenix.manifestFile = inputs.rustManifest;
|
||
|
|
rust.fenix.components = [ "rustfmt" ];
|
||
|
|
rust.fenix.targetComponents.wasm32-unknown-unknown = [ "rust-std" ];
|
||
|
|
|
||
|
|
perSystem =
|
||
|
|
{ pkgs, fenixToolchain, ... }: {
|
||
|
|
checks = {
|
||
|
|
haveRustChain = pkgs.stdenv.mkDerivation {
|
||
|
|
name = "check-rust-toolchain-is-present";
|
||
|
|
dontUnpack = true;
|
||
|
|
buildPhase = ''
|
||
|
|
set -euo pipefail
|
||
|
|
|
||
|
|
echo "Checking for cargo" >&2
|
||
|
|
${fenixToolchain}/bin/cargo --version >/dev/null
|
||
|
|
|
||
|
|
echo "Checking for rustc" >&2
|
||
|
|
${fenixToolchain}/bin/rustc --version >/dev/null
|
||
|
|
|
||
|
|
echo "Checking for rustfmt" >&2
|
||
|
|
${fenixToolchain}/bin/rustfmt --version >/dev/null
|
||
|
|
|
||
|
|
echo "Checking compiler compiles natively" >&2
|
||
|
|
touch lib.rs
|
||
|
|
${fenixToolchain}/bin/rustc --crate-type rlib --crate-name nativechecklib lib.rs
|
||
|
|
|
||
|
|
echo "Checking compiler compiles for wasm32-unknown-unknown" >&2
|
||
|
|
${fenixToolchain}/bin/rustc --crate-type rlib --crate-name crosschecklib --target wasm32-unknown-unknown lib.rs
|
||
|
|
|
||
|
|
touch $out
|
||
|
|
'';
|
||
|
|
};
|
||
|
|
};
|
||
|
|
};
|
||
|
|
};
|
||
|
|
}
|