refactor package installation

This commit is contained in:
Daniel Winkler 2026-05-23 20:15:23 +10:00
commit a0ba90c4d2
8 changed files with 433 additions and 193 deletions

View file

@ -0,0 +1,109 @@
{
config,
pkgs,
lib,
...
}:
let
maybe = cat: pkgsList:
lib.optionals (config.cats.${cat} or false) pkgsList;
in
{
options.catPkgs = lib.mkOption {
type = lib.types.attrsOf (lib.types.listOf lib.types.package);
description = "Per-cat package lists, gated by cat toggles. Single source of truth for runtimeDeps and devShells.";
};
config.catPkgs = {
always = maybe "always" (with pkgs; [ ]);
clickhouse = maybe "clickhouse" (with pkgs; [ clickhouse-lts ]);
external = maybe "external" (with pkgs; [
perl
ruby
shfmt
sqlfluff
tree-sitter
]);
julia = maybe "julia" [
(pkgs.julia-bin.withPackages config.settings.lang_packages.julia)
];
lua = maybe "lua" (with pkgs; [ lua-language-server ]);
markdown = maybe "markdown" (with pkgs; [
python313Packages.pylatexenc
quarto
zk
]);
nix = maybe "nix" (with pkgs; [
alejandra
nix-doc
nixd
]);
optional = maybe "optional" (with pkgs; [
bat
broot
devenv
dust
fd
fzf
gawk
gh
git
hunspell
hunspellDicts.de-at
hunspellDicts.en-us
ispell
jq
just
lazygit
man
ncdu
pigz
poppler
ripgrep
tokei
wget
yq
zathura
]);
python = maybe "python" (let
python_packages_fn =
if pkgs ? basePythonPackages
then ps: pkgs.basePythonPackages ps ++ config.settings.lang_packages.python
else _: config.settings.lang_packages.python;
python_with_packages = pkgs.python3.withPackages python_packages_fn;
in
with pkgs; [
python_with_packages
nodejs
ruff
basedpyright
uv
]);
r = maybe "r" (let
r_packages = (pkgs.baseRPackages or [ ]) ++ config.settings.lang_packages.r;
in
with pkgs; [
(rWrapper.override { packages = r_packages; })
radianWrapper
(quarto.override { extraRPackages = r_packages; })
air-formatter
yaml-language-server
rnvimserver
]);
# cats without packages get empty lists
general = [ ];
gitPlugins = [ ];
treesitterParsers = [ pkgs.tree-sitter ];
utils = [ ];
};
}

View file

