pkgs not passed when using config in parametric aspect
#658
Replies: 2 comments 1 reply
|
The Den decides whether a function is a module or a scope function with this, in isSubmoduleFn = canTake.upTo {
lib = true;
config = true;
options = true;
};and the comment directly under it states the two paths:
args = lib.functionArgs func;
required = builtins.filter (n: !args.${n}) (builtins.attrNames args);
satisfied = valid && builtins.all (n: params ? ${n}) required;
...
upTo = satisfied && intersect != { };So a function counts as a module only if every required argument is one of Two consequences worth knowing before you rewrite it. The way out is to stop mixing the two arg sets and nest them instead: an outer scope function for mkPkgAspect = packages: guiPackages:
{ host, ... }: {
homeManager =
{ lib, ... }@args:
{
home.packages = map (x: if (builtins.isString x) then args.pkgs.${x} else x) (
ensureList packages ++ lib.optionals host.my.gui (ensureList guiPackages)
);
};
};The outer function requires only Your call site does not need to change; |
|
Hello, thanks for support, but I'm sorry to tell you that this fails too: I figured out I'll be using this workaround for now:
{ lib, ... }: {
options.libPath = lib.mkOption { type = lib.types.path; };
config.libPath = ./_lib.nix;
}
{
lib ? { },
}:
rec {
ensureList = x: if (builtins.isList x) then x else [ x ];
mkPkgAspect = packages: guiPackages: {
homeManager = { host, lib, pkgs, ... }: {
home.packages = map (x: if (builtins.isString x) then pkgs.${x} else x) (
ensureList packages ++ lib.optionals host.my.gui (ensureList guiPackages)
);
};
};
}
{ config, ... }: {
den.aspects.user.programs.groups.androidTools = (import config.libPath { }).mkPkgAspect "android-tools" "scrcpy";
}This way all of the arguments are passed properly and there's no import hell since the lib path is stored in config |
Uh oh!
There was an error while loading. Please reload this page.
I'm currently converting my flake-parts config to den. Now I'm trying to pass a common function as per #32:
here is an example aspect I use it in:
now apparently if I use
config,pkgsdon't get passed:when I define the function within a single file, everything works fine:
All reactions