From 811e8db31d67e17b9d8fdfa2618c7cb1fc167f76 Mon Sep 17 00:00:00 2001 From: Osi Bluber <87434959+OsiPog@users.noreply.github.com> Date: Sat, 24 Jan 2026 21:27:18 +0100 Subject: [PATCH 1/4] nixos-icons: make icon colors configurable --- modules/nixos-icons/overlay.nix | 293 +++++++++++++++++++------------- 1 file changed, 178 insertions(+), 115 deletions(-) diff --git a/modules/nixos-icons/overlay.nix b/modules/nixos-icons/overlay.nix index 537b7e589e..f7291a61e2 100644 --- a/modules/nixos-icons/overlay.nix +++ b/modules/nixos-icons/overlay.nix @@ -4,130 +4,193 @@ lib, ... }: +let + inherit (builtins) stringLength substring; + inherit (config.lib.stylix) colors; + + inherit (lib) + concatStrings + max + min + pipe + toHexString + fromHexString + mkOption + types + ; + + cfg = config.stylix.targets.nixos-icons; + + strMatchingHexColor = types.strMatching "^[a-zA-Z0-9]{6}$"; + + hexColorAddRgb = + hexColor: add: + pipe hexColor [ + # convert to hex color to rgb attrset, and add specified value + ( + _: + map + ( + elem: + fromHexString ( + if elem == "r" then + substring 0 2 hexColor + else if elem == "g" then + substring 2 4 hexColor + else + substring 4 6 hexColor + ) + + add.${elem} + ) + [ + "r" + "g" + "b" + ] + ) + # clamp between 0 and 255 + (map (min 255)) + (map (max 0)) + # convert each to hex string + (map toHexString) + # add leading 0 if necessary + (map (hex: if (stringLength hex < 2) then "0" + hex else hex)) + # to one string + concatStrings + ]; +in { - options.stylix.targets.nixos-icons.enable = - config.lib.stylix.mkEnableTarget "the NixOS logo" true; + options.stylix.targets.nixos-icons = { + enable = config.lib.stylix.mkEnableTarget "the NixOS logo" true; + colors = { + nix-snowflake-white.white = mkOption { + default = colors.base05; + defaultText = "config.lib.stylix.colors.base05"; + description = "Replaces the white color in the 'nix-snowflake-white' icon."; + type = strMatchingHexColor; + }; + nix-snowflake-colours = { + gradient-light-blue = { + dark = mkOption { + default = + hexColorAddRgb cfg.colors.nix-snowflake-colours.gradient-light-blue.neutral + { + r = -21; + g = -23; + b = -6; + }; + description = "Replaces the darker part of light blue color gradient (#699ad7) in the 'nix-snowflake-colours' icon."; + type = strMatchingHexColor; + }; + neutral = mkOption { + default = colors.baseOC; + defaultText = "config.lib.stylix.colors.base0C"; + description = "Replaces the neutral part of light blue color gradient (#7eb1dd) in the 'nix-snowflake-colours' icon."; + type = strMatchingHexColor; + }; + light = mkOption { + default = + hexColorAddRgb cfg.colors.nix-snowflake-colours.gradient-light-blue.neutral + { + r = 0; + g = 9; + b = 7; + }; + description = "Replaces the lighter part of light blue color gradient (#7ebae4) the 'nix-snowflake-colours' icon."; + type = strMatchingHexColor; + }; + }; + gradient-blue = { + dark = mkOption { + default = + hexColorAddRgb cfg.colors.nix-snowflake-colours.gradient-blue.neutral + { + r = -9; + g = -13; + b = -21; + }; + description = "Replaces the darker part of blue color gradient (#415e9a) in the 'nix-snowflake-colours' icon."; + type = strMatchingHexColor; + }; + neutral = mkOption { + default = colors.baseOD; + defaultText = "config.lib.stylix.colors.base0D"; + description = "Replaces the neutral part of blue color gradient (#4a6baf) in the 'nix-snowflake-colours' icon."; + type = strMatchingHexColor; + }; + light = mkOption { + default = + hexColorAddRgb cfg.colors.nix-snowflake-colours.gradient-blue.neutral + { + r = 8; + g = 12; + b = 20; + }; + description = "Replaces the lighter part of blue color gradient (#5277c3) the 'nix-snowflake-colours' icon."; + type = strMatchingHexColor; + }; + }; + }; + }; + }; overlay = _: super: - lib.optionalAttrs - (config.stylix.enable && config.stylix.targets.nixos-icons.enable) - { - nixos-icons = super.nixos-icons.overrideAttrs (oldAttrs: { - src = pkgs.applyPatches { - inherit (oldAttrs) src; - prePatch = - let - inherit (builtins) stringLength; - inherit (config.lib.stylix) colors; + lib.optionalAttrs (config.stylix.enable && cfg.enable) { + nixos-icons = super.nixos-icons.overrideAttrs (oldAttrs: { + src = pkgs.applyPatches { + inherit (oldAttrs) src; + prePatch = '' + substituteInPlace \ + logo/nix-snowflake-white.svg \ + --replace-fail \ + '#ffffff' \ + '#${cfg.colors.nix-snowflake-white.white}' - inherit (lib) - concatStrings - max - min - pipe - toHexString - toInt - ; + # The normal snowflake uses 2 gradients, replace each bluish + # color with blue and each light-blueish color with cyan + substituteInPlace \ + logo/nix-snowflake-colours.svg \ + --replace-fail \ + '#699ad7' \ + '#${cfg.colors.nix-snowflake-colours.gradient-light-blue.dark}' - baseColorAdd = - colorName: add: - pipe colorName [ - # convert to base color name to rgb attrset, and add specified value - ( - colorName: - map (elem: toInt colors."${colorName}-rgb-${elem}" + add.${elem}) [ - "r" - "g" - "b" - ] - ) - # clamp between 0 and 255 - (map (min 255)) - (map (max 0)) - # convert each to hex string - (map toHexString) - # add leading 0 if necessary - (map (hex: if (stringLength hex < 2) then "0" + hex else hex)) - # to one string - concatStrings - ]; - in - '' - substituteInPlace \ - logo/nix-snowflake-white.svg \ - --replace-fail \ - '#ffffff' \ - '#${colors.base05}' + substituteInPlace \ + logo/nix-snowflake-colours.svg \ + --replace-fail \ + '#7eb1dd' \ + '#${cfg.colors.nix-snowflake-colours.gradient-light-blue.neutral}' - # The normal snowflake uses 2 gradients, replace each bluish - # color with blue and each light-blueish color with cyan - substituteInPlace \ - logo/nix-snowflake-colours.svg \ - --replace-fail \ - '#699ad7' \ - '#${ - baseColorAdd "base0C" { - r = -21; - g = -23; - b = -6; - } - }' + substituteInPlace \ + logo/nix-snowflake-colours.svg \ + --replace-fail \ + '#7ebae4' \ + '#${cfg.colors.nix-snowflake-colours.gradient-light-blue.light}' - substituteInPlace \ - logo/nix-snowflake-colours.svg \ - --replace-fail \ - '#7eb1dd' \ - '#${colors.base0C}' + substituteInPlace \ + logo/nix-snowflake-colours.svg \ + --replace-fail \ + '#415e9a' \ + '#${cfg.colors.nix-snowflake-colours.gradient-blue.dark}' - substituteInPlace \ - logo/nix-snowflake-colours.svg \ - --replace-fail \ - '#7ebae4' \ - '#${ - baseColorAdd "base0C" { - r = 0; - g = 9; - b = 7; - } - }' + substituteInPlace \ + logo/nix-snowflake-colours.svg \ + --replace-fail \ + '#4a6baf' \ + '#${cfg.colors.nix-snowflake-colours.gradient-blue.neutral}' - substituteInPlace \ - logo/nix-snowflake-colours.svg \ - --replace-fail \ - '#415e9a' \ - '#${ - baseColorAdd "base0D" { - r = -9; - g = -13; - b = -21; - } - }' + substituteInPlace \ + logo/nix-snowflake-colours.svg \ + --replace-fail \ + '#5277c3' \ + '#${cfg.colors.nix-snowflake-colours.gradient-blue.light}' - substituteInPlace \ - logo/nix-snowflake-colours.svg \ - --replace-fail \ - '#4a6baf' \ - '#${colors.base0D}' - - substituteInPlace \ - logo/nix-snowflake-colours.svg \ - --replace-fail \ - '#5277c3' \ - '#${ - baseColorAdd "base0D" { - r = 8; - g = 12; - b = 20; - } - }' - - # Insert attribution comment after the XML prolog - attribution='2i' - sed --in-place "$attribution" logo/nix-snowflake-colours.svg - sed --in-place "$attribution" logo/nix-snowflake-white.svg - ''; - }; - }); - }; + # Insert attribution comment after the XML prolog + attribution='2i' + sed --in-place "$attribution" logo/nix-snowflake-colours.svg + sed --in-place "$attribution" logo/nix-snowflake-white.svg + ''; + }; + }); + }; } From 16cf429357f5030c67328026ea8060e49ac5e55f Mon Sep 17 00:00:00 2001 From: Osi Bluber <87434959+OsiPog@users.noreply.github.com> Date: Sat, 24 Jan 2026 22:59:44 +0100 Subject: [PATCH 2/4] nixos-icons: `hexColorAddRgb` uses correct substrings --- modules/nixos-icons/overlay.nix | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/modules/nixos-icons/overlay.nix b/modules/nixos-icons/overlay.nix index f7291a61e2..5cfd618248 100644 --- a/modules/nixos-icons/overlay.nix +++ b/modules/nixos-icons/overlay.nix @@ -36,9 +36,9 @@ let if elem == "r" then substring 0 2 hexColor else if elem == "g" then - substring 2 4 hexColor + substring 2 2 hexColor else - substring 4 6 hexColor + substring 4 2 hexColor ) + add.${elem} ) @@ -83,7 +83,7 @@ in type = strMatchingHexColor; }; neutral = mkOption { - default = colors.baseOC; + default = colors.base0C; defaultText = "config.lib.stylix.colors.base0C"; description = "Replaces the neutral part of light blue color gradient (#7eb1dd) in the 'nix-snowflake-colours' icon."; type = strMatchingHexColor; @@ -113,7 +113,7 @@ in type = strMatchingHexColor; }; neutral = mkOption { - default = colors.baseOD; + default = colors.base0D; defaultText = "config.lib.stylix.colors.base0D"; description = "Replaces the neutral part of blue color gradient (#4a6baf) in the 'nix-snowflake-colours' icon."; type = strMatchingHexColor; From ba012353b59910d218d78bfb60413455bbcc2414 Mon Sep 17 00:00:00 2001 From: Osi Bluber <87434959+OsiPog@users.noreply.github.com> Date: Sat, 24 Jan 2026 23:19:43 +0100 Subject: [PATCH 3/4] nixos-icons: restructure color options --- modules/nixos-icons/overlay.nix | 110 ++++++++++++++------------------ 1 file changed, 49 insertions(+), 61 deletions(-) diff --git a/modules/nixos-icons/overlay.nix b/modules/nixos-icons/overlay.nix index 5cfd618248..cde8d6e944 100644 --- a/modules/nixos-icons/overlay.nix +++ b/modules/nixos-icons/overlay.nix @@ -69,66 +69,54 @@ in description = "Replaces the white color in the 'nix-snowflake-white' icon."; type = strMatchingHexColor; }; - nix-snowflake-colours = { - gradient-light-blue = { - dark = mkOption { - default = - hexColorAddRgb cfg.colors.nix-snowflake-colours.gradient-light-blue.neutral - { - r = -21; - g = -23; - b = -6; - }; - description = "Replaces the darker part of light blue color gradient (#699ad7) in the 'nix-snowflake-colours' icon."; - type = strMatchingHexColor; - }; - neutral = mkOption { - default = colors.base0C; - defaultText = "config.lib.stylix.colors.base0C"; - description = "Replaces the neutral part of light blue color gradient (#7eb1dd) in the 'nix-snowflake-colours' icon."; - type = strMatchingHexColor; - }; - light = mkOption { - default = - hexColorAddRgb cfg.colors.nix-snowflake-colours.gradient-light-blue.neutral - { - r = 0; - g = 9; - b = 7; - }; - description = "Replaces the lighter part of light blue color gradient (#7ebae4) the 'nix-snowflake-colours' icon."; - type = strMatchingHexColor; + nix-snowflake = { + light-blue-darker = mkOption { + default = hexColorAddRgb cfg.colors.nix-snowflake.light-blue { + r = -21; + g = -23; + b = -6; }; + description = "Replaces the darker part of light blue color gradient (#699ad7) in the 'nix-snowflake-colours' icon."; + type = strMatchingHexColor; + }; + light-blue = mkOption { + default = colors.base0C; + defaultText = "config.lib.stylix.colors.base0C"; + description = "Replaces the neutral part of light blue color gradient (#7eb1dd) in the 'nix-snowflake-colours' icon."; + type = strMatchingHexColor; }; - gradient-blue = { - dark = mkOption { - default = - hexColorAddRgb cfg.colors.nix-snowflake-colours.gradient-blue.neutral - { - r = -9; - g = -13; - b = -21; - }; - description = "Replaces the darker part of blue color gradient (#415e9a) in the 'nix-snowflake-colours' icon."; - type = strMatchingHexColor; + light-blue-lighter = mkOption { + default = hexColorAddRgb cfg.colors.nix-snowflake.light-blue { + r = 0; + g = 9; + b = 7; }; - neutral = mkOption { - default = colors.base0D; - defaultText = "config.lib.stylix.colors.base0D"; - description = "Replaces the neutral part of blue color gradient (#4a6baf) in the 'nix-snowflake-colours' icon."; - type = strMatchingHexColor; + description = "Replaces the lighter part of light blue color gradient (#7ebae4) the 'nix-snowflake-colours' icon."; + type = strMatchingHexColor; + }; + blue-darker = mkOption { + default = hexColorAddRgb cfg.colors.nix-snowflake.blue { + r = -9; + g = -13; + b = -21; }; - light = mkOption { - default = - hexColorAddRgb cfg.colors.nix-snowflake-colours.gradient-blue.neutral - { - r = 8; - g = 12; - b = 20; - }; - description = "Replaces the lighter part of blue color gradient (#5277c3) the 'nix-snowflake-colours' icon."; - type = strMatchingHexColor; + description = "Replaces the darker part of blue color gradient (#415e9a) in the 'nix-snowflake-colours' icon."; + type = strMatchingHexColor; + }; + blue = mkOption { + default = colors.base0D; + defaultText = "config.lib.stylix.colors.base0D"; + description = "Replaces the neutral part of blue color gradient (#4a6baf) in the 'nix-snowflake-colours' icon."; + type = strMatchingHexColor; + }; + blue-lighter = mkOption { + default = hexColorAddRgb cfg.colors.nix-snowflake.blue { + r = 8; + g = 12; + b = 20; }; + description = "Replaces the lighter part of blue color gradient (#5277c3) the 'nix-snowflake-colours' icon."; + type = strMatchingHexColor; }; }; }; @@ -153,37 +141,37 @@ in logo/nix-snowflake-colours.svg \ --replace-fail \ '#699ad7' \ - '#${cfg.colors.nix-snowflake-colours.gradient-light-blue.dark}' + '#${cfg.colors.nix-snowflake.light-blue-darker}' substituteInPlace \ logo/nix-snowflake-colours.svg \ --replace-fail \ '#7eb1dd' \ - '#${cfg.colors.nix-snowflake-colours.gradient-light-blue.neutral}' + '#${cfg.colors.nix-snowflake.light-blue}' substituteInPlace \ logo/nix-snowflake-colours.svg \ --replace-fail \ '#7ebae4' \ - '#${cfg.colors.nix-snowflake-colours.gradient-light-blue.light}' + '#${cfg.colors.nix-snowflake.light-blue-lighter}' substituteInPlace \ logo/nix-snowflake-colours.svg \ --replace-fail \ '#415e9a' \ - '#${cfg.colors.nix-snowflake-colours.gradient-blue.dark}' + '#${cfg.colors.nix-snowflake.blue-darker}' substituteInPlace \ logo/nix-snowflake-colours.svg \ --replace-fail \ '#4a6baf' \ - '#${cfg.colors.nix-snowflake-colours.gradient-blue.neutral}' + '#${cfg.colors.nix-snowflake.blue}' substituteInPlace \ logo/nix-snowflake-colours.svg \ --replace-fail \ '#5277c3' \ - '#${cfg.colors.nix-snowflake-colours.gradient-blue.light}' + '#${cfg.colors.nix-snowflake.blue-lighter}' # Insert attribution comment after the XML prolog attribution='2i' From d69a94a75f15cd887a929bc44d3a1b433891aa69 Mon Sep 17 00:00:00 2001 From: Osi Bluber <87434959+OsiPog@users.noreply.github.com> Date: Sat, 24 Jan 2026 23:43:31 +0100 Subject: [PATCH 4/4] nixos-icons: add better defaults with text representation --- modules/nixos-icons/overlay.nix | 94 ++++++++++++++++++++++++--------- 1 file changed, 69 insertions(+), 25 deletions(-) diff --git a/modules/nixos-icons/overlay.nix b/modules/nixos-icons/overlay.nix index cde8d6e944..8c7af47222 100644 --- a/modules/nixos-icons/overlay.nix +++ b/modules/nixos-icons/overlay.nix @@ -6,7 +6,6 @@ }: let inherit (builtins) stringLength substring; - inherit (config.lib.stylix) colors; inherit (lib) concatStrings @@ -62,59 +61,104 @@ in { options.stylix.targets.nixos-icons = { enable = config.lib.stylix.mkEnableTarget "the NixOS logo" true; + hexColorAddRgb = mkOption { + readOnly = true; + default = hexColorAddRgb; + description = "Function that adds RGB values to a hex color. For example `hexColorAddRgb \"000000\" {r = 128; g = 128; b = 128;}` evaluates to `\"808080\"`"; + }; colors = { nix-snowflake-white.white = mkOption { - default = colors.base05; + default = config.lib.stylix.colors.base05; defaultText = "config.lib.stylix.colors.base05"; description = "Replaces the white color in the 'nix-snowflake-white' icon."; type = strMatchingHexColor; }; nix-snowflake = { light-blue-darker = mkOption { - default = hexColorAddRgb cfg.colors.nix-snowflake.light-blue { - r = -21; - g = -23; - b = -6; - }; + default = + with config.stylix.targets.nixos-icons; + hexColorAddRgb colors.nix-snowflake.light-blue { + r = -21; + g = -23; + b = -6; + }; + defaultText = '' + with config.stylix.targets.nixos-icons; + hexColorAddRgb colors.nix-snowflake.light-blue { + r = -21; + g = -23; + b = -6; + }; + ''; description = "Replaces the darker part of light blue color gradient (#699ad7) in the 'nix-snowflake-colours' icon."; type = strMatchingHexColor; }; light-blue = mkOption { - default = colors.base0C; + default = config.lib.stylix.colors.base0C; defaultText = "config.lib.stylix.colors.base0C"; description = "Replaces the neutral part of light blue color gradient (#7eb1dd) in the 'nix-snowflake-colours' icon."; type = strMatchingHexColor; }; light-blue-lighter = mkOption { - default = hexColorAddRgb cfg.colors.nix-snowflake.light-blue { - r = 0; - g = 9; - b = 7; - }; + default = + with config.stylix.targets.nixos-icons; + hexColorAddRgb colors.nix-snowflake.light-blue { + r = 0; + g = 9; + b = 7; + }; + defaultText = '' + with config.stylix.targets.nixos-icons; + hexColorAddRgb colors.nix-snowflake.light-blue { + r = 0; + g = 9; + b = 7; + }; + ''; description = "Replaces the lighter part of light blue color gradient (#7ebae4) the 'nix-snowflake-colours' icon."; type = strMatchingHexColor; }; blue-darker = mkOption { - default = hexColorAddRgb cfg.colors.nix-snowflake.blue { - r = -9; - g = -13; - b = -21; - }; + default = + with config.stylix.targets.nixos-icons; + hexColorAddRgb colors.nix-snowflake.blue { + r = -9; + g = -13; + b = -21; + }; + defaultText = '' + with config.stylix.targets.nixos-icons; + hexColorAddRgb colors.nix-snowflake.blue { + r = -9; + g = -13; + b = -21; + }; + ''; description = "Replaces the darker part of blue color gradient (#415e9a) in the 'nix-snowflake-colours' icon."; type = strMatchingHexColor; }; blue = mkOption { - default = colors.base0D; + default = config.lib.stylix.colors.base0D; defaultText = "config.lib.stylix.colors.base0D"; description = "Replaces the neutral part of blue color gradient (#4a6baf) in the 'nix-snowflake-colours' icon."; type = strMatchingHexColor; }; blue-lighter = mkOption { - default = hexColorAddRgb cfg.colors.nix-snowflake.blue { - r = 8; - g = 12; - b = 20; - }; + default = + with config.stylix.targets.nixos-icons; + hexColorAddRgb colors.nix-snowflake.blue { + r = 8; + g = 12; + b = 20; + }; + defaultText = '' + with config.stylix.targets.nixos-icons; + hexColorAddRgb colors.nix-snowflake.blue { + r = 8; + g = 12; + b = 20; + }; + ''; description = "Replaces the lighter part of blue color gradient (#5277c3) the 'nix-snowflake-colours' icon."; type = strMatchingHexColor; }; @@ -174,7 +218,7 @@ in '#${cfg.colors.nix-snowflake.blue-lighter}' # Insert attribution comment after the XML prolog - attribution='2i' + attribution='2i' sed --in-place "$attribution" logo/nix-snowflake-colours.svg sed --in-place "$attribution" logo/nix-snowflake-white.svg '';