1{
2 lib,
3 buildGoModule,
4 fetchFromGitHub,
5 arrow-cpp,
6 duckdb,
7 nix-update-script,
8 stdenv,
9 vimPlugins,
10 vimUtils,
11}:
12let
13 version = "0.1.9";
14 src = fetchFromGitHub {
15 owner = "kndndrj";
16 repo = "nvim-dbee";
17 tag = "v${version}";
18 hash = "sha256-AOime4vG0NFcUvsd9Iw5SxR7WaeCsoCRU6h5+vSkt4M=";
19 };
20 dbee-bin = buildGoModule {
21 pname = "dbee-bin";
22 inherit version;
23
24 inherit src;
25 sourceRoot = "${src.name}/dbee";
26
27 vendorHash = "sha256-U/3WZJ/+Bm0ghjeNUILsnlZnjIwk3ySaX3Rd4L9Z62A=";
28 buildInputs = [
29 arrow-cpp
30 duckdb
31 ];
32
33 # Tests attempt to access `/etc/protocols` which is forbidden in the sandbox
34 doCheck = !stdenv.hostPlatform.isDarwin;
35
36 meta.mainProgram = "dbee";
37 };
38in
39vimUtils.buildVimPlugin {
40 pname = "nvim-dbee";
41 inherit version src;
42
43 postPatch = ''
44 substituteInPlace lua/dbee/install/init.lua \
45 --replace-fail 'return vim.fn.stdpath("data") .. "/dbee/bin"' 'return "${dbee-bin}/bin"'
46 '';
47
48 preFixup = ''
49 mkdir $target/bin
50 ln -s ${lib.getExe dbee-bin} $target/bin/dbee
51 '';
52
53 passthru = {
54 updateScript = nix-update-script {
55 attrPath = "vimPlugins.nvim-dbee.dbee-bin";
56 };
57
58 # needed for the update script
59 inherit dbee-bin;
60 };
61
62 dependencies = [ vimPlugins.nui-nvim ];
63
64 meta = {
65 description = "Interactive database client for neovim";
66 homepage = "https://github.com/kndndrj/nvim-dbee";
67 changelog = "https://github.com/kndndrj/nvim-dbee/releases/tag/v${version}";
68 maintainers = with lib.maintainers; [ perchun ];
69 };
70}