evcc: 0.131.4 -> 0.131.5
[NixPkgs.git] / pkgs / by-name / di / diesel-cli / package.nix
blob04f61006159997f22e50f6f700a9d41b610c7e20
2   lib,
3   stdenv,
4   fetchCrate,
5   rustPlatform,
6   installShellFiles,
7   darwin,
8   libiconv,
9   libmysqlclient,
10   nix-update-script,
11   openssl,
12   pkg-config,
13   postgresql,
14   sqlite,
15   testers,
16   zlib,
17   diesel-cli,
18   sqliteSupport ? true,
19   postgresqlSupport ? true,
20   mysqlSupport ? true,
22 assert lib.assertMsg (lib.elem true [
23   postgresqlSupport
24   mysqlSupport
25   sqliteSupport
26 ]) "support for at least one database must be enabled";
28 rustPlatform.buildRustPackage rec {
29   pname = "diesel-cli";
30   version = "2.2.4";
32   src = fetchCrate {
33     inherit version;
34     crateName = "diesel_cli";
35     hash = "sha256-kTwAG1B4gy+1jj5ar5RkmIUMAO9wYsG7QnMcZii/OZk=";
36   };
38   cargoHash = "sha256-qcyNFuKJldHVJDAye4K1rHPf/SvpZ+BmqBast1vh/3Q=";
40   nativeBuildInputs = [
41     installShellFiles
42     pkg-config
43   ];
45   buildInputs =
46     [ openssl ]
47     ++ lib.optional stdenv.hostPlatform.isDarwin darwin.apple_sdk.frameworks.Security
48     ++ lib.optional (stdenv.hostPlatform.isDarwin && mysqlSupport) libiconv
49     ++ lib.optional sqliteSupport sqlite
50     ++ lib.optional postgresqlSupport postgresql
51     ++ lib.optionals mysqlSupport [
52       libmysqlclient
53       zlib
54     ];
56   buildNoDefaultFeatures = true;
57   buildFeatures =
58     lib.optional sqliteSupport "sqlite"
59     ++ lib.optional postgresqlSupport "postgres"
60     ++ lib.optional mysqlSupport "mysql";
62   checkFlags = [
63     # all of these require a live database to be running
64     # `DATABASE_URL must be set in order to run tests: NotPresent`
65     "--skip=infer_schema_internals::information_schema::tests::get_primary_keys_only_includes_primary_key"
66     "--skip=infer_schema_internals::information_schema::tests::load_table_names_loads_from_custom_schema"
67     "--skip=infer_schema_internals::information_schema::tests::load_table_names_loads_from_public_schema_if_none_given"
68     "--skip=infer_schema_internals::information_schema::tests::load_table_names_output_is_ordered"
69     "--skip=infer_schema_internals::information_schema::tests::skip_views"
70     "--skip=infer_schema_internals::mysql::test::get_table_data_loads_column_information"
71     "--skip=infer_schema_internals::mysql::test::gets_table_comment"
72     "--skip=infer_schema_internals::pg::test::get_foreign_keys_loads_foreign_keys"
73     "--skip=infer_schema_internals::pg::test::get_foreign_keys_loads_foreign_keys_with_same_name"
74     "--skip=infer_schema_internals::pg::test::get_table_data_loads_column_information"
75     "--skip=infer_schema_internals::pg::test::gets_table_comment"
76   ];
77   cargoCheckFeatures = buildFeatures;
79   # Tests currently fail due to *many* duplicate definition errors
80   doCheck = false;
82   postInstall = lib.optionalString (stdenv.buildPlatform.canExecute stdenv.hostPlatform) ''
83     installShellCompletion --cmd diesel \
84       --bash <($out/bin/diesel completions bash) \
85       --fish <($out/bin/diesel completions fish) \
86       --zsh <($out/bin/diesel completions zsh)
87   '';
89   # Fix the build with mariadb, which otherwise shows "error adding symbols:
90   # DSO missing from command line" errors for libz and libssl.
91   env.NIX_LDFLAGS = lib.optionalString mysqlSupport "-lz -lssl -lcrypto";
93   passthru = {
94     tests.version = testers.testVersion { package = diesel-cli; };
95     updateScript = nix-update-script { };
96   };
98   meta = {
99     description = "Database tool for working with Rust projects that use Diesel";
100     homepage = "https://diesel.rs";
101     changelog = "https://github.com/diesel-rs/diesel/releases/tag/v${version}";
102     license = with lib.licenses; [
103       mit
104       asl20
105     ];
106     maintainers = with lib.maintainers; [ getchoo ];
107     mainProgram = "diesel";
108   };