fetchFromGitLab: improve readability

This commit is contained in:
Alyssa Ross 2019-11-24 19:54:46 +00:00
parent 571c310007
commit ee49b45a7b

View File

@ -3,8 +3,19 @@
# gitlab example
{ owner, repo, rev, domain ? "gitlab.com", name ? "source", group ? null
, ... # For hash agility
}@args: fetchzip ({
} @ args:
with lib;
let
slug = concatStringsSep "/"
((optional (group != null) group) ++ [ owner repo ]);
escapedSlug = replaceStrings ["." "/"] ["%2E" "%2F"] slug;
in
fetchzip ({
inherit name;
url = "https://${domain}/api/v4/projects/${lib.optionalString (group != null) "${lib.replaceStrings ["."] ["%2E"] group}%2F"}${lib.replaceStrings ["."] ["%2E"] owner}%2F${lib.replaceStrings ["."] ["%2E"] repo}/repository/archive.tar.gz?sha=${rev}";
meta.homepage = "https://${domain}/${lib.optionalString (group != null) "${group}/"}${owner}/${repo}/";
url = "https://${domain}/api/v4/projects/${escapedSlug}/repository/archive.tar.gz?sha=${rev}";
meta.homepage = "https://${domain}/${slug}/";
} // removeAttrs args [ "domain" "owner" "group" "repo" "rev" ]) // { inherit rev; }