2021-01-19 06:50:56 +00:00
|
|
|
{ stdenv, lib, rustPlatform, fetchFromGitHub, openssl, pkg-config, Security
|
2019-09-01 00:40:47 +01:00
|
|
|
, sqliteSupport ? true, sqlite
|
|
|
|
, postgresqlSupport ? true, postgresql
|
|
|
|
, mysqlSupport ? true, mysql, zlib, libiconv
|
|
|
|
}:
|
|
|
|
|
|
|
|
assert lib.assertMsg (sqliteSupport == true || postgresqlSupport == true || mysqlSupport == true)
|
|
|
|
"support for at least one database must be enabled";
|
|
|
|
|
|
|
|
let
|
2021-01-23 12:26:19 +00:00
|
|
|
inherit (lib) optional optionals optionalString;
|
2021-02-15 10:18:37 +00:00
|
|
|
features = optional sqliteSupport "sqlite"
|
|
|
|
++ optional postgresqlSupport "postgres"
|
|
|
|
++ optional mysqlSupport "mysql";
|
2019-09-01 00:40:47 +01:00
|
|
|
in
|
|
|
|
|
|
|
|
rustPlatform.buildRustPackage rec {
|
|
|
|
pname = "diesel-cli";
|
|
|
|
version = "1.4.0";
|
|
|
|
|
|
|
|
src = fetchFromGitHub {
|
|
|
|
owner = "diesel-rs";
|
|
|
|
repo = "diesel";
|
|
|
|
rev = "v${version}";
|
|
|
|
sha256 = "0wp4hvpl9cf8hw1jyz3z476k5blrh6srfpv36dw10bj126rz9pvb";
|
|
|
|
};
|
|
|
|
|
|
|
|
patches = [
|
|
|
|
# Allow warnings to fix many instances of `error: trait objects without an explicit `dyn` are deprecated`
|
|
|
|
#
|
|
|
|
# Remove this after https://github.com/diesel-rs/diesel/commit/9004d1c3fa12aaee84986bd3d893002491373f8c
|
|
|
|
# is in a release.
|
|
|
|
./allow-warnings.patch
|
|
|
|
];
|
|
|
|
|
2021-02-15 10:18:37 +00:00
|
|
|
cargoBuildFlags = [ "--no-default-features" "--features" "${lib.concatStringsSep "," features}" ];
|
2019-09-01 00:40:47 +01:00
|
|
|
cargoPatches = [ ./cargo-lock.patch ];
|
2020-03-09 02:14:17 +00:00
|
|
|
cargoSha256 = "1vbb7r0dpmq8363i040bkhf279pz51c59kcq9v5qr34hs49ish8g";
|
2019-09-01 00:40:47 +01:00
|
|
|
|
2021-01-19 06:50:56 +00:00
|
|
|
nativeBuildInputs = [ pkg-config ];
|
2021-02-15 10:18:37 +00:00
|
|
|
|
2019-09-01 00:40:47 +01:00
|
|
|
buildInputs = [ openssl ]
|
|
|
|
++ optional stdenv.isDarwin Security
|
|
|
|
++ optional (stdenv.isDarwin && mysqlSupport) libiconv
|
|
|
|
++ optional sqliteSupport sqlite
|
|
|
|
++ optional postgresqlSupport postgresql
|
|
|
|
++ optionals mysqlSupport [ mysql zlib ];
|
|
|
|
|
2021-02-15 10:18:37 +00:00
|
|
|
buildAndTestSubdir = "diesel_cli";
|
2019-09-01 00:40:47 +01:00
|
|
|
|
|
|
|
checkPhase = optionalString sqliteSupport ''
|
|
|
|
(cd diesel_cli && cargo check --features sqlite)
|
|
|
|
'';
|
|
|
|
|
|
|
|
doInstallCheck = true;
|
|
|
|
installCheckPhase = ''
|
|
|
|
$out/bin/diesel --version
|
|
|
|
'';
|
|
|
|
|
|
|
|
# Fix the build with mariadb, which otherwise shows "error adding symbols:
|
|
|
|
# DSO missing from command line" errors for libz and libssl.
|
2021-02-15 10:18:37 +00:00
|
|
|
NIX_LDFLAGS = optionalString mysqlSupport "-lz -lssl -lcrypto";
|
2019-09-01 00:40:47 +01:00
|
|
|
|
|
|
|
meta = with lib; {
|
|
|
|
description = "Database tool for working with Rust projects that use Diesel";
|
2020-04-01 02:11:51 +01:00
|
|
|
homepage = "https://github.com/diesel-rs/diesel/tree/master/diesel_cli";
|
2019-09-01 00:40:47 +01:00
|
|
|
license = with licenses; [ mit asl20 ];
|
2020-01-03 22:01:18 +00:00
|
|
|
maintainers = with maintainers; [ ];
|
2019-09-01 00:40:47 +01:00
|
|
|
};
|
|
|
|
}
|