From b077b9fadac62901ad5739f0bc68eb8f61adba4b Mon Sep 17 00:00:00 2001 From: tilpner Date: Wed, 6 Mar 2019 11:24:05 +0100 Subject: [PATCH] gitlab: allow for deeper paths than owner/repo This was prompted by the INFO4-19 repo, with the URL https://gricad-gitlab.univ-grenoble-alpes.fr/Projets-INFO4/18-19/19/code, which contains groups and subgroups and failed to parse properly with the current parseGitlabUrl. --- lib/repoSource.nix | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/lib/repoSource.nix b/lib/repoSource.nix index 7fd611300..b8d1692d2 100644 --- a/lib/repoSource.nix +++ b/lib/repoSource.nix @@ -10,8 +10,8 @@ let len = length parts; in { domain = elemAt parts 2; - owner = elemAt parts (len - 2); - repo = elemAt parts (len - 1); + # Allow for deeper hierarchies than owner/repo (GL has groups and subgroups) + path = lib.drop 3 parts; }; revision = lockedRevisions.${name}; @@ -30,8 +30,9 @@ in else if (lib.hasPrefix "https://gitlab.com" attr.url || type == "gitlab") && !submodules then let gitlab = parseGitlabUrl attr.url; + escapedPath = builtins.concatStringsSep "%2F" gitlab.path; in fetchzip { - url = "https://${gitlab.domain}/api/v4/projects/${gitlab.owner}%2F${gitlab.repo}/repository/archive.tar.gz?sha=${revision.rev}"; + url = "https://${gitlab.domain}/api/v4/projects/${escapedPath}/repository/archive.tar.gz?sha=${revision.rev}"; inherit (revision) sha256; } else