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";
|
2021-03-29 18:03:58 +01:00
|
|
|
version = "1.4.1";
|
2019-09-01 00:40:47 +01:00
|
|
|
|
|
|
|
src = fetchFromGitHub {
|
|
|
|
owner = "diesel-rs";
|
|
|
|
repo = "diesel";
|
2021-03-29 18:03:58 +01:00
|
|
|
# diesel and diesel_cli are independently versioned. diesel_cli
|
|
|
|
# 1.4.1 first became available in diesel 1.4.5, but we can use
|
|
|
|
# a newer diesel tag.
|
|
|
|
rev = "v1.4.6";
|
|
|
|
sha256 = "0c8a2f250mllzpr20j7j0msbf2csjf9dj8g7j6cl04ifdg7gwb9z";
|
2019-09-01 00:40:47 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
patches = [
|
2021-03-29 18:03:58 +01:00
|
|
|
# Fixes:
|
|
|
|
# Compiling diesel v1.4.6 (/build/source/diesel)
|
|
|
|
# error: this `#[deprecated]` annotation has no effect
|
|
|
|
# --> diesel/src/query_builder/insert_statement/mod.rs:205:1
|
|
|
|
# |
|
|
|
|
# 205 | / #[deprecated(
|
|
|
|
# 206 | | since = "1.2.0",
|
|
|
|
# 207 | | note = "Use `<&'a [U] as Insertable<T>>::Values` instead"
|
|
|
|
# 208 | | )]
|
|
|
|
# | |__^ help: remove the unnecessary deprecation attribute
|
|
|
|
# |
|
|
|
|
# = note: `#[deny(useless_deprecated)]` on by default
|
|
|
|
./fix-deprecated.patch
|
2019-09-01 00:40:47 +01:00
|
|
|
];
|
|
|
|
|
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 ];
|
2021-03-29 18:03:58 +01:00
|
|
|
cargoSha256 = "1vkwp861vm20agj0lkhnnxgg4vwg4d5clvvyzxrmm4y4yw46cdl2";
|
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
|
|
|
};
|
|
|
|
}
|