From de638a3a6fca350b6bdb0e0e0fb4984d53dea36e Mon Sep 17 00:00:00 2001 From: RGBCube Date: Thu, 30 Nov 2023 11:58:26 +0300 Subject: [PATCH] Only add prefix if field is a valid color --- flake.nix | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/flake.nix b/flake.nix index db5cb02..fc9608c 100644 --- a/flake.nix +++ b/flake.nix @@ -3,14 +3,17 @@ outputs = { self }: let raw = import ./themes.nix; + + isValidColor = thing: if builtins.isString thing then + (builtins.match "^[0-9a-fA-F]{6}" thing) != null + else + false; in { inherit raw; custom = theme: let - onlyColors = builtins.removeAttrs theme [ "name" "author" ]; - - with0x = theme // (builtins.mapAttrs (_: value: "0x" + value) onlyColors); - withHashtag = theme // (builtins.mapAttrs (_: value: "#" + value) onlyColors); + with0x = theme // (builtins.mapAttrs (_: value: if isValidColor value then "0x" + value else value) theme); + withHashtag = theme // (builtins.mapAttrs (_: value: if isValidColor value then "#" + value else value) theme); themeFull = theme // { inherit with0x withHashtag;