about summary refs log tree commit diff
path: root/pkgs/profpatsch/write-rust.nix
diff options
context:
space:
mode:
authorProfpatsch <mail@profpatsch.de>2021-04-23 17:51:12 +0200
committerProfpatsch <mail@profpatsch.de>2021-04-23 17:51:12 +0200
commita3bc43ce06d132453f1f3de3e395b8cda19a3fc9 (patch)
treef3ccd282c17c5c3ae35c0749752e346814d76d28 /pkgs/profpatsch/write-rust.nix
parent1fe6dfaf8332462e5b1d75f60d7317050eee88bf (diff)
pkgs/profpatsch/write-rust: alwyas run tests by default
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.
Diffstat (limited to 'pkgs/profpatsch/write-rust.nix')
-rw-r--r--pkgs/profpatsch/write-rust.nix21
1 files changed, 16 insertions, 5 deletions
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
     ;
 }