diff --git a/modules/feh/hm.nix b/modules/feh/hm.nix index 3642ec69..b6e13464 100644 --- a/modules/feh/hm.nix +++ b/modules/feh/hm.nix @@ -19,5 +19,5 @@ || xmonad.enable ) ) - "${pkgs.feh}/bin/feh --no-fehbg --bg-scale ${config.stylix.image}"; + "${pkgs.feh}/bin/feh --no-fehbg --bg-scale ${config.stylix.generated.image}"; } diff --git a/modules/feh/nixos.nix b/modules/feh/nixos.nix index 2826af18..3c7290eb 100644 --- a/modules/feh/nixos.nix +++ b/modules/feh/nixos.nix @@ -16,5 +16,5 @@ || i3.enable ) ) - "${pkgs.feh}/bin/feh --no-fehbg --bg-scale ${config.stylix.image}"; + "${pkgs.feh}/bin/feh --no-fehbg --bg-scale ${config.stylix.generated.image}"; } diff --git a/modules/gnome/hm.nix b/modules/gnome/hm.nix index ea98eccc..7d5be376 100644 --- a/modules/gnome/hm.nix +++ b/modules/gnome/hm.nix @@ -14,8 +14,8 @@ in { "org/gnome/desktop/background" = { color-shading-type = "solid"; picture-options = "zoom"; - picture-uri = "file://${config.stylix.image}"; - picture-uri-dark = "file://${config.stylix.image}"; + picture-uri = "file://${config.stylix.generated.image}"; + picture-uri-dark = "file://${config.stylix.generated.image}"; }; "org/gnome/desktop/interface" = { diff --git a/modules/grub/nixos.nix b/modules/grub/nixos.nix index f90df7cf..feb305dc 100644 --- a/modules/grub/nixos.nix +++ b/modules/grub/nixos.nix @@ -99,7 +99,7 @@ in { ${if config.stylix.targets.grub.useImage # Make sure the background image is .png by asking to convert it then - "${pkgs.imagemagick}/bin/convert ${config.stylix.image} png32:$out/background.png" + "${pkgs.imagemagick}/bin/convert ${config.stylix.generated.image} png32:$out/background.png" else "cp ${pixel "base00"} $out/background.png"} diff --git a/modules/hyprpaper/hm.nix b/modules/hyprpaper/hm.nix index dbb7b08a..1357f858 100644 --- a/modules/hyprpaper/hm.nix +++ b/modules/hyprpaper/hm.nix @@ -7,8 +7,8 @@ (config.stylix.enable && config.stylix.targets.hyprpaper.enable) { services.hyprpaper.settings = { - preload = [ "${config.stylix.image}" ]; - wallpaper = [ ",${config.stylix.image}" ]; + preload = [ "${config.stylix.generated.image}" ]; + wallpaper = [ ",${config.stylix.generated.image}" ]; }; }; } diff --git a/modules/i3/hm.nix b/modules/i3/hm.nix index 6004e1cc..6a5b3469 100644 --- a/modules/i3/hm.nix +++ b/modules/i3/hm.nix @@ -56,7 +56,7 @@ in { }; }; -# output."*".bg = "${config.stylix.image} fill"; +# output."*".bg = "${config.stylix.generated.image} fill"; }; }) diff --git a/modules/kde/hm.nix b/modules/kde/hm.nix index d7d7f64c..c78c6b9b 100644 --- a/modules/kde/hm.nix +++ b/modules/kde/hm.nix @@ -143,7 +143,7 @@ let themePackage = pkgs.runCommandLocal "stylix-kde-theme" { colorscheme = formatConfig colorscheme; wallpaperMetadata = builtins.toJSON wallpaperMetadata; - wallpaperImage = config.stylix.image; + wallpaperImage = config.stylix.generated.image; lookAndFeelMetadata = builtins.toJSON lookAndFeelMetadata; lookAndFeelDefaults = formatConfig lookAndFeelDefaults; } '' diff --git a/modules/lightdm/nixos.nix b/modules/lightdm/nixos.nix index e0ea1d38..632300fb 100644 --- a/modules/lightdm/nixos.nix +++ b/modules/lightdm/nixos.nix @@ -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.generated.image; } diff --git a/modules/regreet/nixos.nix b/modules/regreet/nixos.nix index a9c76da3..5b278efe 100644 --- a/modules/regreet/nixos.nix +++ b/modules/regreet/nixos.nix @@ -13,7 +13,7 @@ (config.stylix.enable && config.stylix.targets.regreet.enable && pkgs.stdenv.hostPlatform.isLinux) { programs.regreet = { - settings.background.path = config.stylix.image; + settings.background.path = config.stylix.generated.image; font = { inherit (config.stylix.fonts.sansSerif) name package; }; diff --git a/modules/sway/hm.nix b/modules/sway/hm.nix index 1da892e2..cb0347b1 100644 --- a/modules/sway/hm.nix +++ b/modules/sway/hm.nix @@ -54,7 +54,7 @@ in { }; }; - output."*".bg = "${config.stylix.image} ${config.stylix.imageScalingMode}"; + output."*".bg = "${config.stylix.generated.image} ${config.stylix.imageScalingMode}"; seat."*" = { xcursor_theme = "${config.stylix.cursor.name} ${toString config.stylix.cursor.size}"; diff --git a/modules/swaylock/hm.nix b/modules/swaylock/hm.nix index 7bde8960..cd84cc17 100644 --- a/modules/swaylock/hm.nix +++ b/modules/swaylock/hm.nix @@ -49,7 +49,7 @@ in { text-ver-color = text; text-wrong-color = text; } // lib.optionalAttrs config.stylix.targets.swaylock.useImage { - image = "${config.stylix.image}"; + image = "${config.stylix.generated.image}"; }; }; } diff --git a/modules/wpaperd/hm.nix b/modules/wpaperd/hm.nix index 7008593a..3a6f9320 100644 --- a/modules/wpaperd/hm.nix +++ b/modules/wpaperd/hm.nix @@ -4,6 +4,6 @@ options.stylix.targets.wpaperd.enable = config.lib.stylix.mkEnableTarget "wpaperd" true; config = lib.mkIf (config.stylix.enable && config.stylix.targets.wpaperd.enable) { - programs.wpaperd.settings.any.path = "${config.stylix.image}"; + programs.wpaperd.settings.any.path = "${config.stylix.generated.image}"; }; } diff --git a/stylix/home-manager-integration.nix b/stylix/home-manager-integration.nix index 5afe202b..30a6a815 100644 --- a/stylix/home-manager-integration.nix +++ b/stylix/home-manager-integration.nix @@ -28,6 +28,8 @@ let { path = [ "stylix" "fonts" "sizes" "terminal" ]; } { path = [ "stylix" "fonts" "sizes" "popups" ]; } { path = [ "stylix" "image" ]; } + { path = [ "stylix" "imageEditor" "enable"]; } + { path = [ "stylix" "imageEditor" "method"]; } { path = [ "stylix" "imageScalingMode" ]; } { path = [ "stylix" "opacity" "desktop" ]; } { path = [ "stylix" "opacity" "applications" ]; } diff --git a/stylix/image-editors/default.nix b/stylix/image-editors/default.nix new file mode 100644 index 00000000..494e3a24 --- /dev/null +++ b/stylix/image-editors/default.nix @@ -0,0 +1,11 @@ +{ + config, + lib, + pkgs, + ... +}: +{ + config.lib.stylix.imageEditors = { + lutgen = import ./lutgen.nix { inherit lib config pkgs; }; + }; +} diff --git a/stylix/image-editors/lutgen.nix b/stylix/image-editors/lutgen.nix new file mode 100644 index 00000000..62982910 --- /dev/null +++ b/stylix/image-editors/lutgen.nix @@ -0,0 +1,14 @@ +{ + lib, + config, + pkgs, + ... +}: +img: +let + colors = lib.strings.concatStringsSep " " config.lib.stylix.colors.toList; + baseName = builtins.baseNameOf img; +in +pkgs.runCommand baseName { } '' + ${pkgs.lutgen}/bin/lutgen apply '${img}' --output "$out" -- ${colors} +'' diff --git a/stylix/palette.nix b/stylix/palette.nix index 7fe9600a..8974058b 100644 --- a/stylix/palette.nix +++ b/stylix/palette.nix @@ -21,6 +21,56 @@ let generatedScheme = lib.importJSON paletteJSON; in { + imports = [ + ./image-editors + (lib.mkRemovedOptionModule [ "stylix" "palette" "base00" ] "Using stylix.palette to override scheme is not supported anymore") + + # Added: 2023-02-02 + (lib.mkRemovedOptionModule [ "stylix" "palette" "base01" ] "Using stylix.palette to override scheme is not supported anymore") + + # Added: 2023-02-02 + (lib.mkRemovedOptionModule [ "stylix" "palette" "base02" ] "Using stylix.palette to override scheme is not supported anymore") + + # Added: 2023-02-02 + (lib.mkRemovedOptionModule [ "stylix" "palette" "base03" ] "Using stylix.palette to override scheme is not supported anymore") + + # Added: 2023-02-02 + (lib.mkRemovedOptionModule [ "stylix" "palette" "base04" ] "Using stylix.palette to override scheme is not supported anymore") + + # Added: 2023-02-02 + (lib.mkRemovedOptionModule [ "stylix" "palette" "base05" ] "Using stylix.palette to override scheme is not supported anymore") + + # Added: 2023-02-02 + (lib.mkRemovedOptionModule [ "stylix" "palette" "base06" ] "Using stylix.palette to override scheme is not supported anymore") + + # Added: 2023-02-02 + (lib.mkRemovedOptionModule [ "stylix" "palette" "base07" ] "Using stylix.palette to override scheme is not supported anymore") + + # Added: 2023-02-02 + (lib.mkRemovedOptionModule [ "stylix" "palette" "base08" ] "Using stylix.palette to override scheme is not supported anymore") + + # Added: 2023-02-02 + (lib.mkRemovedOptionModule [ "stylix" "palette" "base09" ] "Using stylix.palette to override scheme is not supported anymore") + + # Added: 2023-02-02 + (lib.mkRemovedOptionModule [ "stylix" "palette" "base0A" ] "Using stylix.palette to override scheme is not supported anymore") + + # Added: 2023-02-02 + (lib.mkRemovedOptionModule [ "stylix" "palette" "base0B" ] "Using stylix.palette to override scheme is not supported anymore") + + # Added: 2023-02-02 + (lib.mkRemovedOptionModule [ "stylix" "palette" "base0C" ] "Using stylix.palette to override scheme is not supported anymore") + + # Added: 2023-02-02 + (lib.mkRemovedOptionModule [ "stylix" "palette" "base0D" ] "Using stylix.palette to override scheme is not supported anymore") + + # Added: 2023-02-02 + (lib.mkRemovedOptionModule [ "stylix" "palette" "base0E" ] "Using stylix.palette to override scheme is not supported anymore") + + # Added: 2023-02-02 + (lib.mkRemovedOptionModule [ "stylix" "palette" "base0F" ] "Using stylix.palette to override scheme is not supported anymore") + ]; + options.stylix = { polarity = lib.mkOption { type = lib.types.enum [ "either" "light" "dark" ]; @@ -55,6 +105,17 @@ in { ''; }; + imageEditor = { + enable = lib.mkEnableOption "Update `stylix.image` by applying `stylix.imageEditor.method` to the image"; + + method = lib.mkOption { + type = with lib.types; functionTo (coercedTo package toString path); + default = config.lib.stylix.imageEditors.lutgen; + description = "Edits the given `stylix.image` argument, outputs to `stylix.generated.image`"; + example = "config.lib.stylix.imageEditors.lutgen;"; + }; + }; + generated = { json = lib.mkOption { type = lib.types.path; @@ -78,6 +139,14 @@ in { readOnly = true; internal = true; }; + + image = lib.mkOption { + type = with lib.types; coercedTo package toString path; + default = cfg.image; + readOnly = true; + internal = true; + apply = img: if cfg.imageEditor.enable then cfg.imageEditor.method img else img; + }; }; base16Scheme = lib.mkOption {