at 23.11-beta 82 lines 2.2 kB view raw
1{ lib 2, sqliteSupport ? true 3, postgresqlSupport ? true 4, mysqlSupport ? true 5, rustPlatform 6, fetchCrate 7, installShellFiles 8, pkg-config 9, openssl 10, stdenv 11, Security 12, libiconv 13, sqlite 14, postgresql 15, mariadb 16, zlib 17}: 18 19assert lib.assertMsg (sqliteSupport == true || postgresqlSupport == true || mysqlSupport == true) 20 "support for at least one database must be enabled"; 21 22let 23 inherit (lib) optional optionals optionalString; 24in 25 26rustPlatform.buildRustPackage rec { 27 pname = "diesel-cli"; 28 version = "2.1.1"; 29 30 src = fetchCrate { 31 inherit version; 32 crateName = "diesel_cli"; 33 hash = "sha256-fpvC9C30DJy5ih+sFTTMoiykUHqG6OzDhF9jvix1Ctg="; 34 }; 35 36 cargoHash = "sha256-nPmUCww8sOJwnG7+uIflLPgT87xPX0s7g0AcuDKhY2I="; 37 38 nativeBuildInputs = [ installShellFiles pkg-config ]; 39 40 buildInputs = [ openssl ] 41 ++ optional stdenv.isDarwin Security 42 ++ optional (stdenv.isDarwin && mysqlSupport) libiconv 43 ++ optional sqliteSupport sqlite 44 ++ optional postgresqlSupport postgresql 45 ++ optionals mysqlSupport [ mariadb zlib ]; 46 47 buildNoDefaultFeatures = true; 48 buildFeatures = optional sqliteSupport "sqlite" 49 ++ optional postgresqlSupport "postgres" 50 ++ optional mysqlSupport "mysql"; 51 52 checkPhase = '' 53 runHook preCheck 54 '' + optionalString sqliteSupport '' 55 cargo check --features sqlite 56 '' + optionalString postgresqlSupport '' 57 cargo check --features postgres 58 '' + optionalString mysqlSupport '' 59 cargo check --features mysql 60 '' + '' 61 runHook postCheck 62 ''; 63 64 postInstall = '' 65 installShellCompletion --cmd diesel \ 66 --bash <($out/bin/diesel completions bash) \ 67 --fish <($out/bin/diesel completions fish) \ 68 --zsh <($out/bin/diesel completions zsh) 69 ''; 70 71 # Fix the build with mariadb, which otherwise shows "error adding symbols: 72 # DSO missing from command line" errors for libz and libssl. 73 NIX_LDFLAGS = optionalString mysqlSupport "-lz -lssl -lcrypto"; 74 75 meta = with lib; { 76 description = "Database tool for working with Rust projects that use Diesel"; 77 homepage = "https://github.com/diesel-rs/diesel/tree/master/diesel_cli"; 78 license = with licenses; [ mit asl20 ]; 79 maintainers = with maintainers; [ ]; 80 mainProgram = "diesel"; 81 }; 82}