1
0
Fork 1
mirror of https://github.com/NixOS/nixpkgs.git synced 2024-12-25 03:17:13 +00:00
nixpkgs/pkgs/development/tools/diesel-cli/default.nix
Daniël de Kok 85f96822a0 treewide: fix cargoSha256/cargoHash
Rust 1.50.0 incorporated a Cargo change (rust-lang/cargo#8937) in
which cargo vendor erroneously changed permissions of vendored
crates. This was fixed in Rust
1.51.0 (rust-lang/cargo#9131). Unfortunately, this means that all
cargoSha256/cargoHashes produced during the Rust 1.50.0 cycle are
potentially broken.

This change updates cargoSha256/cargoHash tree-wide.

Fixes #121994.
2021-05-08 00:36:37 -07:00

82 lines
2.7 KiB
Nix

{ stdenv, lib, rustPlatform, fetchFromGitHub, openssl, pkg-config, Security
, sqliteSupport ? true, sqlite
, postgresqlSupport ? true, postgresql
, mysqlSupport ? true, mariadb, zlib, libiconv
}:
assert lib.assertMsg (sqliteSupport == true || postgresqlSupport == true || mysqlSupport == true)
"support for at least one database must be enabled";
let
inherit (lib) optional optionals optionalString;
features = optional sqliteSupport "sqlite"
++ optional postgresqlSupport "postgres"
++ optional mysqlSupport "mysql";
in
rustPlatform.buildRustPackage rec {
pname = "diesel-cli";
version = "1.4.1";
src = fetchFromGitHub {
owner = "diesel-rs";
repo = "diesel";
# 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";
};
patches = [
# 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
];
cargoBuildFlags = [ "--no-default-features" "--features" "${lib.concatStringsSep "," features}" ];
cargoPatches = [ ./cargo-lock.patch ];
cargoSha256 = "060r90dvdi0s5v3kjagsrrdb4arzzbkin8v5563rdpv0sq1pi3bm";
nativeBuildInputs = [ pkg-config ];
buildInputs = [ openssl ]
++ optional stdenv.isDarwin Security
++ optional (stdenv.isDarwin && mysqlSupport) libiconv
++ optional sqliteSupport sqlite
++ optional postgresqlSupport postgresql
++ optionals mysqlSupport [ mariadb zlib ];
buildAndTestSubdir = "diesel_cli";
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.
NIX_LDFLAGS = optionalString mysqlSupport "-lz -lssl -lcrypto";
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; [ ];
};
}