From ee49b45a7b091287d44966b00d2a4f07d3fcbdfc Mon Sep 17 00:00:00 2001 From: Alyssa Ross Date: Sun, 24 Nov 2019 19:54:46 +0000 Subject: [PATCH] fetchFromGitLab: improve readability --- pkgs/build-support/fetchgitlab/default.nix | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/pkgs/build-support/fetchgitlab/default.nix b/pkgs/build-support/fetchgitlab/default.nix index be110cf8393e..6c4d52a05337 100644 --- a/pkgs/build-support/fetchgitlab/default.nix +++ b/pkgs/build-support/fetchgitlab/default.nix @@ -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; }