load packages only if installed

This commit is contained in:
Daniel Winkler 2026-05-21 20:04:45 +10:00
commit d23c7f6f51
4 changed files with 92 additions and 82 deletions

View file

@ -39,10 +39,8 @@
wrappers,
...
} @ inputs: let
mkWrapperConfig = pkgs: let
def = pkgs.lib.mkDefault;
in {
cats = pkgs.lib.mapAttrs (_: v: def v) {
mkWrapperConfig = pkgs: {
cats = {
clickhouse = false;
gitPlugins = true;
julia = false;
@ -55,22 +53,12 @@
};
settings = {
lang_packages = {
python = def (with pkgs.python3Packages; [
duckdb
polars
]);
r = def ((with pkgs.rpkgs.rPackages; [
arrow
broom
data_table
janitor
languageserver
styler
]) ++ [ pkgs.nvimcom ]);
julia = def ["DataFramesMeta" "QuackIO"];
python = [];
r = [];
julia = [];
};
};
binName = def "vv";
binName = "vv";
};
wrapperSettings = pkgs: let
@ -78,7 +66,7 @@
in
wrapper.config.wrap {
inherit pkgs;
inherit (cfg) cats settings binName;
inherit (cfg) settings binName;
};
systems = [
@ -135,14 +123,29 @@
devShells = forAllSystems (
system: let
pkgs = mkPkgs system;
cfg = mkWrapperConfig pkgs;
nvimPkg = wrapperSettings pkgs;
pythonPkgs = with pkgs.python3Packages; [
duckdb
polars
];
rPkgs = (with pkgs.rpkgs.rPackages; [
arrow
broom
data_table
janitor
languageserver
styler
]) ++ [ pkgs.nvimcom ];
juliaPkgs = ["DataFramesMeta" "QuackIO"];
pythonPackages = let
python_packages_fn =
if pkgs ? basePythonPackages
then ps: pkgs.basePythonPackages ps ++ cfg.settings.lang_packages.python
else _: cfg.settings.lang_packages.python;
then ps: pkgs.basePythonPackages ps ++ pythonPkgs
else _: pythonPkgs;
in
with pkgs; [
(python3.withPackages python_packages_fn)
@ -153,7 +156,7 @@
];
rPackages = let
r_packages = (pkgs.baseRPackages or []) ++ cfg.settings.lang_packages.r;
r_packages = (pkgs.baseRPackages or []) ++ rPkgs;
in
with pkgs; [
(rWrapper.override {packages = r_packages;})
@ -167,7 +170,7 @@
];
juliaPackages = let
julia_with_packages = pkgs.julia-bin.withPackages cfg.settings.lang_packages.julia;
julia_with_packages = pkgs.julia-bin.withPackages juliaPkgs;
in [julia_with_packages];
markdownPackages = with pkgs; [

View file

@ -1,4 +1,6 @@
-- Add the key mappings only for Markdown files in a zk notebook.
local nix = require("config.nix")
if nix.get_cat("markdown", false) then
if require("zk.util").notebook_root(vim.fn.expand('%:p')) ~= nil then
local map = vim.keymap.set
-- Open the link under the caret.
@ -30,3 +32,4 @@ if require("zk.util").notebook_root(vim.fn.expand('%:p')) ~= nil then
{ noremap = true, silent = false, buffer = true, desc = "Code actions" })
end
end

View file

@ -390,6 +390,7 @@ end)
-- zk
now_if_args(function()
if nix.get_cat("markdown", false) then
require("zk").setup({
picker = "minipick",
lsp = {
@ -409,4 +410,5 @@ now_if_args(function()
},
})
end
end)

View file

@ -71,6 +71,7 @@ end)
now(function()
vim.treesitter.language.register("markdown", { "quarto", "rmd" })
if nix.get_cat({"r", "markdown"}, false) then
vim.api.nvim_create_autocmd("FileType", {
pattern = { "quarto" },
callback = function()
@ -87,6 +88,7 @@ now(function()
write_to_disk = true,
},
})
end
end)
later(function()