nixpkgs mirror (for testing)
github.com/NixOS/nixpkgs
nix
1{
2 lib,
3 fetchFromGitHub,
4 nix-update-script,
5 openssl,
6 pkg-config,
7 rustPlatform,
8 vimPlugins,
9 vimUtils,
10}:
11let
12 version = "1.1.0-unstable-2025-01-21";
13 src = fetchFromGitHub {
14 owner = "sourcegraph";
15 repo = "sg.nvim";
16 rev = "775f22b75a9826eabf69b0094dd1d51d619fe552";
17 hash = "sha256-i5g+pzxB8pAORLbr1wlYWUTsrJJmVj9UwlCg8pU3Suw=";
18 };
19
20 sg-nvim-rust = rustPlatform.buildRustPackage {
21 pname = "sg-nvim-rust";
22 inherit version src;
23
24 cargoHash = "sha256-yY/5w2ztmTKJAYDxBJND8itCOwRNi1negiFq3PyFaSM=";
25
26 nativeBuildInputs = [ pkg-config ];
27
28 buildInputs = [ openssl ];
29
30 prePatch = ''
31 rm .cargo/config.toml
32 '';
33
34 env.OPENSSL_NO_VENDOR = true;
35
36 cargoBuildFlags = [ "--workspace" ];
37
38 # tests are broken
39 doCheck = false;
40 };
41in
42vimUtils.buildVimPlugin {
43 pname = "sg.nvim";
44 inherit version src;
45
46 checkInputs = with vimPlugins; [
47 telescope-nvim
48 nvim-cmp
49 ];
50
51 dependencies = [ vimPlugins.plenary-nvim ];
52
53 postInstall = ''
54 mkdir -p $out/target/debug
55 ln -s ${sg-nvim-rust}/{bin,lib}/* $out/target/debug
56 '';
57
58 nvimSkipModules = [
59 # Dependent on active fuzzy search state
60 "sg.cody.fuzzy"
61 ];
62
63 passthru = {
64 updateScript = nix-update-script {
65 extraArgs = [ "--version=branch" ];
66 attrPath = "vimPlugins.sg-nvim.sg-nvim-rust";
67 };
68
69 # needed for the update script
70 inherit sg-nvim-rust;
71 };
72
73 meta = {
74 description = "Neovim plugin designed to emulate the behaviour of the Cursor AI IDE";
75 homepage = "https://github.com/sourcegraph/sg.nvim/";
76 license = lib.licenses.asl20;
77 };
78}