Skip to content

Commit

Permalink
treewide: image unnecessary
Browse files Browse the repository at this point in the history
  • Loading branch information
Flameopathic committed Jan 2, 2025
1 parent f48cab3 commit 2b2b059
Show file tree
Hide file tree
Showing 13 changed files with 32 additions and 14 deletions.
1 change: 1 addition & 0 deletions modules/feh/hm.nix
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
lib.mkIf (
config.stylix.enable
&& config.stylix.targets.feh.enable
&& config.stylix.image != null
&& (
with config.xsession.windowManager;
bspwm.enable
Expand Down
1 change: 1 addition & 0 deletions modules/feh/nixos.nix
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
lib.mkIf (
config.stylix.enable
&& config.stylix.targets.feh.enable
&& config.stylix.image != null
&& (
with config.services.xserver.windowManager;
xmonad.enable
Expand Down
4 changes: 2 additions & 2 deletions modules/gnome/hm.nix
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,8 @@ in {
then "centered"
# Seemingly no tile support... :(
else "zoom";
picture-uri = "file://${config.stylix.image}";
picture-uri-dark = "file://${config.stylix.image}";
picture-uri = lib.mkIf (config.stylix.image != null) "file://${config.stylix.image}";
picture-uri-dark = lib.mkIf (config.stylix.image != null) "file://${config.stylix.image}";
};

"org/gnome/desktop/interface" = {
Expand Down
2 changes: 1 addition & 1 deletion modules/grub/nixos.nix
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ in {
mkdir $out
cp $themeTxtPath $out/theme.txt
${if config.stylix.targets.grub.useImage
${if config.stylix.targets.grub.useImage && config.stylix.image != null
# Make sure the background image is .png by asking to convert it
then
"${pkgs.imagemagick}/bin/convert ${config.stylix.image} png32:$out/background.png"
Expand Down
5 changes: 4 additions & 1 deletion modules/hyprlock/hm.nix
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,10 @@ with config.lib.stylix;

config = lib.mkIf (config.stylix.enable && config.stylix.targets.hyprlock.enable) {
programs.hyprlock.settings = {
background.path = "${config.stylix.image}";
background = {
path = lib.mkIf (config.stylix.image != null) config.stylix.image;
color = "rgb(${base00})";
};
input-field = with colors; {
outer_color = "rgb(${base03})";
inner_color = "rgb(${base00})";
Expand Down
2 changes: 1 addition & 1 deletion modules/hyprpaper/hm.nix
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

config =
lib.mkIf
(config.stylix.enable && config.stylix.targets.hyprpaper.enable)
(config.stylix.enable && config.stylix.targets.hyprpaper.enable && config.stylix.image != null)
{
services.hyprpaper.settings = {
preload = [ "${config.stylix.image}" ];
Expand Down
2 changes: 1 addition & 1 deletion modules/lightdm/nixos.nix
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,5 @@
config.lib.stylix.mkEnableTarget "LightDM" true;

config.services.xserver.displayManager.lightdm.background =
lib.mkIf (config.stylix.enable && config.stylix.targets.lightdm.enable) config.stylix.image;
lib.mkIf (config.stylix.enable && config.stylix.targets.lightdm.enable && config.stylix.image != null) config.stylix.image;
}
2 changes: 1 addition & 1 deletion modules/regreet/nixos.nix
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
(config.stylix.enable && config.stylix.targets.regreet.enable && pkgs.stdenv.hostPlatform.isLinux)
{
programs.regreet = {
settings.background = {
settings.background = lib.mkIf (config.stylix.image != null) {
path = config.stylix.image;
fit = let
inherit (config.stylix) imageScalingMode;
Expand Down
2 changes: 1 addition & 1 deletion modules/sway/hm.nix
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ in {
};
};

output."*".bg = "${config.stylix.image} ${config.stylix.imageScalingMode}";
output."*".bg = lib.mkIf (config.stylix.image != null) "${config.stylix.image} ${config.stylix.imageScalingMode}";
seat."*".xcursor_theme = ''"${config.stylix.cursor.name}" ${toString config.stylix.cursor.size}'';
};
})
Expand Down
2 changes: 1 addition & 1 deletion modules/swaylock/hm.nix
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ in {
text-caps-lock-color = text;
text-ver-color = text;
text-wrong-color = text;
} // lib.optionalAttrs config.stylix.targets.swaylock.useImage {
} // lib.optionalAttrs config.stylix.targets.swaylock.useImage && config.stylix.image != null {
image = "${config.stylix.image}";
};
};
Expand Down
2 changes: 1 addition & 1 deletion modules/wpaperd/hm.nix
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
{
options.stylix.targets.wpaperd.enable = config.lib.stylix.mkEnableTarget "wpaperd" true;

config = lib.mkIf (config.stylix.enable && config.stylix.targets.wpaperd.enable) {
config = lib.mkIf (config.stylix.enable && config.stylix.targets.wpaperd.enable && config.stylix.image != null ) {
programs.wpaperd.settings.any = {
path = "${config.stylix.image}";
mode = let
Expand Down
16 changes: 12 additions & 4 deletions stylix/palette.nix
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
let
cfg = config.stylix;

paletteJSON = let
paletteJSON = lib.mkIf (cfg.image != null) ( let
generatedJSON = pkgs.runCommand "palette.json" { } ''
${palette-generator}/bin/palette-generator \
"${cfg.polarity}" \
Expand All @@ -17,7 +17,7 @@ let
template = ./palette.json.mustache;
extension = ".json";
};
in json;
in json);
generatedScheme = lib.importJSON paletteJSON;

in {
Expand All @@ -35,7 +35,7 @@ in {
};

image = lib.mkOption {
type = with lib.types; coercedTo package toString path;
type = with lib.types; nullOr (coercedTo package toString path);
description = ''
Wallpaper image.
Expand Down Expand Up @@ -99,7 +99,7 @@ in {
This can be a path to a file, a string of YAML, or an attribute set.
'';
type = with lib.types; oneOf [ path lines attrs ];
default = generatedScheme;
default = lib.mkIf (cfg.image != null) generatedScheme;
defaultText = lib.literalMD ''
The colors used in the theming.
Expand All @@ -124,6 +124,14 @@ in {
config = {
# This attrset can be used like a function too, see
# https://github.com/SenchoPens/base16.nix/blob/b390e87cd404e65ab4d786666351f1292e89162a/README.md#theme-step-22

assertions = [
{
assertion = cfg.image != null || cfg.base16Scheme != null;
message = "One of `stylix.image` or `stylix.base16Scheme` must be set";
}
];

lib.stylix.colors = (base16.mkSchemeAttrs cfg.base16Scheme).override cfg.override;
lib.stylix.scheme = base16.mkSchemeAttrs cfg.base16Scheme;

Expand Down
5 changes: 5 additions & 0 deletions stylix/testbed.nix
Original file line number Diff line number Diff line change
Expand Up @@ -158,6 +158,11 @@ let
base16Scheme = "${pkgs.base16-schemes}/share/themes/catppuccin-macchiato.yaml";
polarity = "dark";
}
{
enable = true;
base16Scheme = "${pkgs.base16-schemes}/share/themes/catppuccin-macchiato.yaml";
polarity = "dark";
}
];

in
Expand Down

0 comments on commit 2b2b059

Please sign in to comment.