summary refs log tree commit diff
diff options
context:
space:
mode:
authorDaniël de Kok <me@danieldk.eu>2021-02-15 11:18:37 +0100
committerDaniël de Kok <me@danieldk.eu>2021-02-16 08:09:17 +0100
commit1df80d2bade93da39d844ce3b60185d79689e4bd (patch)
tree8224ebf97e3f833930de0147e800427c3ac31f9a
parent087ab3db9cd2a597700e438ae1d0fbe90c1e3fd0 (diff)
downloadnixpkgs-1df80d2bade93da39d844ce3b60185d79689e4bd.tar
nixpkgs-1df80d2bade93da39d844ce3b60185d79689e4bd.tar.gz
nixpkgs-1df80d2bade93da39d844ce3b60185d79689e4bd.tar.bz2
nixpkgs-1df80d2bade93da39d844ce3b60185d79689e4bd.tar.lz
nixpkgs-1df80d2bade93da39d844ce3b60185d79689e4bd.tar.xz
nixpkgs-1df80d2bade93da39d844ce3b60185d79689e4bd.tar.zst
nixpkgs-1df80d2bade93da39d844ce3b60185d79689e4bd.zip
diesel-cli: use comma-separated features, use buildAndTestSubdir
-rw-r--r--pkgs/build-support/rust/hooks/cargo-check-hook.sh6
-rw-r--r--pkgs/development/tools/diesel-cli/default.nix20
2 files changed, 12 insertions, 14 deletions
diff --git a/pkgs/build-support/rust/hooks/cargo-check-hook.sh b/pkgs/build-support/rust/hooks/cargo-check-hook.sh
index a1df2babffb..8c5b1a13219 100644
--- a/pkgs/build-support/rust/hooks/cargo-check-hook.sh
+++ b/pkgs/build-support/rust/hooks/cargo-check-hook.sh
@@ -1,3 +1,5 @@
+declare -a checkFlags
+
 cargoCheckHook() {
     echo "Executing cargoCheckHook"
 
@@ -34,4 +36,6 @@ cargoCheckHook() {
     runHook postCheck
 }
 
-checkPhase=cargoCheckHook
+if [ -z "${checkPhase-}" ]; then
+  checkPhase=cargoCheckHook
+fi
diff --git a/pkgs/development/tools/diesel-cli/default.nix b/pkgs/development/tools/diesel-cli/default.nix
index bd8e71090c5..20185ff7d13 100644
--- a/pkgs/development/tools/diesel-cli/default.nix
+++ b/pkgs/development/tools/diesel-cli/default.nix
@@ -9,11 +9,9 @@ assert lib.assertMsg (sqliteSupport == true || postgresqlSupport == true || mysq
 
 let
   inherit (lib) optional optionals optionalString;
-  features = ''
-    ${optionalString sqliteSupport "sqlite"} \
-    ${optionalString postgresqlSupport "postgres"} \
-    ${optionalString mysqlSupport "mysql"} \
-  '';
+  features = optional sqliteSupport "sqlite"
+    ++ optional postgresqlSupport "postgres"
+    ++ optional mysqlSupport "mysql";
 in
 
 rustPlatform.buildRustPackage rec {
@@ -35,11 +33,12 @@ rustPlatform.buildRustPackage rec {
     ./allow-warnings.patch
   ];
 
-  cargoBuildFlags = [ "--no-default-features --features \"${features}\"" ];
+  cargoBuildFlags = [ "--no-default-features" "--features" "${lib.concatStringsSep "," features}" ];
   cargoPatches = [ ./cargo-lock.patch ];
   cargoSha256 = "1vbb7r0dpmq8363i040bkhf279pz51c59kcq9v5qr34hs49ish8g";
 
   nativeBuildInputs = [ pkg-config ];
+
   buildInputs = [ openssl ]
     ++ optional stdenv.isDarwin Security
     ++ optional (stdenv.isDarwin && mysqlSupport) libiconv
@@ -47,12 +46,7 @@ rustPlatform.buildRustPackage rec {
     ++ optional postgresqlSupport postgresql
     ++ optionals mysqlSupport [ mysql zlib ];
 
-  # We must `cd diesel_cli`, we cannot use `--package diesel_cli` to build
-  # because --features fails to apply to the package:
-  # https://github.com/rust-lang/cargo/issues/5015
-  # https://github.com/rust-lang/cargo/issues/4753
-  preBuild = "cd diesel_cli";
-  postBuild = "cd ..";
+  buildAndTestSubdir = "diesel_cli";
 
   checkPhase = optionalString sqliteSupport ''
     (cd diesel_cli && cargo check --features sqlite)
@@ -65,7 +59,7 @@ rustPlatform.buildRustPackage rec {
 
   # Fix the build with mariadb, which otherwise shows "error adding symbols:
   # DSO missing from command line" errors for libz and libssl.
-  NIX_LDFLAGS = lib.optionalString mysqlSupport "-lz -lssl -lcrypto";
+  NIX_LDFLAGS = optionalString mysqlSupport "-lz -lssl -lcrypto";
 
   meta = with lib; {
     description = "Database tool for working with Rust projects that use Diesel";