Skip to content

Commit

Permalink
treewide: add overlays option
Browse files Browse the repository at this point in the history
Adds the `stylix.overlays.enable` option which can be disabled to
remove all overlays. This is to handle scenarios where overlays cannot
be set, because the configuration doesn't handle its own nixpkgs
instance. Fixes danth#865.
  • Loading branch information
brckd committed Feb 24, 2025
1 parent d1a382a commit 21a3f63
Show file tree
Hide file tree
Showing 5 changed files with 48 additions and 21 deletions.
30 changes: 16 additions & 14 deletions modules/gnome-text-editor/common.nix
Original file line number Diff line number Diff line change
Expand Up @@ -10,19 +10,21 @@ in
options.stylix.targets.gnome-text-editor.enable =
config.lib.stylix.mkEnableTarget "GNOME Text Editor" true;

config =
config.nixpkgs.overlays =
lib.mkIf
(config.stylix.enable && config.stylix.targets.gnome-text-editor.enable)
{
nixpkgs.overlays = [
(_: prev: {
gnome-text-editor = prev.gnome-text-editor.overrideAttrs (oldAttrs: {
postFixup = ''
${oldAttrs.postFixup or ""}
cp ${style} $out/share/gnome-text-editor/styles/stylix.xml
'';
});
})
];
};
(
config.stylix.enable
&& config.stylix.targets.gnome-text-editor.enable
&& config.stylix.overlays.enable
)
[
(_: prev: {
gnome-text-editor = prev.gnome-text-editor.overrideAttrs (oldAttrs: {
postFixup = ''
${oldAttrs.postFixup or ""}
cp ${style} $out/share/gnome-text-editor/styles/stylix.xml
'';
});
})
];
}
2 changes: 1 addition & 1 deletion modules/gnome/nixos.nix
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ in
# which will then download the pack regardless of its exclusion below.
environment.gnome.excludePackages = [ pkgs.gnome-backgrounds ];

nixpkgs.overlays = [
nixpkgs.overlays = lib.mkIf config.stylix.overlays.enable [
(_: super: {
gnome-shell = super.gnome-shell.overrideAttrs (oldAttrs: {
# Themes are usually applied via an extension, but extensions are
Expand Down
7 changes: 6 additions & 1 deletion modules/nixos-icons/nixos.nix
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,12 @@ with config.lib.stylix.colors;
config.lib.stylix.mkEnableTarget "the NixOS logo" true;

config.nixpkgs.overlays =
lib.mkIf (config.stylix.enable && config.stylix.targets.nixos-icons.enable)
lib.mkIf
(
config.stylix.enable
&& config.stylix.targets.nixos-icons.enable
&& config.stylix.overlays.enable
)
[
(_: super: {
nixos-icons = super.nixos-icons.overrideAttrs (oldAttrs: {
Expand Down
19 changes: 14 additions & 5 deletions stylix/home-manager-integration.nix
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,10 @@
}:

let
disableOverlaysModule = {
config.stylix.overlays.enable = false;
};

copyModules =
builtins.map
(
Expand Down Expand Up @@ -222,10 +226,15 @@ in
};

config = lib.optionalAttrs (options ? home-manager) (
lib.mkIf config.stylix.homeManagerIntegration.autoImport {
home-manager.sharedModules =
[ config.stylix.homeManagerIntegration.module ]
++ (lib.optionals config.stylix.homeManagerIntegration.followSystem copyModules);
}
lib.mkMerge [
(lib.mkIf config.stylix.homeManagerIntegration.autoImport {
home-manager.sharedModules =
[ config.stylix.homeManagerIntegration.module ]
++ (lib.optionals config.stylix.homeManagerIntegration.followSystem copyModules);
})
(lib.mkIf config.home-manager.useGlobalPkgs {
home-manager.sharedModules = [ disableOverlaysModule ];
})
]
);
}
11 changes: 11 additions & 0 deletions stylix/target.nix
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,17 @@
default = true;
example = false;
};

overlays.enable = lib.mkOption {
description = ''
Whether to enable overlays.
When this is `false`, no overlays are set. This may be required if the configuration doesn't manage its own nixpkgs instance.
'';
type = lib.types.bool;
default = true;
example = false;
};
};

config.lib.stylix =
Expand Down

0 comments on commit 21a3f63

Please sign in to comment.