mirror of
https://github.com/NixOS/nixpkgs.git
synced 2024-12-19 12:14:10 +00:00
23 lines
649 B
Nix
23 lines
649 B
Nix
{ 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" "%25" "%2F"] 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; }
|