From 1ab29586606700fc2a2df8dea147c85a7eea6309 Mon Sep 17 00:00:00 2001 From: Melody Renata Date: Sat, 20 Jul 2024 20:05:01 -0400 Subject: [PATCH 1/6] treewide: implement image editor --- modules/feh/hm.nix | 2 +- modules/feh/nixos.nix | 2 +- modules/gnome/hm.nix | 4 +- modules/grub/nixos.nix | 2 +- modules/hyprpaper/hm.nix | 4 +- modules/i3/hm.nix | 2 +- modules/kde/hm.nix | 2 +- modules/lightdm/nixos.nix | 2 +- modules/sway/hm.nix | 2 +- modules/swaylock/hm.nix | 2 +- modules/wpaperd/hm.nix | 2 +- stylix/home-manager-integration.nix | 2 + stylix/image-editors/default.nix | 11 ++++ stylix/image-editors/lutgen.nix | 14 +++++ stylix/palette.nix | 87 ++++++++++++++++++++++++++++- 15 files changed, 125 insertions(+), 15 deletions(-) create mode 100644 stylix/image-editors/default.nix create mode 100644 stylix/image-editors/lutgen.nix 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/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..cce007d4 --- /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}' -o $out -- ${colors} +'' diff --git a/stylix/palette.nix b/stylix/palette.nix index 7fe9600a..2f6ed2ee 100644 --- a/stylix/palette.nix +++ b/stylix/palette.nix @@ -1,5 +1,10 @@ { palette-generator, base16 }: -{ pkgs, lib, config, ... }: +{ + pkgs, + lib, + config, + ... +}: let cfg = config.stylix; @@ -20,7 +25,58 @@ let in json; generatedScheme = lib.importJSON paletteJSON; -in { +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" ]; @@ -54,6 +110,26 @@ in { doesnt fix your monitor perfectly ''; }; + imageEditor = { + enable = lib.mkOption { + type = lib.types.bool; + default = false; + description = '' + Update Wallpaper by applying a lut filter to the image + ''; + }; + method = lib.mkOption { + type = with lib.types; functionTo (coercedTo package toString path); + default = config.lib.stylix.imageEditors.lutgen; + description = '' + A function to edit the image, takes one argument (the image) + and returns the resulting edited image + ''; + example = '' + config.stylix.imageEditor.method = config.lib.stylix.imageEditors.lutgen; + ''; + }; + }; generated = { json = lib.mkOption { @@ -78,6 +154,13 @@ 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 { From 7bb1143ab2ae506abe2845611c2feb40c2860879 Mon Sep 17 00:00:00 2001 From: NAHO <90870942+trueNAHO@users.noreply.github.com> Date: Sun, 21 Jul 2024 16:11:29 +0200 Subject: [PATCH 2/6] stylix: revert formatting --- stylix/palette.nix | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/stylix/palette.nix b/stylix/palette.nix index 2f6ed2ee..c4a62828 100644 --- a/stylix/palette.nix +++ b/stylix/palette.nix @@ -1,10 +1,5 @@ { palette-generator, base16 }: -{ - pkgs, - lib, - config, - ... -}: +{ pkgs, lib, config, ... }: let cfg = config.stylix; From f366d371b42e466942b3cdec6a605128571c5124 Mon Sep 17 00:00:00 2001 From: NAHO <90870942+trueNAHO@users.noreply.github.com> Date: Sun, 21 Jul 2024 16:11:45 +0200 Subject: [PATCH 3/6] stylix: improve formatting --- stylix/palette.nix | 1 + 1 file changed, 1 insertion(+) diff --git a/stylix/palette.nix b/stylix/palette.nix index c4a62828..79a1aeca 100644 --- a/stylix/palette.nix +++ b/stylix/palette.nix @@ -149,6 +149,7 @@ in readOnly = true; internal = true; }; + image = lib.mkOption { type = with lib.types; coercedTo package toString path; default = cfg.image; From 7f9272ab17613fc6c76f623b8336f0025726a8e8 Mon Sep 17 00:00:00 2001 From: NAHO <90870942+trueNAHO@users.noreply.github.com> Date: Sun, 21 Jul 2024 16:11:58 +0200 Subject: [PATCH 4/6] stylix: improve formatting --- stylix/palette.nix | 1 + 1 file changed, 1 insertion(+) diff --git a/stylix/palette.nix b/stylix/palette.nix index 79a1aeca..d082dcc0 100644 --- a/stylix/palette.nix +++ b/stylix/palette.nix @@ -113,6 +113,7 @@ in Update Wallpaper by applying a lut filter to the image ''; }; + method = lib.mkOption { type = with lib.types; functionTo (coercedTo package toString path); default = config.lib.stylix.imageEditors.lutgen; From 206ba7b79b47030e894f3310333804916e799dc2 Mon Sep 17 00:00:00 2001 From: Melody Renata Date: Wed, 7 Aug 2024 13:09:47 -0400 Subject: [PATCH 5/6] stylix: improve formatting --- stylix/image-editors/lutgen.nix | 2 +- stylix/palette.nix | 21 +++++---------------- 2 files changed, 6 insertions(+), 17 deletions(-) diff --git a/stylix/image-editors/lutgen.nix b/stylix/image-editors/lutgen.nix index cce007d4..62982910 100644 --- a/stylix/image-editors/lutgen.nix +++ b/stylix/image-editors/lutgen.nix @@ -10,5 +10,5 @@ let baseName = builtins.baseNameOf img; in pkgs.runCommand baseName { } '' - ${pkgs.lutgen}/bin/lutgen apply '${img}' -o $out -- ${colors} + ${pkgs.lutgen}/bin/lutgen apply '${img}' --output "$out" -- ${colors} '' diff --git a/stylix/palette.nix b/stylix/palette.nix index d082dcc0..8974058b 100644 --- a/stylix/palette.nix +++ b/stylix/palette.nix @@ -20,8 +20,7 @@ let in json; generatedScheme = lib.importJSON paletteJSON; -in -{ +in { imports = [ ./image-editors (lib.mkRemovedOptionModule [ "stylix" "palette" "base00" ] "Using stylix.palette to override scheme is not supported anymore") @@ -105,25 +104,15 @@ in doesnt fix your monitor perfectly ''; }; + imageEditor = { - enable = lib.mkOption { - type = lib.types.bool; - default = false; - description = '' - Update Wallpaper by applying a lut filter to the image - ''; - }; + 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 = '' - A function to edit the image, takes one argument (the image) - and returns the resulting edited image - ''; - example = '' - config.stylix.imageEditor.method = config.lib.stylix.imageEditors.lutgen; - ''; + description = "Edits the given `stylix.image` argument, outputs to `stylix.generated.image`"; + example = "config.lib.stylix.imageEditors.lutgen;"; }; }; From 2e93e9be131362d5468b5f2c47c764834c556bd5 Mon Sep 17 00:00:00 2001 From: Melody Renata Date: Sun, 6 Oct 2024 13:32:32 -0400 Subject: [PATCH 6/6] Update regreet: Use generated wallpaper --- modules/regreet/nixos.nix | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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; };