diesel-cli: use comma-separated features, use buildAndTestSubdir
This commit is contained in:
parent
087ab3db9c
commit
1df80d2bad
@ -1,3 +1,5 @@
|
|||||||
|
declare -a checkFlags
|
||||||
|
|
||||||
cargoCheckHook() {
|
cargoCheckHook() {
|
||||||
echo "Executing cargoCheckHook"
|
echo "Executing cargoCheckHook"
|
||||||
|
|
||||||
@ -34,4 +36,6 @@ cargoCheckHook() {
|
|||||||
runHook postCheck
|
runHook postCheck
|
||||||
}
|
}
|
||||||
|
|
||||||
checkPhase=cargoCheckHook
|
if [ -z "${checkPhase-}" ]; then
|
||||||
|
checkPhase=cargoCheckHook
|
||||||
|
fi
|
||||||
|
@ -9,11 +9,9 @@ assert lib.assertMsg (sqliteSupport == true || postgresqlSupport == true || mysq
|
|||||||
|
|
||||||
let
|
let
|
||||||
inherit (lib) optional optionals optionalString;
|
inherit (lib) optional optionals optionalString;
|
||||||
features = ''
|
features = optional sqliteSupport "sqlite"
|
||||||
${optionalString sqliteSupport "sqlite"} \
|
++ optional postgresqlSupport "postgres"
|
||||||
${optionalString postgresqlSupport "postgres"} \
|
++ optional mysqlSupport "mysql";
|
||||||
${optionalString mysqlSupport "mysql"} \
|
|
||||||
'';
|
|
||||||
in
|
in
|
||||||
|
|
||||||
rustPlatform.buildRustPackage rec {
|
rustPlatform.buildRustPackage rec {
|
||||||
@ -35,11 +33,12 @@ rustPlatform.buildRustPackage rec {
|
|||||||
./allow-warnings.patch
|
./allow-warnings.patch
|
||||||
];
|
];
|
||||||
|
|
||||||
cargoBuildFlags = [ "--no-default-features --features \"${features}\"" ];
|
cargoBuildFlags = [ "--no-default-features" "--features" "${lib.concatStringsSep "," features}" ];
|
||||||
cargoPatches = [ ./cargo-lock.patch ];
|
cargoPatches = [ ./cargo-lock.patch ];
|
||||||
cargoSha256 = "1vbb7r0dpmq8363i040bkhf279pz51c59kcq9v5qr34hs49ish8g";
|
cargoSha256 = "1vbb7r0dpmq8363i040bkhf279pz51c59kcq9v5qr34hs49ish8g";
|
||||||
|
|
||||||
nativeBuildInputs = [ pkg-config ];
|
nativeBuildInputs = [ pkg-config ];
|
||||||
|
|
||||||
buildInputs = [ openssl ]
|
buildInputs = [ openssl ]
|
||||||
++ optional stdenv.isDarwin Security
|
++ optional stdenv.isDarwin Security
|
||||||
++ optional (stdenv.isDarwin && mysqlSupport) libiconv
|
++ optional (stdenv.isDarwin && mysqlSupport) libiconv
|
||||||
@ -47,12 +46,7 @@ rustPlatform.buildRustPackage rec {
|
|||||||
++ optional postgresqlSupport postgresql
|
++ optional postgresqlSupport postgresql
|
||||||
++ optionals mysqlSupport [ mysql zlib ];
|
++ optionals mysqlSupport [ mysql zlib ];
|
||||||
|
|
||||||
# We must `cd diesel_cli`, we cannot use `--package diesel_cli` to build
|
buildAndTestSubdir = "diesel_cli";
|
||||||
# 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 ..";
|
|
||||||
|
|
||||||
checkPhase = optionalString sqliteSupport ''
|
checkPhase = optionalString sqliteSupport ''
|
||||||
(cd diesel_cli && cargo check --features sqlite)
|
(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:
|
# Fix the build with mariadb, which otherwise shows "error adding symbols:
|
||||||
# DSO missing from command line" errors for libz and libssl.
|
# 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; {
|
meta = with lib; {
|
||||||
description = "Database tool for working with Rust projects that use Diesel";
|
description = "Database tool for working with Rust projects that use Diesel";
|
||||||
|
Loading…
x
Reference in New Issue
Block a user