blob: 9f4392c387f64a7beda49afc2e4b4149cca99b1f (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
|
{ lib }:
urlOrRepo: rev: let
inherit (lib) removeSuffix splitString last;
base = last (splitString ":" (baseNameOf (removeSuffix "/" urlOrRepo)));
matched = builtins.match "(.*).git" base;
short = builtins.substring 0 7 rev;
appendShort = if (builtins.match "[a-f0-9]*" rev) != null
then "-${short}"
else "";
in "${if matched == null then base else builtins.head matched}${appendShort}"
|