2017-06-26 14:56:00 +02:00
|
|
|
{ lib }:
|
|
|
|
|
2017-07-04 22:09:34 +02:00
|
|
|
let
|
|
|
|
inherit (lib) removeSuffix hasPrefix removePrefix splitString stringToCharacters concatMapStrings last elem;
|
2017-06-26 14:56:00 +02:00
|
|
|
|
2017-07-04 22:09:34 +02:00
|
|
|
allowedChars = stringToCharacters "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789+-._?=";
|
|
|
|
sanitizeStoreName = s:
|
|
|
|
let
|
|
|
|
s' = concatMapStrings (c: if elem c allowedChars then c else "") (stringToCharacters s);
|
|
|
|
s'' = if hasPrefix "." s' then "_${removePrefix "." s'}" else s';
|
|
|
|
in
|
|
|
|
s'';
|
|
|
|
in
|
|
|
|
urlOrRepo: rev:
|
|
|
|
let
|
|
|
|
repo' = last (splitString ":" (baseNameOf (removeSuffix ".git" (removeSuffix "/" urlOrRepo))));
|
|
|
|
rev' = baseNameOf rev;
|
|
|
|
in
|
|
|
|
"${sanitizeStoreName repo'}-${sanitizeStoreName rev'}-src"
|