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);
}