@ -13,6 +13,7 @@
Set a category to `false` to skip its dependency/plugin specs.
Available categories:
- always: always-on packages (not gated by a toggle)
- clickhouse: Clickhouse client and tools
- external: external tools and integrations
- general: core Neovim plugins/features
@ -30,6 +31,7 @@
};
config.cats = {
always = lib.mkDefault true;
clickhouse = lib.mkDefault false;
external = lib.mkDefault true;
general = lib.mkDefault true;

View file

@ -1,33 +0,0 @@
{
config,
lib,
...
}:
let
collect_runtime_packages = runtime_deps_type:
config.specCollect
(acc: spec:
let
is_enabled = if spec ? enable then spec.enable else true;
has_runtime_deps = (spec.runtimeDeps or false) == runtime_deps_type;
packages = spec.runtimePackages or [ ];
in
acc ++ lib.optionals (is_enabled && has_runtime_deps) packages
)
[ ];
prefix_packages = collect_runtime_packages "prefix";
to_path_specs = packages: [
{
data = [
"PATH"
":"
"${lib.makeBinPath packages}"
];
}
];
in
{
config.prefixVar = lib.optionals (prefix_packages != [ ]) (to_path_specs prefix_packages);
}

View file

@ -13,133 +13,69 @@
};
};
config.specs.external = {
config.specs.always = lib.mkIf (config.cats.always or true) {
data = lib.mkDefault null;
runtimeDeps = "prefix";
runtimePkgs = config.catPkgs.always;
};
config.specs.external = lib.mkIf (config.cats.external or true) {
data = lib.mkDefault null;
before = ["INIT_MAIN"];
config = ''
vim.o.shell = "${pkgs.zsh}/bin/zsh"
'';
runtimeDeps = "prefix";
runtimePkgs = with pkgs; [
perl
ruby
shfmt
sqlfluff
tree-sitter
];
runtimePkgs = config.catPkgs.external;
};
config.specs.optional = lib.mkIf (config.cats.optional or true) {
data = lib.mkDefault null;
runtimeDeps = "prefix";
before = ["INIT_MAIN"];
runtimePkgs = with pkgs; [
bat
broot
devenv
dust
fd
fzf
gawk
gh
git
hunspell
hunspellDicts.de-at
hunspellDicts.en-us
ispell
jq
just
lazygit
man
ncdu
pigz
poppler
ripgrep
tokei
wget
yq
zathura
];
runtimePkgs = config.catPkgs.optional;
};
config.specs.markdown = lib.mkIf (config.cats.markdown or true) {
data = lib.mkDefault null;
runtimeDeps = "prefix";
runtimePkgs = with pkgs; [
python313Packages.pylatexenc
quarto
zk
];
runtimePkgs = config.catPkgs.markdown;
};
config.specs.nix = lib.mkIf (config.cats.nix or true) {
data = lib.mkDefault null;
runtimeDeps = "prefix";
runtimePkgs = with pkgs; [
alejandra
nix-doc
nixd
];
runtimePkgs = config.catPkgs.nix;
};
config.specs.lua = lib.mkIf (config.cats.lua or true) {
data = lib.mkDefault null;
runtimeDeps = "prefix";
runtimePkgs = with pkgs; [
lua-language-server
];
runtimePkgs = config.catPkgs.lua;
};
config.specs.python = lib.mkIf (config.cats.python or true) {
data = lib.mkDefault null;
runtimeDeps = "prefix";
runtimePkgs = let
python_packages_fn =
if pkgs ? basePythonPackages
then ps: pkgs.basePythonPackages ps ++ config.settings.lang_packages.python
else _: config.settings.lang_packages.python;
python_with_packages = pkgs.python3.withPackages python_packages_fn;
in
with pkgs; [
python_with_packages
nodejs
ruff
basedpyright
uv
];
runtimePkgs = config.catPkgs.python;
};
config.specs.r = lib.mkIf (config.cats.r or true) {
data = lib.mkDefault null;
runtimeDeps = "prefix";
runtimePkgs = let
r_packages = (pkgs.baseRPackages or []) ++ config.settings.lang_packages.r;
in
with pkgs; [
(rWrapper.override {packages = r_packages;})
radianWrapper
(quarto.override {extraRPackages = r_packages;})
air-formatter
yaml-language-server
updateR
];
runtimePkgs = config.catPkgs.r;
};
config.specs.julia = lib.mkIf (config.cats.julia or true) {
data = lib.mkDefault null;
runtimeDeps = "prefix";
runtimePkgs = let
julia_with_packages =
pkgs.julia-bin.withPackages config.settings.lang_packages.julia;
in [julia_with_packages];
runtimePkgs = config.catPkgs.julia;
};
config.specs.clickhouse = lib.mkIf (config.cats.clickhouse or true) {
data = lib.mkDefault null;
runtimeDeps = "prefix";
runtimePkgs = with pkgs; [
clickhouse-lts
];
runtimePkgs = config.catPkgs.clickhouse;
};
config.runtimePkgs = config.specCollect (acc: v: acc ++ (v.runtimePkgs or [])) [];

View file

@ -9,6 +9,7 @@ inputs:
{
imports = [
wlib.wrapperModules.neovim
./module/settings/cat-packages.nix
./module/specs/deps.nix
./module/specs/plugins.nix
./module/settings/core.nix
@ -16,7 +17,6 @@ inputs:
./module/settings/env.nix
./module/settings/hosts.nix
./module/settings/lang-packages.nix
./module/settings/runtime-path.nix
];
options.nvim-lib.neovimPlugins = lib.mkOption {