Avoiding duplicates with den.lib.parametric
#99
-
|
It seems that when using eg: den.aspects.wayland._.cosmic = den.lib.parametric {
includes = [ den.aspects.wayland._.base ];
homeManager =
{ pkgs, lib, ... }:
{
gtk.iconTheme = {
name = lib.mkForce "Cosmic";
package = lib.mkForce pkgs.cosmic-icons;
};
};
};Error: I found that moving the homeManager config to the includes fixed this: den.aspects.wayland._.cosmic = den.lib.parametric {
includes = [
den.aspects.wayland._.base
(
{ host, ... }:
{
homeManager =
{ pkgs, lib, ... }:
{
xdg.configFile = {
# using cosmics automatic gtk theming
"gtk-4.0/assets".enable = false;
"gtk-4.0/gtk.css".enable = false;
"gtk-4.0/gtk-dark.css".enable = false;
};
gtk.iconTheme = {
name = lib.mkForce "Cosmic";
package = lib.mkForce pkgs.cosmic-icons;
};
};
}
)
];
};I wanted to see if there was a better solution. |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 13 replies
-
|
Minimal example here: https://github.com/michaelBelsanti/bogus-den/tree/withown-dupes |
Beta Was this translation helpful? Give feedback.
-
|
I was able to create a failing test, by using a home-manager option. So the home-manager integration gets tested, all previous tests were OS-level configs. here's the diffdiff --git a/templates/examples/foo.patch b/templates/examples/foo.patch
new file mode 100644
index 0000000000..e69de29bb2
diff --git a/templates/examples/modules/_example/ci/parametric-with-owned.nix b/templates/examples/modules/_example/ci/parametric-with-owned.nix
index 708150c5b4..6b69534026 100644
--- a/templates/examples/modules/_example/ci/parametric-with-owned.nix
+++ b/templates/examples/modules/_example/ci/parametric-with-owned.nix
@@ -1,7 +1,7 @@
{ den, lib, ... }:
let
# a test module to check context was forwarded
- fwdModule.nixos.options.fwd = {
+ fwdModule.options.fwd = {
a = strOpt;
b = strOpt;
c = strOpt;
@@ -19,10 +19,12 @@
{
den.aspects.rockhopper.includes = [
- fwdModule
+ { nixos.imports = [ fwdModule ]; }
+ { homeManager.imports = [ fwdModule ]; }
den.aspects.fwd._.first
];
den.aspects.rockhopper.nixos.fwd.c = "host owned C";
+ den.aspects.rockhopper.homeManager.fwd.a = "host home-managed A";
# this aspect will take any context and also forward it
# into any includes function that can take same context.
@@ -33,6 +35,11 @@
fwd.a = "First owned A";
fwd.pkg = pkgs.hello;
};
+ homeManager =
+ { pkgs, ... }:
+ {
+ fwd.pkg = pkgs.vim;
+ };
includes = [
den.aspects.fwd._.second
{ nixos.fwd.d = "First static includes D"; }
@@ -73,7 +80,12 @@
};
perSystem =
- { checkCond, rockhopper, ... }:
+ {
+ checkCond,
+ rockhopper,
+ alice-at-rockhopper,
+ ...
+ }:
{
checks.parametric-fwd-a = checkCond "fwd-a" (rockhopper.config.fwd.a == "First owned A");
checks.parametric-fwd-b = checkCond "fwd-b" (
@@ -84,6 +96,13 @@
checks.parametric-fwd-e = checkCond "fwd-e" (rockhopper.config.fwd.e == "Third Impact");
checks.parametric-fwd-f = checkCond "fwd-f" (rockhopper.config.fwd.f == "Fifth Earth rockhopper");
checks.parametric-fwd-pkg = checkCond "fwd-pkg" (lib.getName rockhopper.config.fwd.pkg == "hello");
+
+ checks.parametric-fwd-hm-a = checkCond "fwd-hm-a" (
+ alice-at-rockhopper.fwd.a == "host home-managed A"
+ );
+ checks.parametric-fwd-hm-pkg = checkCond "fwd-hm-pkg" (
+ lib.getName alice-at-rockhopper.fwd.pkg == "vim"
+ );
};
}and error: error: The option `home-manager.users.alice.fwd.pkg' is defined multiple times while it's expected to be unique.
Definition values:
- In `<unknown-file>, via option den.aspects.fwd.provides.first.<function body>.includes."[definition 1-entry 2]".includes."[definition 1-entry 1]".homeManager': <derivation vim-9.1.1833>
- In `<unknown-file>, via option den.aspects.fwd.provides.first.<function body>.includes."[definition 1-entry 2]".includes."[definition 1-entry 1]".homeManager': <derivation vim-9.1.1833>
Use `lib.mkForce value` or `lib.mkDefault value` to change the priority on any of these definitions. |
Beta Was this translation helpful? Give feedback.
Fixed and tested at #105