treewide: migrate overlay autoloading to general mkTarget modules#2174
Conversation
Migrate the /modules/<MODULE>/overlay.nix overlay autoloading to general mkTarget modules by guarding them with the 'overlays' config argument. Closes: nix-community#2155
0xda157
left a comment
There was a problem hiding this comment.
stylix.overlays.enable should still be respected. I suspect this will also fix the checks failing.
Actually, none of the diff --git a/stylix/mk-target.nix b/stylix/mk-target.nix
index 2edf705d..5014f1c7 100644
--- a/stylix/mk-target.nix
+++ b/stylix/mk-target.nix
@@ -286,10 +286,19 @@ let
}`";
in
{
- enable = lib.mkEnableOption "${config} for ${humanName}" // {
- default = true;
- example = false;
- };
+ enable =
+ let
+ default =
+ if argument == "colors" then
+ config.lib.stylix.colors
+ else
+ config.stylix.${argument};
+ in
+ lib.mkEnableOption "${config} for ${humanName}"
+ // {
+ inherit default;
+ example = !default;
+ };
override = lib.mkOption {
default = null;Either way, the missing The infinite recursion error can be minimalistically removed from diff --git a/modules/gtksourceview/nixos.nix b/modules/gtksourceview/nixos.nix
index 48e93b2a..06df73ae 100644
--- a/modules/gtksourceview/nixos.nix
+++ b/modules/gtksourceview/nixos.nix
@@ -1,2 +1,2 @@
{ lib, mkTarget, ... }:
-mkTarget { config = import ./common.nix { inherit lib; }; }
+mkTarget { config = [ ]; }
diff --git a/modules/nixos-icons/nixos.nix b/modules/nixos-icons/nixos.nix
index eac5361b..229ff1dd 100644
--- a/modules/nixos-icons/nixos.nix
+++ b/modules/nixos-icons/nixos.nix
@@ -4,4 +4,4 @@
pkgs,
...
}:
-mkTarget { config = import ./common.nix { inherit lib pkgs; }; }
+mkTarget { config = [ ]; }However, neither diff --git a/modules/gtksourceview/hm.nix b/modules/gtksourceview/hm.nix
index eeebef4b..19cf5fd8 100644
--- a/modules/gtksourceview/hm.nix
+++ b/modules/gtksourceview/hm.nix
@@ -24,6 +24,5 @@ mkTarget {
);
}
)
- (import ./common.nix { inherit lib; })
];
}
diff --git a/modules/nixos-icons/hm.nix b/modules/nixos-icons/hm.nix
index eac5361b..229ff1dd 100644
--- a/modules/nixos-icons/hm.nix
+++ b/modules/nixos-icons/hm.nix
@@ -4,4 +4,4 @@
pkgs,
...
}:
-mkTarget { config = import ./common.nix { inherit lib pkgs; }; }
+mkTarget { config = [ ]; }While unconditional declaring diff --git a/modules/gtksourceview/nixos.nix b/modules/gtksourceview/nixos.nix
index 48e93b2a..c0fef191 100644
--- a/modules/gtksourceview/nixos.nix
+++ b/modules/gtksourceview/nixos.nix
@@ -1,2 +1,2 @@
{ lib, mkTarget, ... }:
-mkTarget { config = import ./common.nix { inherit lib; }; }
+mkTarget { config.nixpkgs.overlays = [ ]; }
diff --git a/modules/nixos-icons/nixos.nix b/modules/nixos-icons/nixos.nix
index eac5361b..7fee00fe 100644
--- a/modules/nixos-icons/nixos.nix
+++ b/modules/nixos-icons/nixos.nix
@@ -4,4 +4,4 @@
pkgs,
...
}:
-mkTarget { config = import ./common.nix { inherit lib pkgs; }; }
+mkTarget { config.nixpkgs.overlays = [ ]; }works, conditionally declaring them based on diff --git a/modules/gtksourceview/nixos.nix b/modules/gtksourceview/nixos.nix
index 48e93b2a..a5434397 100644
--- a/modules/gtksourceview/nixos.nix
+++ b/modules/gtksourceview/nixos.nix
@@ -1,2 +1,2 @@
{ lib, mkTarget, ... }:
-mkTarget { config = import ./common.nix { inherit lib; }; }
+mkTarget { config = { colors }: { nixpkgs.overlays = [ ]; }; }
diff --git a/modules/nixos-icons/nixos.nix b/modules/nixos-icons/nixos.nix
index eac5361b..b653e395 100644
--- a/modules/nixos-icons/nixos.nix
+++ b/modules/nixos-icons/nixos.nix
@@ -4,4 +4,4 @@
pkgs,
...
}:
-mkTarget { config = import ./common.nix { inherit lib pkgs; }; }
+mkTarget { config = { colors }: { nixpkgs.overlays = [ ]; }; }Note that conditionally declaring them based on diff --git a/modules/gtksourceview/nixos.nix b/modules/gtksourceview/nixos.nix
index 48e93b2a..deecf040 100644
--- a/modules/gtksourceview/nixos.nix
+++ b/modules/gtksourceview/nixos.nix
@@ -1,2 +1,2 @@
{ lib, mkTarget, ... }:
-mkTarget { config = import ./common.nix { inherit lib; }; }
+mkTarget { config = { overlays }: { nixpkgs.overlays = [ ]; }; }
diff --git a/modules/nixos-icons/nixos.nix b/modules/nixos-icons/nixos.nix
index eac5361b..90d28233 100644
--- a/modules/nixos-icons/nixos.nix
+++ b/modules/nixos-icons/nixos.nix
@@ -4,4 +4,4 @@
pkgs,
...
}:
-mkTarget { config = import ./common.nix { inherit lib pkgs; }; }
+mkTarget { config = { overlays }: { nixpkgs.overlays = [ ]; }; }
More specifically, I suspect the following infinite recursion caused by Indeed, the infinite recursion can be reproduced with either of the following patches on the master branch (aad90ca):
In other words, the infinite recursion error is not necessarily a technical limitation, but rather how we want to handle this from a design perspective. I suppose adding the |
Important
Although
nix build .#{doc,testbed:kitty:dark}works and the logic looks sound to me, this PR should be properly tested, especially with the/modules/{gtksourceview,nixos-icons}/modules having no testbeds.The
schemelesstestbeds are failing, which can be minimally reproduced in NixOS modules with the followingconfiggroup:Maybe the
colorsgenerated fromstylix.imageinfinite recurse withnixpkgs.overlaysdeclarations. I will try to look into this.CC: @0xda157, @OsiPog, @astreaprtcl