43 lines
1.3 KiB
Nix
43 lines
1.3 KiB
Nix
{
|
|
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
|
|
'';
|
|
};
|
|
};
|
|
};
|
|
};
|
|
}
|