mirror of
https://github.com/dwinkler1/nvimConfig.git
synced 2026-07-07 16:08:22 -04:00
refactor package installation
This commit is contained in:
parent
10254b11c7
commit
a0ba90c4d2
8 changed files with 433 additions and 193 deletions
109
modules/module/settings/cat-packages.nix
Normal file
109
modules/module/settings/cat-packages.nix
Normal 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 = [ ];
|
||||
};
|
||||
}
|
||||
|
|
@ -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;
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
}
|
||||
|
|
@ -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 [])) [];
|
||||
|
|
|
|||
|
|
@ -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 {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue