nixvim lib with no pkgs dependency
#2186
MattSturgeon
started this conversation in
General
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
It is conventional for
libin most flake outputs to not be system-specific.It is also problematic if
pkgsis (unnecessarily) evaluated multiple times to build someones config.Currently, to evaluate nixvim's lib we need both our flake outputs and
pkgs. Since we then also use nixvim's lib to evaluate the modules, we need apkgsoutside of (before) the module eval.We also need nixvim's lib in some parts of our flake eval (e.g. in some of our test derivations), so that means we need to evaluate a
pkgsfor our flake. Now that I put that in writing, it doesn't sound so bad; this would always be the case anyway since flake evals almost always end up needing to evaluatepkgsfor something...Regardless, I think the ideal is to make it so that our flake's
liboutput is not an attrsof <system> but instead a library attrset that does not depend on system/pkgs.To this end, we'd have to refactor or replace the standalone wrapper with a new design that accepts
systemas an argument, similar tonixpkgs.lib.nixosSystemor home-manager's equivalent. We'd also have to move any functions inhelpersthat needpkgsinto module options (such as theconfig.libmodule option) OR refactor them to takepkgsas a function argument.E.g.
helpers.writeLuacould look something like:writeLua = pkgs: name: text: pkgs.runCommand name { inherit text; } "echo -n "$text" > $out && stylua $out";(receiving
pkgsas its first argument)This matches the pattern used in nixpkgs lib, e.g.
lib.callPackageWithorlib.types.mkPackageOptionboth takepkgsas their first argument and can be curried if needed within the module eval (or withinpkgs, i.e.pkgs.callPackage = lib.callPackageWith pkgs).Beta Was this translation helpful? Give feedback.
All reactions