My personal project and infrastructure archive
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 
nomicon/infra/libkookie/home-manager-stable/modules/lib/strings.nix

23 lines
721 B

{ lib }:
let
inherit (lib)
genList length lowerChars replaceStrings stringToCharacters upperChars;
in {
# Figures out a valid Nix store name for the given path.
storeFileName = path:
let
# All characters that are considered safe. Note "-" is not
# included to avoid "-" followed by digit being interpreted as a
# version.
safeChars = [ "+" "." "_" "?" "=" ] ++ lowerChars ++ upperChars
++ stringToCharacters "0123456789";
empties = l: genList (x: "") (length l);
unsafeInName =
stringToCharacters (replaceStrings safeChars (empties safeChars) path);
safeName = replaceStrings unsafeInName (empties unsafeInName) path;
in "hm_" + safeName;
}