mirror of
https://github.com/NixOS/nixpkgs.git
synced 2024-12-24 14:43:37 +00:00
eb11feaa0b
Changes the default fetcher in the Rust Platform to be the newer `fetchCargoTarball`, and changes every application using the current default to instead opt out. This commit does not change any hashes or cause any rebuilds. Once integrated, we will start deleting the opt-outs and recomputing hashes. See #79975 for details.
81 lines
2.6 KiB
Nix
81 lines
2.6 KiB
Nix
{ stdenv, lib, rustPlatform, fetchFromGitHub, openssl, pkgconfig, Security
|
|
, 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
|
|
inherit (stdenv.lib) optional optionals optionalString;
|
|
features = ''
|
|
${optionalString sqliteSupport "sqlite"} \
|
|
${optionalString postgresqlSupport "postgres"} \
|
|
${optionalString mysqlSupport "mysql"} \
|
|
'';
|
|
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
|
|
];
|
|
|
|
cargoBuildFlags = [ "--no-default-features --features \"${features}\"" ];
|
|
cargoPatches = [ ./cargo-lock.patch ];
|
|
# Delete this on next update; see #79975 for details
|
|
legacyCargoFetcher = true;
|
|
|
|
cargoSha256 = "0xlcskddhy7xsiwj54gmn1xlgkfxb4dwrys7rbamfz1h8aa6ixjx";
|
|
|
|
nativeBuildInputs = [ pkgconfig ];
|
|
buildInputs = [ openssl ]
|
|
++ optional stdenv.isDarwin Security
|
|
++ optional (stdenv.isDarwin && mysqlSupport) libiconv
|
|
++ optional sqliteSupport sqlite
|
|
++ optional postgresqlSupport postgresql
|
|
++ optionals mysqlSupport [ mysql zlib ];
|
|
|
|
# We must `cd diesel_cli`, we cannot use `--package diesel_cli` to build
|
|
# because --features fails to apply to the package:
|
|
# https://github.com/rust-lang/cargo/issues/5015
|
|
# https://github.com/rust-lang/cargo/issues/4753
|
|
preBuild = "cd diesel_cli";
|
|
postBuild = "cd ..";
|
|
|
|
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 = lib.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 ];
|
|
platforms = platforms.all;
|
|
maintainers = with maintainers; [ ];
|
|
};
|
|
}
|