diff options
author | zseri <zseri.devel@ytrizja.de> | 2021-12-25T04·23+0100 |
---|---|---|
committer | zseri <zseri.devel@ytrizja.de> | 2021-12-25T05·03+0000 |
commit | 1cc8aa56a44a83fd6d1841089fea8991d792207e (patch) | |
tree | 26b96da601c17c9ce39cca02b8fd315255bba452 /users/zseri/store-ref-scanner/default.nix | |
parent | f4dddea4c375dd0dc472d8879cc4fc506dd77d8c (diff) |
refactor(zseri/store-ref-scanner): get rid of proc_unroll dependency r/3386
Change-Id: I0d4a8b2af814fd2870c3eb4218ee4fbaba1216f5 Reviewed-on: https://cl.tvl.fyi/c/depot/+/4605 Tested-by: BuildkiteCI Reviewed-by: zseri <zseri.devel@ytrizja.de>
Diffstat (limited to 'users/zseri/store-ref-scanner/default.nix')
-rw-r--r-- | users/zseri/store-ref-scanner/default.nix | 50 |
1 files changed, 47 insertions, 3 deletions
diff --git a/users/zseri/store-ref-scanner/default.nix b/users/zseri/store-ref-scanner/default.nix index b78cbfbc6588..38f3fd64ecd7 100644 --- a/users/zseri/store-ref-scanner/default.nix +++ b/users/zseri/store-ref-scanner/default.nix @@ -1,5 +1,49 @@ -{ depot, pkgs, ... }: +{ depot, lib, pkgs, ... }: + +let + sourceFilter = name: type: + let + baseName = builtins.baseNameOf (builtins.toString name); + in + (baseName == "Cargo.toml") + || (type == "directory" && baseName == "src") + || (lib.hasSuffix ".rs" baseName) + ; +in + +pkgs.buildRustCrate rec { + pname = "store-ref-scanner"; + crateName = "store-ref-scanner"; + version = "0.1.0"; + edition = "2021"; + src = lib.cleanSourceWith { filter = sourceFilter; src = ./.; }; + + passthru.tests = pkgs.buildRustCrate { + pname = "store-ref-scanner-tests"; + inherit crateName src version edition; + buildTests = true; + postInstall = '' + set -ex + export RUST_BACKTRACE=1 + # recreate a file hierarchy as when running tests with cargo + # the source for test data + # build outputs + testRoot=target/debug + mkdir -p $testRoot + chmod +w -R . + # test harness executables are suffixed with a hash, + # like cargo does this allows to prevent name collision + # with the main executables of the crate + hash=$(basename $out) + ls -lasR $out + for file in $out/tests/*; do + f=$testRoot/$(basename $file)-$hash + cp $file $f + $f 2>&1 | tee -a $out/tests.log + done + rm -rf $out/tests + set +ex + ''; + }; -(import ./Cargo.nix { inherit pkgs; }).rootCrate.build.override { - runTests = true; } |