nixpkgs mirror (for testing)
github.com/NixOS/nixpkgs
nix
1{
2 stdenv,
3 lib,
4 fetchurl,
5 autoPatchelfHook,
6 libxcrypt-legacy,
7 makeBinaryWrapper,
8 pgsql-tools,
9}:
10
11stdenv.mkDerivation (finalAttrs: {
12 pname = "pgsql-tools";
13 version = "2.1.0";
14
15 src = fetchurl (
16 let
17 sources = {
18 x86_64-linux = {
19 url = "https://github.com/microsoft/pgsql-tools/releases/download/v${finalAttrs.version}/pgsqltoolsservice-linux-x64.tar.gz";
20 hash = "sha256-dN7+LJCUwb39ypuJV4p3jUHNGAPaObN4aZvsOHIpmkQ=";
21 };
22 aarch64-linux = {
23 url = "https://github.com/microsoft/pgsql-tools/releases/download/v${finalAttrs.version}/pgsqltoolsservice-linux-arm64.tar.gz";
24 hash = "sha256-rD8jymGdM1RDGDbrKu6E7xoWtSMRNuc2ngCmR+sHgQI=";
25 };
26 x86_64-darwin = {
27 url = "https://github.com/microsoft/pgsql-tools/releases/download/v${finalAttrs.version}/pgsqltoolsservice-osx-x86.tar.gz";
28 hash = "sha256-KLl7HPChurzB6QYV6AqAP3g1J3VKl61+we3opzJQwG0=";
29 };
30 aarch64-darwin = {
31 url = "https://github.com/microsoft/pgsql-tools/releases/download/v${finalAttrs.version}/pgsqltoolsservice-osx-arm64.tar.gz";
32 hash = "sha256-tpabEKB1kqse7D58FsP/9jywk+vgAAvptL9MadwxWg8=";
33 };
34 };
35 in
36 sources.${stdenv.hostPlatform.system}
37 );
38
39 nativeBuildInputs = [
40 makeBinaryWrapper
41 ]
42 ++ lib.optionals stdenv.isLinux [
43 autoPatchelfHook
44 ];
45
46 buildInputs = lib.optionals stdenv.isLinux [
47 libxcrypt-legacy
48 (lib.getLib stdenv.cc.cc)
49 ];
50
51 dontBuild = true;
52 dontStrip = true;
53
54 installPhase = ''
55 runHook preInstall
56
57 mkdir -p $out/bin $out/lib/pgsql-tools
58 install -Dm755 ossdbtoolsservice_main $out/lib/pgsql-tools/ossdbtoolsservice_main
59 cp -r _internal $out/lib/pgsql-tools/
60
61 makeBinaryWrapper $out/lib/pgsql-tools/ossdbtoolsservice_main $out/bin/ossdbtoolsservice_main \
62 ${lib.optionalString stdenv.isLinux ''--prefix LD_LIBRARY_PATH : "${
63 lib.makeLibraryPath [
64 libxcrypt-legacy
65 (lib.getLib stdenv.cc.cc)
66 ]
67 }"''} \
68 --chdir $out/lib/pgsql-tools
69
70 runHook postInstall
71 '';
72
73 doInstallCheck = true;
74
75 passthru = {
76 updateScript = ./update.sh;
77 };
78
79 meta = {
80 homepage = "https://github.com/microsoft/pgsql-tools";
81 description = "Backend service for PostgreSQL server tools, offering features such as connection management, query execution with result set handling, and language service support via the VS Code protocol";
82 changelog = "https://github.com/microsoft/pgsql-tools/releases/tag/v${finalAttrs.version}";
83 license = lib.licenses.mit;
84 platforms = lib.platforms.linux ++ lib.platforms.darwin;
85 maintainers = with lib.maintainers; [ liberodark ];
86 mainProgram = "ossdbtoolsservice_main";
87 sourceProvenance = with lib.sourceTypes; [ binaryNativeCode ];
88 };
89})