20 lines
904 B
Nix
20 lines
904 B
Nix
{
|
|
description = "Flake Template Hell";
|
|
outputs = _: let
|
|
stringToCharacters = str: builtins.genList (p: builtins.substring p 1 str) (builtins.stringLength str);
|
|
upperCase = stringToCharacters "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
|
|
lowerCase = stringToCharacters "abcdefghijklmnopqrstuvwxyz";
|
|
toUpper = builtins.replaceStrings lowerCase upperCase;
|
|
toLower = builtins.replaceStrings upperCase lowerCase;
|
|
addContextFrom = src: target: builtins.substring 0 0 src + target;
|
|
toSentenceCase = str: let
|
|
firstChar = builtins.substring 0 1 str;
|
|
restChars = builtins.substring 1 (builtins.stringLength str) str;
|
|
in addContextFrom str (toUpper firstChar + toLower restChars);
|
|
in {
|
|
templates = builtins.mapAttrs (name: _: {
|
|
path = ./templates/${name};
|
|
description = "Template for ${toSentenceCase name} projects.";
|
|
}) (builtins.readDir ./templates);
|
|
};
|
|
}
|