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
-
It is conventional for
lib
in most flake outputs to not be system-specific.It is also problematic if
pkgs
is (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 apkgs
outside 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
pkgs
for 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 evaluatepkgs
for something...Regardless, I think the ideal is to make it so that our flake's
lib
output 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
system
as an argument, similar tonixpkgs.lib.nixosSystem
or home-manager's equivalent. We'd also have to move any functions inhelpers
that needpkgs
into module options (such as theconfig.lib
module option) OR refactor them to takepkgs
as a function argument.E.g.
helpers.writeLua
could look something like:writeLua = pkgs: name: text: pkgs.runCommand name { inherit text; } "echo -n "$text" > $out && stylua $out";
(receiving
pkgs
as its first argument)This matches the pattern used in nixpkgs lib, e.g.
lib.callPackageWith
orlib.types.mkPackageOption
both takepkgs
as 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