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.nix22
1 files changed, 22 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..f1850fbaa1ea
--- /dev/null
+++ b/nixpkgs/pkgs/build-support/fetchgitlab/default.nix
@@ -0,0 +1,22 @@
+{ 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;
+  escapedRev = replaceStrings ["+"] ["%2B"] rev;
+in
+
+fetchzip ({
+  inherit name;
+  url = "https://${domain}/api/v4/projects/${escapedSlug}/repository/archive.tar.gz?sha=${escapedRev}";
+  meta.homepage = "https://${domain}/${slug}/";
+} // removeAttrs args [ "domain" "owner" "group" "repo" "rev" ]) // { inherit rev; }