1{ stdenv
2, lib
3, rustPlatform
4, fetchFromGitHub
5, installShellFiles
6, pkg-config
7, openssl
8, libiconv
9, testers
10, sqlx-cli
11, CoreFoundation
12, Security
13, SystemConfiguration
14}:
15
16rustPlatform.buildRustPackage rec {
17 pname = "sqlx-cli";
18 version = "0.7.1";
19
20 src = fetchFromGitHub {
21 owner = "launchbadge";
22 repo = "sqlx";
23 rev = "v${version}";
24 hash = "sha256-567/uJPQhrNqDqBF/PqklXm2avSjvtQsddjChwUKUCI=";
25 };
26
27 cargoHash = "sha256-X7fLbih1s3sxn8vb2kQeFUKDK2DlC+sjm9ZTwj3FD1Y=";
28
29 doCheck = false;
30 cargoBuildFlags = [ "--package sqlx-cli --no-default-features --features native-tls,postgres,sqlite,mysql,completions" ];
31
32 nativeBuildInputs = [
33 installShellFiles
34 pkg-config
35 ];
36
37 buildInputs =
38 lib.optionals stdenv.isLinux [
39 openssl
40 ] ++
41 lib.optionals stdenv.isDarwin [
42 CoreFoundation
43 Security
44 SystemConfiguration
45 libiconv
46 ];
47
48 postInstall = ''
49 for shell in bash fish zsh; do
50 $out/bin/sqlx completions $shell > sqlx.$shell
51 installShellCompletion sqlx.$shell
52 done
53 '';
54
55 passthru.tests.version = testers.testVersion {
56 package = sqlx-cli;
57 command = "sqlx --version";
58 };
59
60 meta = with lib; {
61 description =
62 "SQLx's associated command-line utility for managing databases, migrations, and enabling offline mode with sqlx::query!() and friends.";
63 homepage = "https://github.com/launchbadge/sqlx";
64 license = licenses.asl20;
65 maintainers = with maintainers; [ greizgh xrelkd fd ];
66 mainProgram = "sqlx";
67 };
68}