2021-10-08 15:17:17 +00:00
|
|
|
{ lib
|
|
|
|
, sqliteSupport ? true
|
|
|
|
, postgresqlSupport ? true
|
|
|
|
, mysqlSupport ? true
|
|
|
|
, rustPlatform
|
|
|
|
, fetchCrate
|
|
|
|
, installShellFiles
|
|
|
|
, pkg-config
|
|
|
|
, openssl
|
|
|
|
, stdenv
|
|
|
|
, Security
|
|
|
|
, libiconv
|
|
|
|
, sqlite
|
|
|
|
, postgresql
|
|
|
|
, mariadb
|
|
|
|
, zlib
|
2020-04-24 23:36:52 +00:00
|
|
|
}:
|
|
|
|
|
|
|
|
assert lib.assertMsg (sqliteSupport == true || postgresqlSupport == true || mysqlSupport == true)
|
|
|
|
"support for at least one database must be enabled";
|
|
|
|
|
|
|
|
let
|
2021-02-05 17:12:51 +00:00
|
|
|
inherit (lib) optional optionals optionalString;
|
2020-04-24 23:36:52 +00:00
|
|
|
in
|
|
|
|
|
|
|
|
rustPlatform.buildRustPackage rec {
|
|
|
|
pname = "diesel-cli";
|
2022-09-09 14:08:57 +00:00
|
|
|
version = "2.0.0";
|
2020-04-24 23:36:52 +00:00
|
|
|
|
2021-10-08 15:17:17 +00:00
|
|
|
src = fetchCrate {
|
|
|
|
inherit version;
|
|
|
|
crateName = "diesel_cli";
|
2022-09-09 14:08:57 +00:00
|
|
|
sha256 = "sha256-PBfVLqm9vEbf1tDTx4v8U1amYwC0hpYTAYcWyfHB84g=";
|
2020-04-24 23:36:52 +00:00
|
|
|
};
|
|
|
|
|
2022-09-09 14:08:57 +00:00
|
|
|
cargoSha256 = "sha256-8bvJwdZEdIChFUdTVL+EyjzqI+OAJaVMOOyspReSFzc=";
|
2020-04-24 23:36:52 +00:00
|
|
|
|
2021-10-08 15:17:17 +00:00
|
|
|
nativeBuildInputs = [ installShellFiles pkg-config ];
|
2021-03-09 03:18:52 +00:00
|
|
|
|
2020-04-24 23:36:52 +00:00
|
|
|
buildInputs = [ openssl ]
|
|
|
|
++ optional stdenv.isDarwin Security
|
|
|
|
++ optional (stdenv.isDarwin && mysqlSupport) libiconv
|
|
|
|
++ optional sqliteSupport sqlite
|
|
|
|
++ optional postgresqlSupport postgresql
|
2021-04-05 15:23:46 +00:00
|
|
|
++ optionals mysqlSupport [ mariadb zlib ];
|
2020-04-24 23:36:52 +00:00
|
|
|
|
2021-12-06 16:07:01 +00:00
|
|
|
buildNoDefaultFeatures = true;
|
|
|
|
buildFeatures = optional sqliteSupport "sqlite"
|
|
|
|
++ optional postgresqlSupport "postgres"
|
|
|
|
++ optional mysqlSupport "mysql";
|
|
|
|
|
2021-10-08 15:17:17 +00:00
|
|
|
checkPhase = ''
|
|
|
|
runHook preCheck
|
|
|
|
'' + optionalString sqliteSupport ''
|
|
|
|
cargo check --features sqlite
|
|
|
|
'' + optionalString postgresqlSupport ''
|
|
|
|
cargo check --features postgres
|
|
|
|
'' + optionalString mysqlSupport ''
|
|
|
|
cargo check --features mysql
|
|
|
|
'' + ''
|
|
|
|
runHook postCheck
|
2020-04-24 23:36:52 +00:00
|
|
|
'';
|
|
|
|
|
2021-10-08 15:17:17 +00:00
|
|
|
postInstall = ''
|
|
|
|
installShellCompletion --cmd diesel \
|
|
|
|
--bash <($out/bin/diesel completions bash) \
|
|
|
|
--fish <($out/bin/diesel completions fish) \
|
|
|
|
--zsh <($out/bin/diesel completions zsh)
|
2020-04-24 23:36:52 +00:00
|
|
|
'';
|
|
|
|
|
|
|
|
# Fix the build with mariadb, which otherwise shows "error adding symbols:
|
|
|
|
# DSO missing from command line" errors for libz and libssl.
|
2021-03-09 03:18:52 +00:00
|
|
|
NIX_LDFLAGS = optionalString mysqlSupport "-lz -lssl -lcrypto";
|
2020-04-24 23:36:52 +00:00
|
|
|
|
|
|
|
meta = with lib; {
|
|
|
|
description = "Database tool for working with Rust projects that use Diesel";
|
|
|
|
homepage = "https://github.com/diesel-rs/diesel/tree/master/diesel_cli";
|
|
|
|
license = with licenses; [ mit asl20 ];
|
|
|
|
maintainers = with maintainers; [ ];
|
2021-10-08 15:17:17 +00:00
|
|
|
mainProgram = "diesel";
|
2020-04-24 23:36:52 +00:00
|
|
|
};
|
|
|
|
}
|