stylix: add imports to mkTarget#1363
Conversation
7f9cd69 to
04c67c2
Compare
One approach would be to have Or maybe that doesn't make sense because not all imports will need an enable option. If so, perhaps A "part" could have extra options, config elements, and imports. A "whole" target has those and also an enable option. Although it'd be better if we don't need this complexity. I.e. if |
I was think adding imports so we could use mkRenamedOption and mkRemovedOption, I don't think adding |
Ah. That makes sense. If you want to prevent importing arbitrary modules, but want to support renaming or removing options, the only way I can think of is by having I.e. adding a However this won't scale well as you'd have to have a hard-coded attr for each function you wanted to support. E.g. mkChangedOptionModule, mkMergedOptionModule, mkAliasOptionModule, etc are used less often, but would need changes to mkTarget if you ever needed to use them. You could have a more flexible design, by having a single option whose entries specify the function used: Which is still kinda clunky, but provides a nice middle ground of not being too inflexible while still restricting to |
|
The way I envisioned this working was basically as follows: { mkTarget, lib, ... }:
{
imports = [
/* etc */
];
} // mkTarget { /* etc */ }I don't see a reason to limit what people can import or make warnings for; are there any other reasons that this pattern would be undesirable (or possibly non-functional)? |
Manually having to call mkTarget is bad ux and we should remove it once we've transferred all the modules to mkTarget (if they can all be transferred to mkTarget). Treating mkTarget as something you merge with the rest of the module seems really janky and undesirable in the mean time. In my view the final form of mkTarget would be each module is either or e.g. { lib, pkgs }:
{
name = "foo";
humanName = "Foo";
configElements = [ ];
}or { lib, pkgs }:
map
(
{ name, humanName }:
{
inherit name humanName;
configElements = [ ];
}
)
[
{
name = "foo";
humanName = "Foo";
}
{
name = "bar";
humanName = "Bar";
}
] |
Yes, this seems like the easiest way to scale this, while ensuring
Although, this mkTarget {
imports.mkRenamedOptionModule = [[[ "foo" "bar" ] [ "x" "y" ]]];
}
For reference, this differs from my proposal in #1341 (comment) by not treating "simple" modules as pure attribute sets. |
04c67c2 to
496a1d5
Compare
I see what you mean. In that case, I support this PR as-is, as I do not see a reason to limit what can be imported. |
There was a problem hiding this comment.
I don't see a reason to limit what people can import or make warnings for; are there any other reasons that this pattern would be undesirable (or possibly non-functional)?
Manually having to call mkTarget is bad ux and we should remove it once we've transferred all the modules to mkTarget (if they an all be transferred to mkTarget). Treating mkTarget as something you merge with the rest of the module seems really janky and undesirable in the mean time.
I see what you mean. In that case, I support this PR as-is, as I do not see a reason to limit what can be imported.
Considering the ongoing mkTarget migration may require this functionality, I am fine interfacing imports for now and potentially polishing this in the future: #1363 (comment).
|
Successfully created backport PR for |
Fixes: 093087e ("stylix: add imports to mkTarget (nix-community#1363)")
Fixes: 093087e ("stylix: add imports to mkTarget (nix-community#1363)")
Fixes: 093087e ("stylix: add imports to mkTarget (nix-community#1363)")
Fixes: 093087e ("stylix: add imports to mkTarget (nix-community#1363)")
Fixes: 093087e ("stylix: add imports to mkTarget (nix-community#1363)")
Fixes: 093087e ("stylix: add imports to mkTarget (nix-community#1363)")
Fixes: 093087e ("stylix: add imports to mkTarget (nix-community#1363)")
Fixes: 093087e ("stylix: add imports to mkTarget (nix-community#1363)")
Fixes: 093087e ("stylix: add imports to mkTarget (nix-community#1363)") (cherry picked from commit 9afd823)
Fixes: 093087e ("stylix: add imports to mkTarget (nix-community#1363)")
imports is necessary for renamed/removed options. Note that imports is "unsafe" and might cause failure to check
!= null(maybe a different way would be better?)cc @trueNAHO @MattSturgeon @Flameopathic
Things done
Notify maintainers