Clone of https://github.com/NixOS/nixpkgs.git (to stress-test knotserver)
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.0.1"; 29 30 src = fetchCrate { 31 inherit version; 32 crateName = "diesel_cli"; 33 sha256 = "sha256-IHxK5hI0RYNFQQe/Kfao0Zw8L3bs1gdN1xwmO4kKi08="; 34 }; 35 36 cargoSha256 = "sha256-KoTeDzUk/KbUx+4NLVifX3yehm4V13LJ/YUmzoUSuDM="; 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}