2022-12-17 10:02:37 +00:00
|
|
|
{ stdenv
|
|
|
|
, lib
|
|
|
|
, rustPlatform
|
|
|
|
, fetchFromGitHub
|
2023-08-04 22:07:22 +00:00
|
|
|
, installShellFiles
|
2022-12-17 10:02:37 +00:00
|
|
|
, pkg-config
|
2023-10-09 19:29:22 +00:00
|
|
|
, openssl
|
2022-12-17 10:02:37 +00:00
|
|
|
, libiconv
|
|
|
|
, testers
|
|
|
|
, sqlx-cli
|
2023-08-04 22:07:22 +00:00
|
|
|
, CoreFoundation
|
|
|
|
, Security
|
|
|
|
, SystemConfiguration
|
2022-12-17 10:02:37 +00:00
|
|
|
}:
|
2021-02-05 17:12:51 +00:00
|
|
|
|
|
|
|
rustPlatform.buildRustPackage rec {
|
|
|
|
pname = "sqlx-cli";
|
2024-01-13 08:15:51 +00:00
|
|
|
version = "0.7.3";
|
2021-02-05 17:12:51 +00:00
|
|
|
|
|
|
|
src = fetchFromGitHub {
|
|
|
|
owner = "launchbadge";
|
|
|
|
repo = "sqlx";
|
|
|
|
rev = "v${version}";
|
2024-01-13 08:15:51 +00:00
|
|
|
hash = "sha256-AKVNyuV9jwzmsy6tHkGkLj1fhVT8XYvEn2Ip2wCKDxI=";
|
2021-02-05 17:12:51 +00:00
|
|
|
};
|
|
|
|
|
2024-01-13 08:15:51 +00:00
|
|
|
cargoHash = "sha256-F3FLu/n57F8psk+d0Hf+HnqV/DvEFQwRefu/4C8A1sU=";
|
|
|
|
|
|
|
|
# Prepare the Cargo.lock for offline use.
|
|
|
|
# See https://github.com/NixOS/nixpkgs/issues/261412
|
|
|
|
postConfigure = ''
|
|
|
|
cargo metadata --offline > /dev/null
|
|
|
|
'';
|
|
|
|
|
|
|
|
buildNoDefaultFeatures = true;
|
|
|
|
buildFeatures = [
|
|
|
|
"native-tls"
|
|
|
|
"postgres"
|
|
|
|
"sqlite"
|
|
|
|
"mysql"
|
|
|
|
"completions"
|
|
|
|
];
|
2021-02-05 17:12:51 +00:00
|
|
|
|
|
|
|
doCheck = false;
|
2024-01-13 08:15:51 +00:00
|
|
|
cargoBuildFlags = [ "--package sqlx-cli" ];
|
2023-08-04 22:07:22 +00:00
|
|
|
|
|
|
|
nativeBuildInputs = [
|
|
|
|
installShellFiles
|
|
|
|
pkg-config
|
|
|
|
];
|
|
|
|
|
2023-10-09 19:29:22 +00:00
|
|
|
buildInputs =
|
|
|
|
lib.optionals stdenv.isLinux [
|
|
|
|
openssl
|
|
|
|
] ++
|
|
|
|
lib.optionals stdenv.isDarwin [
|
|
|
|
CoreFoundation
|
|
|
|
Security
|
|
|
|
SystemConfiguration
|
|
|
|
libiconv
|
|
|
|
];
|
2021-02-05 17:12:51 +00:00
|
|
|
|
2023-08-04 22:07:22 +00:00
|
|
|
postInstall = ''
|
|
|
|
for shell in bash fish zsh; do
|
|
|
|
$out/bin/sqlx completions $shell > sqlx.$shell
|
|
|
|
installShellCompletion sqlx.$shell
|
|
|
|
done
|
|
|
|
'';
|
2021-02-05 17:12:51 +00:00
|
|
|
|
2022-06-16 17:23:12 +00:00
|
|
|
passthru.tests.version = testers.testVersion {
|
|
|
|
package = sqlx-cli;
|
|
|
|
command = "sqlx --version";
|
|
|
|
};
|
|
|
|
|
2021-02-05 17:12:51 +00:00
|
|
|
meta = with lib; {
|
|
|
|
description =
|
|
|
|
"SQLx's associated command-line utility for managing databases, migrations, and enabling offline mode with sqlx::query!() and friends.";
|
|
|
|
homepage = "https://github.com/launchbadge/sqlx";
|
|
|
|
license = licenses.asl20;
|
2023-08-04 22:07:22 +00:00
|
|
|
maintainers = with maintainers; [ greizgh xrelkd fd ];
|
2023-08-22 20:05:09 +00:00
|
|
|
mainProgram = "sqlx";
|
2021-02-05 17:12:51 +00:00
|
|
|
};
|
|
|
|
}
|