summary refs log tree commit diff
diff options
context:
space:
mode:
authorAlyssa Ross <hi@alyssa.is>2019-11-24 19:54:46 +0000
committerAlyssa Ross <hi@alyssa.is>2019-12-09 01:33:16 +0000
commitee49b45a7b091287d44966b00d2a4f07d3fcbdfc (patch)
tree2e55c13d74d0818f3fc71cc26f031b0a747530fc
parent571c310007d0e659e2d6aa412ac9229481e32a0a (diff)
downloadnixpkgs-ee49b45a7b091287d44966b00d2a4f07d3fcbdfc.tar
nixpkgs-ee49b45a7b091287d44966b00d2a4f07d3fcbdfc.tar.gz
nixpkgs-ee49b45a7b091287d44966b00d2a4f07d3fcbdfc.tar.bz2
nixpkgs-ee49b45a7b091287d44966b00d2a4f07d3fcbdfc.tar.lz
nixpkgs-ee49b45a7b091287d44966b00d2a4f07d3fcbdfc.tar.xz
nixpkgs-ee49b45a7b091287d44966b00d2a4f07d3fcbdfc.tar.zst
nixpkgs-ee49b45a7b091287d44966b00d2a4f07d3fcbdfc.zip
fetchFromGitLab: improve readability
-rw-r--r--pkgs/build-support/fetchgitlab/default.nix17
1 files changed, 14 insertions, 3 deletions
diff --git a/pkgs/build-support/fetchgitlab/default.nix b/pkgs/build-support/fetchgitlab/default.nix
index be110cf8393..6c4d52a0533 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; }