Skip to content

Rust Prelude runtime library #118

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 22 commits into from
Nov 9, 2023
Merged
Show file tree
Hide file tree
Changes from 21 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions extras/build.nix
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
overlayAttrs = {
extras = {
purescriptFlake = import ./flake-purescript.nix pkgs;
rustFlake = import ./flake-rust.nix pkgs;
haskellData = import ./haskell-data.nix pkgs;
};
};
Expand Down
53 changes: 53 additions & 0 deletions extras/flake-rust.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
pkgs:

{ crane, src, system, crateName, localDeps, dataDeps }:
let
rustWithTools = pkgs.rust-bin.stable.latest.default.override {
extensions = [ "rustfmt" "rust-analyzer" "clippy" ];
};
craneLib = crane.lib.${system}.overrideToolchain rustWithTools;

buildEnv = pkgs.stdenv.mkDerivation {
inherit src;
name = "lbf-rust-workspace";
unpackPhase = builtins.concatStringsSep "\n"
([
"mkdir -p $out"
"cp -r $src $out/${crateName}"
]
++ (map ({ name, path }: "cp -r ${path} $out/${name}") localDeps)
++ (map ({ name, path }: "cp -r ${path} $out/${name}") dataDeps)
);
};
commonArgs = {
src = buildEnv;
pname = crateName;
strictDeps = true;
cargoLock = "${src}/Cargo.lock";
cargoToml = "${src}/Cargo.toml";
postUnpack = ''
cd $sourceRoot/${crateName}
sourceRoot="."
'';
};
cargoArtifacts = craneLib.buildDepsOnly commonArgs;

in
{
devShells."dev-${crateName}-rust" = craneLib.devShell {
# checks = self'.checks;
};

packages."${crateName}-rust" = craneLib.buildPackage commonArgs // {
inherit cargoArtifacts;
doCheck = false;
};

checks."${crateName}-rust-test" = craneLib.cargoNextest (commonArgs // {
inherit cargoArtifacts;
});

checks."${crateName}-rust-clippy" = craneLib.cargoClippy (commonArgs // {
inherit cargoArtifacts;
});
}
1 change: 1 addition & 0 deletions flake.nix
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@
./runtimes/purescript/lbr-prelude/build.nix
./runtimes/purescript/lbr-plutus/build.nix
./runtimes/rust/lbr-prelude/build.nix
./runtimes/rust/lbr-prelude-derive/build.nix
./testsuites/lbt-prelude/api/build.nix
./testsuites/lbt-prelude/golden/build.nix
./testsuites/lbt-prelude/lbt-prelude-haskell/build.nix
Expand Down
2 changes: 2 additions & 0 deletions runtimes/rust/lbr-prelude-derive/.envrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
nix_direnv_watch_file ./build.nix
use flake ../../..#dev-lbr-prelude-derive-rust
2 changes: 2 additions & 0 deletions runtimes/rust/lbr-prelude-derive/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
/target
/proptest-regressions
Loading