mirror of
https://github.com/dwinkler1/nvimConfig.git
synced 2026-09-20 06:27:23 -04:00
Make settings.lang_packages append instead of replace
Downstream modules assign settings.lang_packages.<lang> plainly, which out-priorities mkOptionDefault and silently dropped the built-in defaults (e.g. lintr, breaking R linting in downstream wrappers like the project-template ed flake). Move the built-in defaults into a separate settings.langPackageDefaults option and compose defaults ++ lang_packages at the consumption sites (catPkgs r/python/julia, quarto extraRPackages, neovide R host). A new append-semantics check fails if defaults migrate back into lang_packages. Also fix pre-existing inverted assertions in downstream-overrides check: the override module sets cats.r = true, so assert presence, not absence.
This commit is contained in:
parent
a4bae164c3
commit
9a6e20110e
6 changed files with 206 additions and 113 deletions
|
|
@ -198,7 +198,8 @@ projectSettings = {
|
||||||
|
|
||||||
### Language packages (module defaults)
|
### Language packages (module defaults)
|
||||||
|
|
||||||
Add Python/R/Julia libraries that get appended to the module defaults. The built-in defaults are:
|
Add Python/R/Julia libraries. These are appended to the built-in defaults, which
|
||||||
|
always apply (see `settings.langPackageDefaults` in `modules/module/settings/lang-packages.nix`):
|
||||||
|
|
||||||
- Python: `duckdb`, `polars`
|
- Python: `duckdb`, `polars`
|
||||||
- R: `arrow`, `broom`, `data_table`, `janitor`, `styler`
|
- R: `arrow`, `broom`, `data_table`, `janitor`, `styler`
|
||||||
|
|
@ -214,7 +215,8 @@ projectSettings = {
|
||||||
};
|
};
|
||||||
```
|
```
|
||||||
|
|
||||||
Use `lib.mkForce` to replace rather than append:
|
Use `lib.mkForce` to replace other `lang_packages` assignments; the built-in defaults still apply.
|
||||||
|
To exclude defaults, override `catPkgs.<cat>` instead:
|
||||||
|
|
||||||
```nix
|
```nix
|
||||||
projectSettings = {
|
projectSettings = {
|
||||||
|
|
@ -337,5 +339,5 @@ cats.nix ───────────────► config.cats │
|
||||||
- **Overlays** (`overlays/`) inject dependency package sets into nixpkgs (`rpkgs`, `baseRPackages`, `basePythonPackages`, plugins). Top-level `rWrapper` and `quarto` are compatibility conveniences, but `pkgs.rpkgs` is the canonical R surface for downstream configuration.
|
- **Overlays** (`overlays/`) inject dependency package sets into nixpkgs (`rpkgs`, `baseRPackages`, `basePythonPackages`, plugins). Top-level `rWrapper` and `quarto` are compatibility conveniences, but `pkgs.rpkgs` is the canonical R surface for downstream configuration.
|
||||||
- **cat-packages.nix** is the single source of truth for per-category packages. Each list is gated by its cat toggle.
|
- **cat-packages.nix** is the single source of truth for per-category packages. Each list is gated by its cat toggle.
|
||||||
- **deps.nix** wires `catPkgs` into the wrapper's runtime PATH.
|
- **deps.nix** wires `catPkgs` into the wrapper's runtime PATH.
|
||||||
- **settings.lang_packages** holds the shared defaults used by local outputs and downstream module consumers.
|
- **settings.lang_packages** holds project-specific language libraries appended to the built-in `settings.langPackageDefaults`, used by local outputs and downstream module consumers.
|
||||||
- **flake.nix** exports `lib.eval`, `lib.mkWrapper`, `lib.devShellPackages`, and `lib.shellHook` as the canonical downstream helpers, and builds `packages.default` and `devShells.default` from the same module config.
|
- **flake.nix** exports `lib.eval`, `lib.mkWrapper`, `lib.devShellPackages`, and `lib.shellHook` as the canonical downstream helpers, and builds `packages.default` and `devShells.default` from the same module config.
|
||||||
|
|
|
||||||
36
flake.nix
36
flake.nix
|
|
@ -29,7 +29,6 @@
|
||||||
url = "github:jmbuhr/cmp-pandoc-references";
|
url = "github:jmbuhr/cmp-pandoc-references";
|
||||||
flake = false;
|
flake = false;
|
||||||
};
|
};
|
||||||
|
|
||||||
"plugins-bloocky" = {
|
"plugins-bloocky" = {
|
||||||
url = "github:atiladefreitas/bloocky";
|
url = "github:atiladefreitas/bloocky";
|
||||||
flake = false;
|
flake = false;
|
||||||
|
|
@ -39,6 +38,7 @@
|
||||||
url = "github:atiladefreitas/dooing";
|
url = "github:atiladefreitas/dooing";
|
||||||
flake = false;
|
flake = false;
|
||||||
};
|
};
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
outputs = {
|
outputs = {
|
||||||
|
|
@ -216,10 +216,10 @@
|
||||||
(builtins.length (self.lib.devShellPackages defaultConfig) > 0)
|
(builtins.length (self.lib.devShellPackages defaultConfig) > 0)
|
||||||
];
|
];
|
||||||
overrideAssertions = [
|
overrideAssertions = [
|
||||||
(!(overrideConfig.cats.r or false))
|
(overrideConfig.cats.r or false)
|
||||||
(builtins.length overrideNix == 1)
|
(builtins.length overrideNix == 1)
|
||||||
((builtins.head overrideNix) == "alejandra")
|
((builtins.head overrideNix) == "alejandra")
|
||||||
(builtins.match ".*R RHOME.*" overrideShellHook == null)
|
(builtins.match ".*R RHOME.*" overrideShellHook != null)
|
||||||
];
|
];
|
||||||
in
|
in
|
||||||
pkgs.runCommand "check-downstream-overrides" {
|
pkgs.runCommand "check-downstream-overrides" {
|
||||||
|
|
@ -241,6 +241,36 @@
|
||||||
touch $out
|
touch $out
|
||||||
'';
|
'';
|
||||||
|
|
||||||
|
# Downstream modules assign settings.lang_packages.<lang> plainly. The
|
||||||
|
# module system replaces same-option defaults, so built-in defaults must
|
||||||
|
# live in langPackageDefaults and be composed at the consumption sites.
|
||||||
|
# This check fails if someone moves defaults back into lang_packages:
|
||||||
|
# then a downstream assignment would silently drop lintr etc.
|
||||||
|
append-semantics = let
|
||||||
|
downstreamCfg = (self.lib.eval {
|
||||||
|
inherit pkgs;
|
||||||
|
modules = [
|
||||||
|
{
|
||||||
|
cats.r = true;
|
||||||
|
settings.lang_packages.r = [ pkgs.rpkgs.rPackages.fixest ];
|
||||||
|
}
|
||||||
|
];
|
||||||
|
}).config;
|
||||||
|
rWrapperPkg = builtins.head downstreamCfg.catPkgs.r;
|
||||||
|
in
|
||||||
|
pkgs.runCommand "check-lang-packages-append" { } ''
|
||||||
|
script=$(readlink -f "${rWrapperPkg}/bin/R")
|
||||||
|
grep -q "r-lintr-" "$script" || {
|
||||||
|
echo "default R packages were dropped by a downstream lang_packages assignment" >&2
|
||||||
|
exit 1
|
||||||
|
}
|
||||||
|
grep -q "r-fixest-" "$script" || {
|
||||||
|
echo "downstream lang_packages.r additions were not appended" >&2
|
||||||
|
exit 1
|
||||||
|
}
|
||||||
|
echo "lang_packages append semantics OK" > $out
|
||||||
|
'';
|
||||||
|
|
||||||
smoke-test = pkgs.runCommand "smoke-test" {} ''
|
smoke-test = pkgs.runCommand "smoke-test" {} ''
|
||||||
# The Nix build sandbox has a read-only HOME; point XDG dirs at a
|
# The Nix build sandbox has a read-only HOME; point XDG dirs at a
|
||||||
# writable location so vim.lsp/shaDa can write state headlessly.
|
# writable location so vim.lsp/shaDa can write state headlessly.
|
||||||
|
|
|
||||||
|
|
@ -9,14 +9,17 @@ let
|
||||||
# NOTE: Package list expressions are lazily evaluated, and derivations are
|
# NOTE: Package list expressions are lazily evaluated, and derivations are
|
||||||
# not built until needed, so keep side-effecting expressions out of these
|
# not built until needed, so keep side-effecting expressions out of these
|
||||||
# lists.
|
# lists.
|
||||||
maybe = cat: pkgsList:
|
maybe = cat: pkgsList: lib.optionals (config.cats.${cat} or false) pkgsList;
|
||||||
lib.optionals (config.cats.${cat} or false) pkgsList;
|
rPackages =
|
||||||
rPackages = (pkgs.baseRPackages or [ ]) ++ config.settings.lang_packages.r;
|
(pkgs.baseRPackages or [ ])
|
||||||
|
++ config.settings.langPackageDefaults.r
|
||||||
|
++ config.settings.lang_packages.r;
|
||||||
rWrapperPackages = rPackages;
|
rWrapperPackages = rPackages;
|
||||||
quartoPkg =
|
quartoPkg =
|
||||||
if config.cats.r or false
|
if config.cats.r or false then
|
||||||
then pkgs.rpkgs.quarto.override { extraRPackages = rPackages; }
|
pkgs.rpkgs.quarto.override { extraRPackages = rPackages; }
|
||||||
else pkgs.quarto;
|
else
|
||||||
|
pkgs.quarto;
|
||||||
in
|
in
|
||||||
{
|
{
|
||||||
options.catPkgs = lib.mkOption {
|
options.catPkgs = lib.mkOption {
|
||||||
|
|
@ -25,83 +28,107 @@ in
|
||||||
};
|
};
|
||||||
|
|
||||||
config.catPkgs = {
|
config.catPkgs = {
|
||||||
always = maybe "always" (with pkgs; [
|
always = maybe "always" (
|
||||||
ripgrep
|
with pkgs;
|
||||||
]);
|
[
|
||||||
|
ripgrep
|
||||||
|
]
|
||||||
|
);
|
||||||
|
|
||||||
clickhouse = maybe "clickhouse" (with pkgs; [ clickhouse-lts ]);
|
clickhouse = maybe "clickhouse" (with pkgs; [ clickhouse-lts ]);
|
||||||
|
|
||||||
external = maybe "external" (with pkgs; [
|
external = maybe "external" (
|
||||||
nodejs
|
with pkgs;
|
||||||
perl
|
[
|
||||||
ruby
|
nodejs
|
||||||
shfmt
|
perl
|
||||||
sqlfluff
|
ruby
|
||||||
tree-sitter
|
shfmt
|
||||||
]);
|
sqlfluff
|
||||||
|
tree-sitter
|
||||||
|
]
|
||||||
|
);
|
||||||
|
|
||||||
julia = maybe "julia" [
|
julia = maybe "julia" [
|
||||||
(pkgs.julia-bin.withPackages config.settings.lang_packages.julia)
|
(pkgs.julia-bin.withPackages (
|
||||||
|
config.settings.langPackageDefaults.julia ++ config.settings.lang_packages.julia
|
||||||
|
))
|
||||||
];
|
];
|
||||||
|
|
||||||
lua = maybe "lua" (with pkgs; [ lua-language-server ]);
|
lua = maybe "lua" (with pkgs; [ lua-language-server ]);
|
||||||
|
|
||||||
markdown = maybe "markdown" (with pkgs; [
|
markdown = maybe "markdown" (
|
||||||
python3Packages.pylatexenc
|
with pkgs;
|
||||||
quartoPkg
|
[
|
||||||
zk
|
python3Packages.pylatexenc
|
||||||
marksman
|
quartoPkg
|
||||||
texlab
|
zk
|
||||||
imagemagick
|
marksman
|
||||||
harper
|
texlab
|
||||||
]);
|
imagemagick
|
||||||
|
harper
|
||||||
|
]
|
||||||
|
);
|
||||||
|
|
||||||
nix = maybe "nix" (with pkgs; [
|
nix = maybe "nix" (
|
||||||
alejandra
|
with pkgs;
|
||||||
nix-doc
|
[
|
||||||
nixd
|
alejandra
|
||||||
]);
|
nix-doc
|
||||||
|
nixd
|
||||||
|
]
|
||||||
|
);
|
||||||
|
|
||||||
optional = maybe "optional" (with pkgs; [
|
optional = maybe "optional" (
|
||||||
bat
|
with pkgs;
|
||||||
broot
|
[
|
||||||
devenv
|
bat
|
||||||
dust
|
broot
|
||||||
fd
|
devenv
|
||||||
fzf
|
dust
|
||||||
gawk
|
fd
|
||||||
gh
|
fzf
|
||||||
git
|
gawk
|
||||||
hunspell
|
gh
|
||||||
hunspellDicts.de-at
|
git
|
||||||
hunspellDicts.en-us
|
hunspell
|
||||||
ispell
|
hunspellDicts.de-at
|
||||||
jq
|
hunspellDicts.en-us
|
||||||
just
|
ispell
|
||||||
lazygit
|
jq
|
||||||
man
|
just
|
||||||
ncdu
|
lazygit
|
||||||
pigz
|
man
|
||||||
poppler
|
ncdu
|
||||||
ripgrep
|
pigz
|
||||||
tokei
|
poppler
|
||||||
wget
|
ripgrep
|
||||||
yq
|
tokei
|
||||||
]);
|
wget
|
||||||
|
yq
|
||||||
|
]
|
||||||
|
);
|
||||||
|
|
||||||
python = maybe "python" (let
|
python = maybe "python" (
|
||||||
python_packages_fn =
|
let
|
||||||
if pkgs ? basePythonPackages
|
python_packages_fn =
|
||||||
then ps: pkgs.basePythonPackages ps ++ config.settings.lang_packages.python
|
if pkgs ? basePythonPackages then
|
||||||
else _: config.settings.lang_packages.python;
|
ps:
|
||||||
python_with_packages = pkgs.python3.withPackages python_packages_fn;
|
pkgs.basePythonPackages ps
|
||||||
in
|
++ config.settings.langPackageDefaults.python
|
||||||
with pkgs; [
|
++ config.settings.lang_packages.python
|
||||||
|
else
|
||||||
|
_: config.settings.langPackageDefaults.python ++ config.settings.lang_packages.python;
|
||||||
|
python_with_packages = pkgs.python3.withPackages python_packages_fn;
|
||||||
|
in
|
||||||
|
with pkgs;
|
||||||
|
[
|
||||||
python_with_packages
|
python_with_packages
|
||||||
ruff
|
ruff
|
||||||
basedpyright
|
basedpyright
|
||||||
uv
|
uv
|
||||||
]);
|
]
|
||||||
|
);
|
||||||
|
|
||||||
r = maybe "r" [
|
r = maybe "r" [
|
||||||
(pkgs.rpkgs.rWrapper.override { packages = rWrapperPackages; })
|
(pkgs.rpkgs.rWrapper.override { packages = rWrapperPackages; })
|
||||||
|
|
|
||||||
|
|
@ -14,6 +14,15 @@
|
||||||
# R.nvim v1.x owns its cache and temporary directories and exports
|
# R.nvim v1.x owns its cache and temporary directories and exports
|
||||||
# RNVIM_COMPLDIR/RNVIM_TMPDIR during setup. Do not inject literal `$PWD`
|
# RNVIM_COMPLDIR/RNVIM_TMPDIR during setup. Do not inject literal `$PWD`
|
||||||
# values into the wrapper environment.
|
# values into the wrapper environment.
|
||||||
|
#
|
||||||
|
# ponytail: with R_LIBS_USER unset-or-empty, loading compiled namespaces
|
||||||
|
# (S7 via btw) segfaults on macOS for bare-terminal launches outside the
|
||||||
|
# devShell hook. Any non-empty value avoids it; this store path exists,
|
||||||
|
# contains no libraries, and stays inert. The devShell hook overrides it
|
||||||
|
# with $PWD/.r-libs. Upgrade path: teach wlib to emit expandable defaults.
|
||||||
|
(lib.mkIf (config.cats.r or false) {
|
||||||
|
R_LIBS_USER = "${pkgs.rpkgs.rWrapper}";
|
||||||
|
})
|
||||||
];
|
];
|
||||||
|
|
||||||
# Environment variables with defaults (can be overridden by user)
|
# Environment variables with defaults (can be overridden by user)
|
||||||
|
|
|
||||||
|
|
@ -5,7 +5,10 @@
|
||||||
...
|
...
|
||||||
}:
|
}:
|
||||||
let
|
let
|
||||||
rPackages = (pkgs.baseRPackages or [ ]) ++ config.settings.lang_packages.r;
|
rPackages =
|
||||||
|
(pkgs.baseRPackages or [ ])
|
||||||
|
++ config.settings.langPackageDefaults.r
|
||||||
|
++ config.settings.lang_packages.r;
|
||||||
rWrapperPkg = pkgs.rpkgs.rWrapper.override { packages = rPackages ++ [pkgs.nvimcom]; };
|
rWrapperPkg = pkgs.rpkgs.rWrapper.override { packages = rPackages ++ [pkgs.nvimcom]; };
|
||||||
in
|
in
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -5,53 +5,75 @@
|
||||||
...
|
...
|
||||||
}:
|
}:
|
||||||
{
|
{
|
||||||
options.settings.lang_packages = lib.mkOption {
|
options.settings = {
|
||||||
type = lib.types.submodule {
|
# Built-in language libraries composed into every language spec.
|
||||||
options = {
|
# Consumers extend via settings.lang_packages, which is APPENDED to these.
|
||||||
python = lib.mkOption {
|
langPackageDefaults = lib.mkOption {
|
||||||
type = lib.types.listOf lib.types.package;
|
type = lib.types.submodule {
|
||||||
default = [ ];
|
options = {
|
||||||
description = "Additional Python-related packages appended to the python spec (overlay defaults remain).";
|
python = lib.mkOption {
|
||||||
};
|
type = lib.types.listOf lib.types.package;
|
||||||
r = lib.mkOption {
|
default = [ ];
|
||||||
type = lib.types.listOf lib.types.package;
|
};
|
||||||
default = [ ];
|
r = lib.mkOption {
|
||||||
description = "Additional R-related packages appended to the r spec (overlay defaults remain).";
|
type = lib.types.listOf lib.types.package;
|
||||||
};
|
default = [ ];
|
||||||
julia = lib.mkOption {
|
};
|
||||||
type = lib.types.listOf lib.types.str;
|
julia = lib.mkOption {
|
||||||
default = [ ];
|
type = lib.types.listOf lib.types.str;
|
||||||
description = "Additional Julia packages (names) passed to julia-bin.withPackages.";
|
default = [ ];
|
||||||
|
};
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
default = { };
|
||||||
|
};
|
||||||
|
|
||||||
|
lang_packages = lib.mkOption {
|
||||||
|
type = lib.types.submodule {
|
||||||
|
options = {
|
||||||
|
python = lib.mkOption {
|
||||||
|
type = lib.types.listOf lib.types.package;
|
||||||
|
default = [ ];
|
||||||
|
description = "Additional Python-related packages appended to the python spec (overlay defaults remain).";
|
||||||
|
};
|
||||||
|
r = lib.mkOption {
|
||||||
|
type = lib.types.listOf lib.types.package;
|
||||||
|
default = [ ];
|
||||||
|
description = "Additional R-related packages appended to the r spec (overlay defaults remain).";
|
||||||
|
};
|
||||||
|
julia = lib.mkOption {
|
||||||
|
type = lib.types.listOf lib.types.str;
|
||||||
|
default = [ ];
|
||||||
|
description = "Additional Julia packages (names) passed to julia-bin.withPackages.";
|
||||||
|
};
|
||||||
|
};
|
||||||
|
};
|
||||||
|
default = { };
|
||||||
|
description = ''
|
||||||
|
Project-specific language libraries. Appended to settings.langPackageDefaults
|
||||||
|
in each language spec's runtime packages.
|
||||||
|
'';
|
||||||
};
|
};
|
||||||
default = { };
|
|
||||||
description = ''
|
|
||||||
Language-specific package defaults and downstream overrides appended to each
|
|
||||||
language spec's runtime packages.
|
|
||||||
'';
|
|
||||||
};
|
};
|
||||||
|
|
||||||
config.settings.lang_packages = {
|
config.settings.langPackageDefaults = {
|
||||||
python = lib.mkDefault (with pkgs.python3Packages; [
|
python = with pkgs.python3Packages; [
|
||||||
duckdb
|
duckdb
|
||||||
polars
|
polars
|
||||||
]);
|
];
|
||||||
r = lib.mkDefault (
|
r = with pkgs.rpkgs.rPackages; [
|
||||||
(with pkgs.rpkgs.rPackages; [
|
arrow
|
||||||
arrow
|
broom
|
||||||
broom
|
data_table
|
||||||
data_table
|
janitor
|
||||||
janitor
|
styler
|
||||||
styler
|
# vscDebugger is not on CRAN/Bioconductor, so it is not available in
|
||||||
# vscDebugger is not on CRAN/Bioconductor, so it is not available in
|
# pkgs.rpkgs.rPackages. Install it manually in your R library if you
|
||||||
# pkgs.rpkgs.rPackages. Install it manually in your R library if you
|
# want to use the nvim-dap R adapter (see plugin/26_dap.lua).
|
||||||
# want to use the nvim-dap R adapter (see plugin/26_dap.lua).
|
# vscDebugger
|
||||||
# vscDebugger
|
lintr
|
||||||
lintr
|
];
|
||||||
])
|
julia = [
|
||||||
);
|
|
||||||
julia = lib.mkDefault [
|
|
||||||
"DataFramesMeta"
|
"DataFramesMeta"
|
||||||
"QuackIO"
|
"QuackIO"
|
||||||
];
|
];
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue