Initial commit
This commit is contained in:
commit
e483f73dd4
12 changed files with 479 additions and 0 deletions
2
examples/.gitignore
vendored
Normal file
2
examples/.gitignore
vendored
Normal file
|
|
@ -0,0 +1,2 @@
|
|||
flake.lock
|
||||
target/
|
||||
7
examples/crane/Cargo.lock
generated
Normal file
7
examples/crane/Cargo.lock
generated
Normal file
|
|
@ -0,0 +1,7 @@
|
|||
# This file is automatically @generated by Cargo.
|
||||
# It is not intended for manual editing.
|
||||
version = 3
|
||||
|
||||
[[package]]
|
||||
name = "rusty-hello"
|
||||
version = "0.1.0"
|
||||
8
examples/crane/Cargo.toml
Normal file
8
examples/crane/Cargo.toml
Normal file
|
|
@ -0,0 +1,8 @@
|
|||
[package]
|
||||
name = "rusty-hello"
|
||||
version = "0.1.0"
|
||||
edition = "2021"
|
||||
|
||||
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
||||
|
||||
[dependencies]
|
||||
43
examples/crane/flake.nix
Normal file
43
examples/crane/flake.nix
Normal file
|
|
@ -0,0 +1,43 @@
|
|||
{
|
||||
description = "An example of a shell environment with a Crane-built package";
|
||||
|
||||
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.crane ];
|
||||
|
||||
systems = [ "x86_64-linux" ];
|
||||
|
||||
perSystem =
|
||||
{ pkgs, craneLib, self', ... }: {
|
||||
packages.rusty-hello = craneLib.buildPackage {
|
||||
src = craneLib.cleanCargoSource (craneLib.path ./.);
|
||||
strictDeps = true;
|
||||
};
|
||||
|
||||
checks = {
|
||||
craneCompilesRustPackage = pkgs.stdenv.mkDerivation {
|
||||
name = "check-crane-compiles-rust-package";
|
||||
dontUnpack = true;
|
||||
buildPhase = ''
|
||||
set -euo pipefail
|
||||
|
||||
# Check that the compilation of our trivial package yielded something we can actually execute.
|
||||
OUTPUT="$(${self'.packages.rusty-hello}/bin/rusty-hello)"
|
||||
if [[ "$OUTPUT" != "Rusty-Hello" ]]; then
|
||||
echo "Received output '$OUTPUT', expected 'Rusty-Hello'" >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
touch $out
|
||||
'';
|
||||
};
|
||||
};
|
||||
};
|
||||
};
|
||||
}
|
||||
3
examples/crane/src/main.rs
Normal file
3
examples/crane/src/main.rs
Normal file
|
|
@ -0,0 +1,3 @@
|
|||
fn main() {
|
||||
println!("Rusty-Hello");
|
||||
}
|
||||
8
examples/fenix/Cargo.toml
Normal file
8
examples/fenix/Cargo.toml
Normal file
|
|
@ -0,0 +1,8 @@
|
|||
[package]
|
||||
name = "fenix"
|
||||
version = "0.1.0"
|
||||
edition = "2021"
|
||||
|
||||
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
||||
|
||||
[dependencies]
|
||||
51
examples/fenix/flake.nix
Normal file
51
examples/fenix/flake.nix
Normal file
|
|
@ -0,0 +1,51 @@
|
|||
{
|
||||
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
|
||||
'';
|
||||
};
|
||||
};
|
||||
};
|
||||
};
|
||||
}
|
||||
3
examples/fenix/src/main.rs
Normal file
3
examples/fenix/src/main.rs
Normal file
|
|
@ -0,0 +1,3 @@
|
|||
fn main() {
|
||||
println!("Hello, world!");
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue