From a3bc43ce06d132453f1f3de3e395b8cda19a3fc9 Mon Sep 17 00:00:00 2001 From: Profpatsch Date: Fri, 23 Apr 2021 17:51:12 +0200 Subject: pkgs/profpatsch/write-rust: alwyas run tests by default MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit testRustSimple wouldn’t work with all the rust functions, so let’s just use it internally and expose the tests via the conventional `doCheck` attribute instead. --- pkgs/profpatsch/default.nix | 5 ++--- pkgs/profpatsch/execline/default.nix | 11 +++++------ pkgs/profpatsch/nman/default.nix | 5 ++--- pkgs/profpatsch/write-rust.nix | 21 ++++++++++++++++----- 4 files changed, 25 insertions(+), 17 deletions(-) (limited to 'pkgs/profpatsch') diff --git a/pkgs/profpatsch/default.nix b/pkgs/profpatsch/default.nix index c5f8ed94..61530859 100644 --- a/pkgs/profpatsch/default.nix +++ b/pkgs/profpatsch/default.nix @@ -128,7 +128,7 @@ in rec { git-commit-index = callPackage ./git-commit-index { inherit script; }; nix-http-serve = callPackage ./nix-http-serve {}; nman = callPackage ./nman { - inherit writeRustSimpleBin testRustSimple; + inherit writeRustSimpleBin; inherit (sternenseemann) temp; }; sfttime = callPackage ./sfttime {}; @@ -171,7 +171,6 @@ in rec { writeRustSimple writeRustSimpleBin writeRustSimpleLib - testRustSimple ; inherit (runExeclineFns) @@ -267,7 +266,7 @@ in rec { record-get ; - inherit (import ./execline/default.nix { inherit pkgs writeRustSimpleLib testRustSimple rust-deps; }) + inherit (import ./execline/default.nix { inherit pkgs writeRustSimpleLib rust-deps; }) el-semicolon el-exec el-substitute diff --git a/pkgs/profpatsch/execline/default.nix b/pkgs/profpatsch/execline/default.nix index 0f0807b5..45d616e2 100644 --- a/pkgs/profpatsch/execline/default.nix +++ b/pkgs/profpatsch/execline/default.nix @@ -1,11 +1,10 @@ -{ pkgs, writeRustSimpleLib, testRustSimple, rust-deps }: +{ pkgs, writeRustSimpleLib, rust-deps }: let - el-semicolon = testRustSimple - (writeRustSimpleLib "el_semicolon" { - release = false; - verbose = true; - } ./el_semicolon.rs); + el-semicolon = writeRustSimpleLib "el_semicolon" { + release = false; + verbose = true; + } ./el_semicolon.rs; el-exec = writeRustSimpleLib "el_exec" { dependencies = [ rust-deps.libc ]; diff --git a/pkgs/profpatsch/nman/default.nix b/pkgs/profpatsch/nman/default.nix index f03c4502..31461999 100644 --- a/pkgs/profpatsch/nman/default.nix +++ b/pkgs/profpatsch/nman/default.nix @@ -1,10 +1,9 @@ { lib , writeRustSimpleBin -, testRustSimple , temp }: -testRustSimple (writeRustSimpleBin "nman" { +writeRustSimpleBin "nman" { meta = { license = lib.licenses.gpl3Only; description = "Open man page in a temporary nix-shell"; @@ -15,4 +14,4 @@ testRustSimple (writeRustSimpleBin "nman" { postInstall = '' install -Dm644 ${./nman.1} "$out/share/man/man1/nman.1" ''; -} ./nman.rs) +} ./nman.rs diff --git a/pkgs/profpatsch/write-rust.nix b/pkgs/profpatsch/write-rust.nix index 1c02c014..13ba6b82 100644 --- a/pkgs/profpatsch/write-rust.nix +++ b/pkgs/profpatsch/write-rust.nix @@ -10,7 +10,13 @@ let "if" [ bins.s6-ln "-sL" path "$out" ] ]; - writeRustSimpleBin = name: { dependencies ? [], ... }@args: srcFile: pkgs.buildRustCrate ({ + writeRustSimpleBin = name: { + dependencies ? [], + doCheck ? true, + ... + }@args: srcFile: + (if doCheck then testRustSimple else pkgs.lib.id) + (pkgs.buildRustCrate ({ pname = name; version = "1.0.0"; crateName = name; @@ -21,9 +27,15 @@ let cp ${srcFile} $out/src/bin/${name}.rs find $out ''; - } // args); + } // args)); - writeRustSimpleLib = name: { dependencies ? [], ... }@args: srcFile: pkgs.buildRustCrate ({ + writeRustSimpleLib = name: { + dependencies ? [], + doCheck ? true, + ... + }@args: srcFile: + (if doCheck then testRustSimple else pkgs.lib.id) + (pkgs.buildRustCrate ({ pname = name; version = "1.0.0"; crateName = name; @@ -33,7 +45,7 @@ let cp ${srcFile} $out/src/lib.rs find $out ''; - } // args); + } // args)); /* Takes a `buildRustCrate` derivation as an input, * builds it with `{ buildTests = true; }` and runs @@ -65,6 +77,5 @@ in { writeRustSimple writeRustSimpleBin writeRustSimpleLib - testRustSimple ; } -- cgit 1.4.1