Initial commit

This commit is contained in:
Sebastien Braun 2024-02-08 22:00:00 +00:00
commit e483f73dd4
12 changed files with 479 additions and 0 deletions

7
examples/crane/Cargo.lock generated Normal file
View 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"

View 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
View 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
'';
};
};
};
};
}

View file

@ -0,0 +1,3 @@
fn main() {
println!("Rusty-Hello");
}