2021-10-08 00:14:24 +01:00
|
|
|
{ lib
|
|
|
|
, sqliteSupport ? true
|
|
|
|
, postgresqlSupport ? true
|
|
|
|
, mysqlSupport ? true
|
|
|
|
, rustPlatform
|
|
|
|
, fetchCrate
|
|
|
|
, installShellFiles
|
|
|
|
, pkg-config
|
|
|
|
, openssl
|
|
|
|
, stdenv
|
|
|
|
, Security
|
|
|
|
, libiconv
|
|
|
|
, sqlite
|
|
|
|
, postgresql
|
|
|
|
, mariadb
|
|
|
|
, zlib
|
2019-09-01 00:40:47 +01:00
|
|
|
}:
|
|
|
|
|
|
|
|
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;
|
2019-09-01 00:40:47 +01:00
|
|
|
in
|
|
|
|
|
|
|
|
rustPlatform.buildRustPackage rec {
|
|
|
|
pname = "diesel-cli";
|
2021-03-29 18:03:58 +01:00
|
|
|
version = "1.4.1";
|
2019-09-01 00:40:47 +01:00
|
|
|
|
2021-10-08 00:14:24 +01:00
|
|
|
src = fetchCrate {
|
|
|
|
inherit version;
|
|
|
|
crateName = "diesel_cli";
|
|
|
|
sha256 = "sha256-mRdDc4fHMkwkszY+2l8z1RSNMEQnrWI5/Y0Y2W+guQE=";
|
2019-09-01 00:40:47 +01:00
|
|
|
};
|
|
|
|
|
2021-10-08 00:14:24 +01:00
|
|
|
cargoSha256 = "sha256-sQ762Ss31sA5qALHzwkvwbfRXo00cCtqzQyoz3/zf6I=";
|
2019-09-01 00:40:47 +01:00
|
|
|
|
2021-10-08 00:14:24 +01:00
|
|
|
nativeBuildInputs = [ installShellFiles 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
|
2021-03-14 16:11:57 +00:00
|
|
|
++ optionals mysqlSupport [ mariadb zlib ];
|
2019-09-01 00:40:47 +01:00
|
|
|
|
2021-11-16 00:46:47 +00:00
|
|
|
buildNoDefaultFeatures = true;
|
|
|
|
buildFeatures = optional sqliteSupport "sqlite"
|
|
|
|
++ optional postgresqlSupport "postgres"
|
|
|
|
++ optional mysqlSupport "mysql";
|
|
|
|
|
2021-10-08 00:14:24 +01:00
|
|
|
checkPhase = ''
|
|
|
|
runHook preCheck
|
|
|
|
'' + optionalString sqliteSupport ''
|
|
|
|
cargo check --features sqlite
|
|
|
|
'' + optionalString postgresqlSupport ''
|
|
|
|
cargo check --features postgres
|
|
|
|
'' + optionalString mysqlSupport ''
|
|
|
|
cargo check --features mysql
|
|
|
|
'' + ''
|
|
|
|
runHook postCheck
|
2019-09-01 00:40:47 +01:00
|
|
|
'';
|
|
|
|
|
2021-10-08 00:14:24 +01:00
|
|
|
postInstall = ''
|
|
|
|
installShellCompletion --cmd diesel \
|
|
|
|
--bash <($out/bin/diesel completions bash) \
|
|
|
|
--fish <($out/bin/diesel completions fish) \
|
|
|
|
--zsh <($out/bin/diesel completions zsh)
|
2019-09-01 00:40:47 +01:00
|
|
|
'';
|
|
|
|
|
|
|
|
# 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; [ ];
|
2021-10-08 00:14:24 +01:00
|
|
|
mainProgram = "diesel";
|
2019-09-01 00:40:47 +01:00
|
|
|
};
|
|
|
|
}
|