flake.nix: create packaging, generate coverage
This commit is contained in:
75
nix/coverage.nix
Normal file
75
nix/coverage.nix
Normal file
@@ -0,0 +1,75 @@
|
||||
{
|
||||
lib
|
||||
, stdenvNoCC
|
||||
, rustPlatform
|
||||
, cargoToml
|
||||
, cargoLock
|
||||
, src
|
||||
|
||||
, rust-bin
|
||||
, cargo-nextest
|
||||
, grcov
|
||||
}:
|
||||
|
||||
stdenvNoCC.mkDerivation {
|
||||
pname = "coverage-${cargoToml.package.name}";
|
||||
version = cargoToml.package.version;
|
||||
inherit src;
|
||||
|
||||
env = {
|
||||
RUSTFLAGS = "-Cinstrument-coverage";
|
||||
LLVM_PROFILE_FILE = "target/coverage/%p-%m.profraw";
|
||||
};
|
||||
|
||||
cargoDeps = rustPlatform.importCargoLock {
|
||||
lockFile = cargoLock;
|
||||
};
|
||||
|
||||
nativeBuildInputs = [
|
||||
rustPlatform.cargoSetupHook
|
||||
cargo-nextest
|
||||
grcov
|
||||
(rust-bin.selectLatestNightlyWith (toolchain: toolchain.default.override {
|
||||
extensions = [ "llvm-tools-preview" ];
|
||||
}))
|
||||
];
|
||||
|
||||
buildPhase = ''
|
||||
runHook preBuild
|
||||
|
||||
export HOME="$(pwd)"
|
||||
|
||||
cargo nextest run --all-features --release --no-fail-fast
|
||||
|
||||
grcov \
|
||||
--source-dir . \
|
||||
--binary-path ./target/release/deps/ \
|
||||
--excl-start 'mod test* \{' \
|
||||
--ignore 'tests/*' \
|
||||
--ignore "*test.rs" \
|
||||
--ignore "*tests.rs" \
|
||||
--ignore "*github.com*" \
|
||||
--ignore "*libcore*" \
|
||||
--ignore "*rustc*" \
|
||||
--ignore "*liballoc*" \
|
||||
--ignore "*cargo*" \
|
||||
-t html \
|
||||
-o ./target/coverage/html \
|
||||
target/coverage/
|
||||
|
||||
runHook postBuild
|
||||
'';
|
||||
|
||||
installPhase = ''
|
||||
runHook preBuild
|
||||
|
||||
mv target/coverage $out
|
||||
|
||||
runHook postBuild
|
||||
'';
|
||||
|
||||
meta = with lib; {
|
||||
license = licenses.mit;
|
||||
platforms = platforms.linux ++ platforms.darwin;
|
||||
};
|
||||
}
|
22
nix/default.nix
Normal file
22
nix/default.nix
Normal file
@@ -0,0 +1,22 @@
|
||||
{
|
||||
lib
|
||||
, rustPlatform
|
||||
, cargoToml
|
||||
, cargoLock
|
||||
, src
|
||||
}:
|
||||
let
|
||||
in
|
||||
rustPlatform.buildRustPackage {
|
||||
pname = cargoToml.package.name;
|
||||
version = cargoToml.package.version;
|
||||
inherit src;
|
||||
|
||||
cargoLock.lockFile = cargoLock;
|
||||
|
||||
meta = with lib; {
|
||||
license = licenses.mit;
|
||||
platforms = platforms.linux ++ platforms.darwin;
|
||||
mainProgram = (lib.head cargoToml.bin).name;
|
||||
};
|
||||
}
|
Reference in New Issue
Block a user