at 17.09-beta 19 lines 683 B view raw
1{ lib }: 2 3let 4 inherit (lib) removeSuffix hasPrefix removePrefix splitString stringToCharacters concatMapStrings last elem; 5 6 allowedChars = stringToCharacters "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789+-._?="; 7 sanitizeStoreName = s: 8 let 9 s' = concatMapStrings (c: if elem c allowedChars then c else "") (stringToCharacters s); 10 s'' = if hasPrefix "." s' then "_${removePrefix "." s'}" else s'; 11 in 12 s''; 13in 14 urlOrRepo: rev: 15 let 16 repo' = last (splitString ":" (baseNameOf (removeSuffix ".git" (removeSuffix "/" urlOrRepo)))); 17 rev' = baseNameOf rev; 18 in 19 "${sanitizeStoreName repo'}-${sanitizeStoreName rev'}-src"