1{ stdenv
2, lib
3, rustPlatform
4, fetchFromGitHub
5, fetchpatch
6, pkg-config
7, openssl
8, SystemConfiguration
9, CoreFoundation
10, Security
11, libiconv
12, testers
13, sqlx-cli
14}:
15
16rustPlatform.buildRustPackage rec {
17 pname = "sqlx-cli";
18 version = "0.6.2";
19
20 src = fetchFromGitHub {
21 owner = "launchbadge";
22 repo = "sqlx";
23 rev = "v${version}";
24 sha256 = "sha256-pQlrKjhOJfjNEmLxqnFmmBY1naheZUsaq2tGdLKGxjg=";
25 };
26
27 patches = [
28 # https://github.com/launchbadge/sqlx/pull/2228
29 (fetchpatch {
30 name = "fix-rust-1.65-compile.patch";
31 url = "https://github.com/launchbadge/sqlx/commit/2fdf85b212332647dc4ac47e087df946151feedf.patch";
32 hash = "sha256-5BCuIwmECe9qQrdYll7T+UOGwuTBolWEhKNE7GcZqJw=";
33 })
34 ];
35
36 cargoSha256 = "sha256-AbA8L7rkyZfKW0vvjyrcW5eU6jGD+zAqIcEUOJmeqJs=";
37
38 doCheck = false;
39 cargoBuildFlags = [ "-p sqlx-cli" ];
40
41 nativeBuildInputs = [ pkg-config ];
42 buildInputs = lib.optionals stdenv.isLinux [ openssl ]
43 ++ lib.optionals stdenv.isDarwin [ SystemConfiguration CoreFoundation Security libiconv ];
44
45 passthru.tests.version = testers.testVersion {
46 package = sqlx-cli;
47 command = "sqlx --version";
48 };
49
50 meta = with lib; {
51 description =
52 "SQLx's associated command-line utility for managing databases, migrations, and enabling offline mode with sqlx::query!() and friends.";
53 homepage = "https://github.com/launchbadge/sqlx";
54 license = licenses.asl20;
55 maintainers = with maintainers; [ greizgh ];
56 };
57}