refactor: use wrapper from nixpkgs instead of custom one

This commit is contained in:
Guz
2025-03-04 15:43:49 -03:00
parent 7352d5ff2b
commit 060dc31e4d
4 changed files with 129 additions and 468 deletions

241
flake.lock generated
View File

@@ -1,79 +1,5 @@
{
"nodes": {
"flake-compat": {
"flake": false,
"locked": {
"lastModified": 1733328505,
"narHash": "sha256-NeCCThCEP3eCl2l/+27kNNK7QrwZB1IJCrXfrbv5oqU=",
"owner": "edolstra",
"repo": "flake-compat",
"rev": "ff81ac966bb2cae68946d5ed5fc4994f96d0ffec",
"type": "github"
},
"original": {
"owner": "edolstra",
"repo": "flake-compat",
"type": "github"
}
},
"flake-compat_2": {
"flake": false,
"locked": {
"lastModified": 1696426674,
"narHash": "sha256-kvjfFW7WAETZlt09AgDn1MrtKzP7t90Vf7vypd3OL1U=",
"owner": "edolstra",
"repo": "flake-compat",
"rev": "0f9255e01c2351cc7d116c072cb317785dd33b33",
"type": "github"
},
"original": {
"owner": "edolstra",
"repo": "flake-compat",
"type": "github"
}
},
"flake-parts": {
"inputs": {
"nixpkgs-lib": [
"neovim-nightly-overlay",
"nixpkgs"
]
},
"locked": {
"lastModified": 1740872218,
"narHash": "sha256-ZaMw0pdoUKigLpv9HiNDH2Pjnosg7NBYMJlHTIsHEUo=",
"owner": "hercules-ci",
"repo": "flake-parts",
"rev": "3876f6b87db82f33775b1ef5ea343986105db764",
"type": "github"
},
"original": {
"owner": "hercules-ci",
"repo": "flake-parts",
"type": "github"
}
},
"flake-parts_2": {
"inputs": {
"nixpkgs-lib": [
"neovim-nightly-overlay",
"hercules-ci-effects",
"nixpkgs"
]
},
"locked": {
"lastModified": 1738453229,
"narHash": "sha256-7H9XgNiGLKN1G1CgRh0vUL4AheZSYzPm+zmZ7vxbJdo=",
"owner": "hercules-ci",
"repo": "flake-parts",
"rev": "32ea77a06711b758da0ad9bd6a844c5740a87abd",
"type": "github"
},
"original": {
"id": "flake-parts",
"type": "indirect"
}
},
"flake-utils": {
"inputs": {
"systems": "systems"
@@ -92,55 +18,12 @@
"type": "github"
}
},
"git-hooks": {
"inputs": {
"flake-compat": "flake-compat_2",
"gitignore": "gitignore",
"nixpkgs": [
"neovim-nightly-overlay",
"nixpkgs"
]
},
"locked": {
"lastModified": 1740870877,
"narHash": "sha256-LWDIJvKWMW0tiih1jTcAK0ncTi3S9IF3gOhpCT1ydik=",
"owner": "cachix",
"repo": "git-hooks.nix",
"rev": "25d4946dfc2021584f5bde1fbd2aa97353384a95",
"type": "github"
},
"original": {
"owner": "cachix",
"repo": "git-hooks.nix",
"type": "github"
}
},
"gitignore": {
"inputs": {
"nixpkgs": [
"neovim-nightly-overlay",
"git-hooks",
"nixpkgs"
]
},
"locked": {
"lastModified": 1709087332,
"narHash": "sha256-HG2cCnktfHsKV0s4XW83gU3F57gaTljL9KNSuG6bnQs=",
"owner": "hercules-ci",
"repo": "gitignore.nix",
"rev": "637db329424fd7e46cf4185293b9cc8c88c95394",
"type": "github"
},
"original": {
"owner": "hercules-ci",
"repo": "gitignore.nix",
"type": "github"
}
},
"go-grip": {
"inputs": {
"flake-utils": "flake-utils",
"nixpkgs": "nixpkgs"
"nixpkgs": [
"nixpkgs"
]
},
"locked": {
"lastModified": 1733732005,
@@ -156,101 +39,7 @@
"type": "github"
}
},
"hercules-ci-effects": {
"inputs": {
"flake-parts": "flake-parts_2",
"nixpkgs": [
"neovim-nightly-overlay",
"nixpkgs"
]
},
"locked": {
"lastModified": 1739595404,
"narHash": "sha256-0CjCfbq0yHWexOrpO06e2WU1r5JAqR6ffy1zgM3NksI=",
"owner": "hercules-ci",
"repo": "hercules-ci-effects",
"rev": "06519cec8fb32d219006da6eacd255504a9996af",
"type": "github"
},
"original": {
"owner": "hercules-ci",
"repo": "hercules-ci-effects",
"type": "github"
}
},
"neovim-nightly-overlay": {
"inputs": {
"flake-compat": "flake-compat",
"flake-parts": "flake-parts",
"git-hooks": "git-hooks",
"hercules-ci-effects": "hercules-ci-effects",
"neovim-src": "neovim-src",
"nixpkgs": "nixpkgs_2",
"treefmt-nix": "treefmt-nix"
},
"locked": {
"lastModified": 1740874225,
"narHash": "sha256-sdBT6Njf1MDVnb4kLbGhCpXQ2P7E+50TRW1mIdujFEE=",
"owner": "nix-community",
"repo": "neovim-nightly-overlay",
"rev": "ee3854351ae89ad79eb148d4253263aeaa936913",
"type": "github"
},
"original": {
"owner": "nix-community",
"repo": "neovim-nightly-overlay",
"type": "github"
}
},
"neovim-src": {
"flake": false,
"locked": {
"lastModified": 1740870130,
"narHash": "sha256-nrKnJhmplq4QMcenY/bpD6SHOsiN3VS2toUtsO9NfII=",
"owner": "neovim",
"repo": "neovim",
"rev": "13513835798c732554de277229d4c6744df11502",
"type": "github"
},
"original": {
"owner": "neovim",
"repo": "neovim",
"type": "github"
}
},
"nixpkgs": {
"locked": {
"lastModified": 1728241625,
"narHash": "sha256-yumd4fBc/hi8a9QgA9IT8vlQuLZ2oqhkJXHPKxH/tRw=",
"owner": "nixos",
"repo": "nixpkgs",
"rev": "c31898adf5a8ed202ce5bea9f347b1c6871f32d1",
"type": "github"
},
"original": {
"owner": "nixos",
"ref": "nixos-unstable",
"repo": "nixpkgs",
"type": "github"
}
},
"nixpkgs_2": {
"locked": {
"lastModified": 1740791350,
"narHash": "sha256-igS2Z4tVw5W/x3lCZeeadt0vcU9fxtetZ/RyrqsCRQ0=",
"owner": "NixOS",
"repo": "nixpkgs",
"rev": "199169a2135e6b864a888e89a2ace345703c025d",
"type": "github"
},
"original": {
"owner": "NixOS",
"ref": "nixpkgs-unstable",
"repo": "nixpkgs",
"type": "github"
}
},
"nixpkgs_3": {
"locked": {
"lastModified": 1740828860,
"narHash": "sha256-cjbHI+zUzK5CPsQZqMhE3npTyYFt9tJ3+ohcfaOF/WM=",
@@ -269,8 +58,7 @@
"root": {
"inputs": {
"go-grip": "go-grip",
"neovim-nightly-overlay": "neovim-nightly-overlay",
"nixpkgs": "nixpkgs_3"
"nixpkgs": "nixpkgs"
}
},
"systems": {
@@ -287,27 +75,6 @@
"repo": "default",
"type": "github"
}
},
"treefmt-nix": {
"inputs": {
"nixpkgs": [
"neovim-nightly-overlay",
"nixpkgs"
]
},
"locked": {
"lastModified": 1739829690,
"narHash": "sha256-mL1szCeIsjh6Khn3nH2cYtwO5YXG6gBiTw1A30iGeDU=",
"owner": "numtide",
"repo": "treefmt-nix",
"rev": "3d0579f5cc93436052d94b73925b48973a104204",
"type": "github"
},
"original": {
"owner": "numtide",
"repo": "treefmt-nix",
"type": "github"
}
}
},
"root": "root",

View File

@@ -2,10 +2,10 @@
description = "My development environment";
inputs = {
nixpkgs.url = "github:nixos/nixpkgs/nixos-unstable";
neovim-nightly-overlay.url = "github:nix-community/neovim-nightly-overlay";
go-grip = {
url = "github:guz013/go-grip";
inputs.nixpkgs.follows = "nixpkgs";
};
};
outputs = {
@@ -19,40 +19,23 @@
"x86_64-darwin"
"aarch64-darwin"
];
overlays = [
inputs.neovim-nightly-overlay.overlays.default
];
forAllSystems = f:
nixpkgs.lib.genAttrs systems (system: let
pkgs = import nixpkgs {inherit system overlays;};
pkgs = import nixpkgs {inherit system;};
in
f system pkgs);
f {
inherit pkgs;
inherit (pkgs) lib;
});
in {
packages = forAllSystems (system: pkgs: {
neovim = pkgs.callPackage ./neovim.nix {
go-grip = inputs.go-grip.packages.${system}.default;
};
default = self.packages.${system}.neovim;
});
legacyPackages = self.packages;
nixosModules = {
neovim = (import ./home-manager.nix) {inherit inputs self;};
default = self.nixosModules.neovim;
};
homeManagerModules = {
neovim = (import ./home-manager.nix) {inherit inputs self;};
default = self.homeManagerModules.neovim;
};
devShells = forAllSystems (system: pkgs: {
default = pkgs.mkShell {
buildInputs = with pkgs; [
alejandra
stylua
];
packages = forAllSystems ({
pkgs,
lib,
...
}: {
neovim = import ./package.nix {
inherit pkgs lib;
go-grip = inputs.go-grip.packages.${pkgs.system}.default;
};
});
};

View File

@@ -1,200 +0,0 @@
{
symlinkJoin,
makeWrapper,
runCommandLocal,
pkgs,
lib,
# Dependencies
neovim-unwrapped ? pkgs.neovim-unwrapped,
yazi ? pkgs.yazi,
ripgrep ? pkgs.ripgrep,
go-grip,
...
}: let
startPlugins = with pkgs;
with vimPlugins; [
blink-cmp
catppuccin-nvim
indent-blankline-nvim
lze
nvim-lspconfig
nvim-treesitter.withAllGrammars
nvim-treesitter-textobjects
nvim-treesitter-textsubjects
(vimUtils.buildVimPlugin {
name = "dot013.nvim";
src = ./.;
})
];
optPlugins = with pkgs;
with pkgs.vimPlugins; [
auto-save-nvim
auto-session
cloak-nvim
conform-nvim
comment-nvim
friendly-snippets
gitsigns-nvim
harpoon2
lualine-nvim
luasnip
marks-nvim
nvim-autopairs
nvim-dap
nvim-dap-go
nvim-dap-ui
nvim-dap-virtual-text
nvim-nio
nvim-ts-autotag
nvim-web-devicons
telescope-nvim
telescope-fzf-native-nvim
trouble-nvim
tmux-nvim
vim-sleuth
(vimUtils.buildVimPlugin {
pname = "nvim-emmet";
version = "v0.4.4";
src = fetchGit {
url = "https://github.com/olrtg/nvim-emmet";
rev = "cde4fb2968704aae5c18b7f8a9bc2508767bb78d";
};
})
# Probably can be replaced by local functions in the config
(vimUtils.buildVimPlugin {
pname = "tfm.nvim";
version = "2024-04-23";
src = fetchGit {
url = "https://github.com/Rolv-Apneseth/tfm.nvim";
rev = "fb0de2c96bf303216ac5d91ce9bdb7f430030f8b";
};
})
];
languageServers = with pkgs; [
emmet-language-server
deno
gopls
golangci-lint-langserver
htmx-lsp
lua-language-server
nil
tailwindcss-language-server
typescript-language-server
rust-analyzer
vscode-langservers-extracted
# Temporally solution since there isn't a easy way to install pnpm packages
(pkgs.writeShellScriptBin "unocss-language-server" ''
${lib.getExe pkgs.bun} x unocss-language-server@0.1.5 "$@"
'')
];
formatters = with pkgs; [
alejandra
shellharden
shfmt
jq
];
packages = [
ripgrep
go-grip
yazi
];
foldPlugins = builtins.foldl' (acc: next: acc ++ [next] ++ (foldPlugins (next.dependencies or []))) [];
startPluginsWithDeps = lib.unique (foldPlugins startPlugins);
optPluginsWithDeps = lib.unique (foldPlugins optPlugins);
packpath = let
packageName = "dot013";
in
runCommandLocal "packpath" {} ''
mkdir -p $out/pack/${packageName}/{start,opt}
${lib.concatMapStringsSep "\n"
(plugin: "ln -vsfT ${plugin} $out/pack/${packageName}/start/${lib.getName plugin}")
startPluginsWithDeps}
${lib.concatMapStringsSep "\n"
(plugin: "ln -vsfT ${plugin} $out/pack/${packageName}/opt/${lib.getName plugin}")
optPluginsWithDeps}
'';
initLua = let
luaPackages = lp: [];
luaEnv = neovim-unwrapped.lua.withPackages luaPackages;
inherit (neovim-unwrapped.lua.pkgs.luaLib) genLuaPathAbsStr genLuaCPathAbsStr;
in
pkgs.writeText "init.lua" ''
-- Don't use LUA_PATH and LUA_CPATH, since they leak into the LSP
package.path = "${genLuaPathAbsStr luaEnv};" .. package.path
package.cpath = "${genLuaCPathAbsStr luaEnv};" .. package.cpath
-- No remote plugins
vim.g.loaded_node_provider = 0
vim.g.loaded_perl_provider = 0
vim.g.loaded_python_provider = 0
vim.g.loaded_python3_provider = 0
vim.g.loaded_ruby_provider = 0
require("dot013")
'';
nvim-derivation = symlinkJoin {
name = "neovim-custom";
pname = "nvim";
paths = let
wrappedNvim = pkgs.writeShellScriptBin "nvim" ''
export PATH=${lib.makeBinPath (languageServers ++ formatters ++ packages)}:$PATH
${lib.getExe neovim-unwrapped} "$@"
'';
in [wrappedNvim];
nativeBuildInputs = [makeWrapper];
postBuild = ''
wrapProgram $out/bin/nvim \
--add-flags '-u' \
--add-flags '${initLua}' \
--add-flags '--cmd' \
--add-flags "'set packpath^=${packpath} | set runtimepath^=${packpath}'" \
--set-default NVIM_APPNAME nvim-custom
'';
passthru = {
inherit packpath;
};
meta = {
mainProgram = "nvim";
};
};
in
pkgs.stdenv.mkDerivation rec {
name = "Neovim";
pname = "nvim";
buildCommand = let
desktopEntry = pkgs.makeDesktopItem {
name = pname;
desktopName = name;
exec = "${lib.getExe nvim-derivation}";
terminal = true;
};
in ''
mkdir -p $out/bin
cp ${lib.getExe nvim-derivation} $out/bin
mkdir -p $out/share/applications
cp ${desktopEntry}/share/applications/${pname}.desktop $out/share/applications/${pname}.desktop
'';
}
// {
inherit (neovim-unwrapped) description meta;
}

111
package.nix Normal file
View File

@@ -0,0 +1,111 @@
{
pkgs,
lib,
neovim ? pkgs.neovim,
ripgrep ? pkgs.ripgrep,
go-grip ? null,
yazi ? pkgs.yazi,
...
}: let
start = with pkgs.vimPlugins; [
blink-cmp
catppuccin-nvim
indent-blankline-nvim
lze
nvim-lspconfig
nvim-treesitter.withAllGrammars
nvim-treesitter-textobjects
nvim-treesitter-textsubjects
((pkgs.vimUtils.buildVimPlugin {
name = "dot013.nvim";
src = ./.;
})
.overrideAttrs {doCheck = false;})
];
opt = with pkgs.vimPlugins; [
auto-save-nvim
auto-session
cloak-nvim
conform-nvim
comment-nvim
friendly-snippets
gitsigns-nvim
harpoon2
lualine-nvim
luasnip
marks-nvim
nvim-autopairs
nvim-dap
nvim-dap-go
nvim-dap-ui
nvim-dap-virtual-text
nvim-nio
nvim-ts-autotag
nvim-web-devicons
telescope-nvim
telescope-fzf-native-nvim
trouble-nvim
tmux-nvim
vim-sleuth
(pkgs.vimUtils.buildVimPlugin {
pname = "nvim-emmet";
version = "v0.4.4";
src = fetchGit {
url = "https://github.com/olrtg/nvim-emmet";
rev = "cde4fb2968704aae5c18b7f8a9bc2508767bb78d";
};
})
# Probably can be replaced by local functions in the config
(pkgs.vimUtils.buildVimPlugin {
pname = "tfm.nvim";
version = "2024-04-23";
src = fetchGit {
url = "https://github.com/Rolv-Apneseth/tfm.nvim";
rev = "fb0de2c96bf303216ac5d91ce9bdb7f430030f8b";
};
})
];
languageServers = with pkgs; [
emmet-language-server
deno
gopls
golangci-lint-langserver
htmx-lsp
lua-language-server
nil
tailwindcss-language-server
typescript-language-server
rust-analyzer
vscode-langservers-extracted
# Temporally solution since there isn't a easy way to install pnpm packages
(pkgs.writeShellScriptBin "unocss-language-server" ''
${lib.getExe pkgs.bun} x unocss-language-server@0.1.5 "$@"
'')
];
formatters = with pkgs; [
alejandra
shellharden
shfmt
jq
];
externalDependencies = [
ripgrep
go-grip
yazi
];
in
neovim.override {
viAlias = true;
vimAlias = true;
configure.packages.plugins = {inherit start opt;};
extraMakeWrapperArgs = let
binPath = lib.makeBinPath (languageServers ++ formatters ++ externalDependencies);
in "--suffix PATH : ${binPath}";
}