crane/checks/trunk.nix
Simon Žlender aa5dcd0518
Splice overrideToolchain (#652)
---------

Co-authored-by: Ivan Petkov <ivanppetkov@gmail.com>
2024-06-29 11:29:52 -07:00

61 lines
1.8 KiB
Nix

{ myLib
, pkgs
, runCommand
, stdenv
}:
let
wasmToolchainFor = p: p.rust-bin.stable.latest.minimal.override {
targets = [ "wasm32-unknown-unknown" ];
};
tarball = builtins.fetchTarball {
url = "https://github.com/NixOS/nixpkgs/archive/4e6868b1aa3766ab1de169922bb3826143941973.tar.gz";
sha256 = "sha256:1q6bj2jjlwb10sfrhqmjpzsc3yc4x76cvky16wh0z52p7d2lhdpv";
};
myLibWasm = (myLib.overrideToolchain wasmToolchainFor).overrideScope (_final: _prev: {
inherit (import tarball { inherit (stdenv) system; }) wasm-bindgen-cli;
});
defaultArgs = {
src = ./trunk;
doCheck = false;
wasm-bindgen-cli = pkgs.wasm-bindgen-cli.override {
version = "0.2.92";
hash = "sha256-1VwY8vQy7soKEgbki4LD+v259751kKxSxmo/gqE6yV0=";
cargoHash = "sha256-aACJ+lYNEU8FFBs158G1/JG8sc6Rq080PeKCMnwdpH0=";
};
};
# default build
cargoArtifacts = myLibWasm.buildDepsOnly (defaultArgs // {
CARGO_BUILD_TARGET = "wasm32-unknown-unknown";
});
trunkSimple = myLibWasm.buildTrunkPackage (defaultArgs // {
inherit cargoArtifacts;
pname = "trunk-simple";
});
trunkSimpleNoArtifacts = myLibWasm.buildTrunkPackage (defaultArgs // {
pname = "trunk-simple-no-artifacts";
});
trunkOutdatedBindgen = myLibWasm.buildTrunkPackage {
pname = "trunk-outdated-bindgen";
src = ./trunk-outdated-bindgen;
doCheck = false;
wasm-bindgen-cli = pkgs.wasm-bindgen-cli.override {
version = "0.2.85";
hash = "sha256-0pTIzpu7dJM34CXmi83e8UV0E3N2bKJiOMw5WJQ2s/Y=";
cargoHash = "sha256-ZwmoFKmGaf5VvTTXjLyb2714Pu536E/8UxUzxI40ID8=";
};
};
in
runCommand "trunkTests" { } ''
test -f ${trunkSimple}/*.wasm
test -f ${trunkSimple}/*.css
test -f ${trunkSimpleNoArtifacts}/*.wasm
test -f ${trunkOutdatedBindgen}/*.wasm
mkdir -p $out
''