about summary refs log tree commit diff
path: root/nixpkgs/pkgs/build-support/fetchgitlab
diff options
context:
space:
mode:
Diffstat (limited to 'nixpkgs/pkgs/build-support/fetchgitlab')
-rw-r--r--nixpkgs/pkgs/build-support/fetchgitlab/default.nix21
1 files changed, 21 insertions, 0 deletions
diff --git a/nixpkgs/pkgs/build-support/fetchgitlab/default.nix b/nixpkgs/pkgs/build-support/fetchgitlab/default.nix
new file mode 100644
index 000000000000..6c4d52a05337
--- /dev/null
+++ b/nixpkgs/pkgs/build-support/fetchgitlab/default.nix
@@ -0,0 +1,21 @@
+{ fetchzip, lib }:
+
+# gitlab example
+{ owner, repo, rev, domain ? "gitlab.com", name ? "source", group ? null
+, ... # For hash agility
+} @ 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/${escapedSlug}/repository/archive.tar.gz?sha=${rev}";
+  meta.homepage = "https://${domain}/${slug}/";
+} // removeAttrs args [ "domain" "owner" "group" "repo" "rev" ]) // { inherit rev; }