nixpkgs-suyu/pkgs/build-support/fetchgitlab/default.nix

23 lines
649 B
Nix
Raw Normal View History

{ fetchzip, lib }:
# gitlab example
{ owner, repo, rev, domain ? "gitlab.com", name ? "source", group ? null
, ... # For hash agility
2019-11-24 20:54:46 +01:00
} @ args:
with lib;
let
slug = concatStringsSep "/"
((optional (group != null) group) ++ [ owner repo ]);
escapedSlug = replaceStrings ["." "/"] ["%2E" "%2F"] slug;
escapedRev = replaceStrings ["+" "%" "/"] ["%2B" "%25" "%2F"] rev;
2019-11-24 20:54:46 +01:00
in
fetchzip ({
inherit name;
url = "https://${domain}/api/v4/projects/${escapedSlug}/repository/archive.tar.gz?sha=${escapedRev}";
2019-11-24 20:54:46 +01:00
meta.homepage = "https://${domain}/${slug}/";
} // removeAttrs args [ "domain" "owner" "group" "repo" "rev" ]) // { inherit rev; }