diff --git a/default.nix b/default.nix index 40d2119..7fdb2c1 100644 --- a/default.nix +++ b/default.nix @@ -9,8 +9,11 @@ let sha256 = locked.narHash; }; -in { nixpkgs-lib ? import ((fromFlake "nixpkgs-lib") + "/lib") -, base16-schemes ? fromFlake "base16-schemes", ... }: rec { +in +{ nixpkgs-lib ? import ((fromFlake "nixpkgs-lib") + "/lib") +, base16-schemes ? fromFlake "base16-schemes" +, ... +}: rec { lib = import ./lib; lib-contrib = import ./lib/contrib; lib-core = import ./lib/core { inherit nixpkgs-lib; }; diff --git a/lib/contrib/default.nix b/lib/contrib/default.nix index 55156ae..a3e30c5 100644 --- a/lib/contrib/default.nix +++ b/lib/contrib/default.nix @@ -1,4 +1,4 @@ -{pkgs ? (builtins.trace "nix-colors/lib-contrib: using as pkgs because the pkgs parameter was not provided" (import {}))}: +{ pkgs ? (builtins.trace "nix-colors/lib-contrib: using as pkgs because the pkgs parameter was not provided" (import { })) }: rec { # Takes a scheme, resulting wallpaper height and width, plus logo scale, and ouputs the generated wallpaper path # Example: diff --git a/lib/contrib/gtk-theme.nix b/lib/contrib/gtk-theme.nix index 3cab322..5a3671f 100644 --- a/lib/contrib/gtk-theme.nix +++ b/lib/contrib/gtk-theme.nix @@ -6,7 +6,8 @@ let mkdir -p $out/bin ln -s ${pkgs.resvg}/bin/resvg $out/bin/rendersvg ''; -in pkgs.stdenv.mkDerivation rec { +in +pkgs.stdenv.mkDerivation rec { name = "generated-gtk-theme-${scheme.slug}"; src = pkgs.fetchFromGitHub { owner = "nana-4"; diff --git a/lib/contrib/vim-theme.nix b/lib/contrib/vim-theme.nix index 04fc62e..5d58546 100644 --- a/lib/contrib/vim-theme.nix +++ b/lib/contrib/vim-theme.nix @@ -3,7 +3,8 @@ let c = scheme.colors; slug = scheme.slug; -in pkgs.writeTextDir "colors/nix-${slug}.vim" '' +in +pkgs.writeTextDir "colors/nix-${slug}.vim" '' let g:colors_name="nix-${slug}" set termguicolors diff --git a/lib/core/conversions.nix b/lib/core/conversions.nix index 8672039..e8b1602 100644 --- a/lib/core/conversions.nix +++ b/lib/core/conversions.nix @@ -60,13 +60,15 @@ let let inherit (nixpkgs-lib) toLower; lowerHex = toLower hex; - in if builtins.stringLength hex != 1 then + in + if builtins.stringLength hex != 1 then throw "Function only accepts a single character." else if hexToDecMap ? ${lowerHex} then hexToDecMap."${lowerHex}" else throw "Character ${hex} is not a hexadecimal value."; -in rec { +in +rec { /* Converts from hexadecimal to decimal. Type: hexToDec :: string -> int @@ -88,7 +90,8 @@ in rec { decimals = builtins.map hexCharToDec (stringToCharacters hex); decimalsAscending = reverseList decimals; decimalsPowered = imap0 base16To10 decimalsAscending; - in foldl builtins.add 0 decimalsPowered; + in + foldl builtins.add 0 decimalsPowered; /* Converts a 6 character hexadecimal string to RGB values. @@ -110,7 +113,8 @@ in rec { rgbStartIndex = [ 0 2 4 ]; hexList = builtins.map (x: builtins.substring x 2 hex) rgbStartIndex; hexLength = builtins.stringLength hex; - in if hexLength != 6 then + in + if hexLength != 6 then throw '' Unsupported hex string length of ${builtins.toString hexLength}. Length must be exactly 6. @@ -133,5 +137,6 @@ in rec { inherit (nixpkgs-lib) concatStringsSep; hexInRGB = hexToRGB hex; hexInRGBString = map toString hexInRGB; - in concatStringsSep sep hexInRGBString; + in + concatStringsSep sep hexInRGBString; } diff --git a/lib/core/math.nix b/lib/core/math.nix index 13361a8..0dbe560 100644 --- a/lib/core/math.nix +++ b/lib/core/math.nix @@ -25,7 +25,8 @@ let x = pow base (exponent / 2); odd_exp = mod exponent 2 == 1; - in x * x * (if odd_exp then base else 1) + in + x * x * (if odd_exp then base else 1) else if exponent == 1 then base else if exponent == 0 && base == 0 then diff --git a/lib/core/schemeFromYAML.nix b/lib/core/schemeFromYAML.nix index 76909e5..184f967 100644 --- a/lib/core/schemeFromYAML.nix +++ b/lib/core/schemeFromYAML.nix @@ -16,7 +16,8 @@ let sep = builtins.unsafeDiscardStringContext _sep; s = builtins.unsafeDiscardStringContext _s; splits = filter builtins.isString (builtins.split (escapeRegex sep) s); - in map (v: addContextFrom _sep (addContextFrom _s v)) splits; + in + map (v: addContextFrom _sep (addContextFrom _s v)) splits; nameValuePair = name: value: { inherit name value; }; # From https://github.com/arcnmx/nixexprs @@ -41,7 +42,8 @@ let lines = splitString "\n" yaml; lines' = map stripLine lines; lines'' = filter usefulLine lines'; - in mapListToAttrs attrLine lines''; + in + mapListToAttrs attrLine lines''; convertScheme = slug: set: { name = set.scheme; @@ -55,4 +57,5 @@ let }; schemeFromYAML = slug: content: convertScheme slug (fromYAML content); -in schemeFromYAML +in +schemeFromYAML diff --git a/lib/core/schemeToYAML.nix b/lib/core/schemeToYAML.nix index 74c7856..bdb757b 100644 --- a/lib/core/schemeToYAML.nix +++ b/lib/core/schemeToYAML.nix @@ -28,5 +28,7 @@ let scheme: "${scheme.name}" author: "${scheme.author}" '' + concatMapStrings # Add a line for each base0X color - (color: ''${color}: "${scheme.colors.${color}}"'') colorNames; -in schemeToYAML + (color: ''${color}: "${scheme.colors.${color}}"'') + colorNames; +in +schemeToYAML diff --git a/lib/core/tests/conversions.nix b/lib/core/tests/conversions.nix index fc8c6b1..55039f9 100644 --- a/lib/core/tests/conversions.nix +++ b/lib/core/tests/conversions.nix @@ -5,7 +5,8 @@ let conversions = import ../conversions.nix { inherit nixpkgs-lib; }; inherit (nixpkgs-lib) runTests; -in runTests { +in +runTests { testHexToDec_1 = { expr = conversions.hexToDec "12"; expected = 18; diff --git a/lib/core/tests/math.nix b/lib/core/tests/math.nix index cac43db..75c50b7 100644 --- a/lib/core/tests/math.nix +++ b/lib/core/tests/math.nix @@ -5,7 +5,8 @@ let math = import ../math.nix { inherit nixpkgs-lib; }; inherit (nixpkgs-lib) runTests; -in runTests { +in +runTests { testPow_1 = { expr = math.pow 0 1000; expected = 0; diff --git a/schemes.nix b/schemes.nix index 8dd3bac..7120f85 100644 --- a/schemes.nix +++ b/schemes.nix @@ -10,7 +10,8 @@ let let sufLen = stringLength suffix; sLen = stringLength str; - in if sufLen <= sLen && suffix == substring (sLen - sufLen) sufLen str then + in + if sufLen <= sLen && suffix == substring (sLen - sufLen) sufLen str then substring 0 (sLen - sufLen) str else str; @@ -18,7 +19,8 @@ let let lenContent = stringLength content; lenSuffix = stringLength suffix; - in lenContent >= lenSuffix + in + lenContent >= lenSuffix && substring (lenContent - lenSuffix) lenContent content == suffix; stripYamlExtension = filename: @@ -28,10 +30,13 @@ let colorSchemeFiles = filter isYamlFile (attrNames (readDir base16-schemes)); - colorSchemes = listToAttrs (map (filename: rec { - # Scheme slug - name = stripYamlExtension (baseNameOf filename); - # Scheme contents - value = schemeFromYAML name (readFile "${base16-schemes}/${filename}"); - }) colorSchemeFiles); -in colorSchemes + colorSchemes = listToAttrs (map + (filename: rec { + # Scheme slug + name = stripYamlExtension (baseNameOf filename); + # Scheme contents + value = schemeFromYAML name (readFile "${base16-schemes}/${filename}"); + }) + colorSchemeFiles); +in +colorSchemes