From 83a0627f337a47d52d972bb450f1045a7fc55167 Mon Sep 17 00:00:00 2001 From: luc65r Date: Sat, 31 Oct 2020 11:28:06 +0100 Subject: [PATCH] fetchFromSourcehut: init --- doc/builders/fetchers.chapter.md | 4 +++ pkgs/build-support/fetchsourcehut/default.nix | 25 +++++++++++++++++++ pkgs/top-level/all-packages.nix | 2 ++ 3 files changed, 31 insertions(+) create mode 100644 pkgs/build-support/fetchsourcehut/default.nix diff --git a/doc/builders/fetchers.chapter.md b/doc/builders/fetchers.chapter.md index d4cab056c70..99d87f078cc 100644 --- a/doc/builders/fetchers.chapter.md +++ b/doc/builders/fetchers.chapter.md @@ -68,3 +68,7 @@ This is used with Savannah repositories. The arguments expected are very similar ## `fetchFromRepoOrCz` This is used with repo.or.cz repositories. The arguments expected are very similar to fetchFromGitHub above. + +## `fetchFromSourcehut` + +This is used with sourcehut repositories. The arguments expected are very similar to fetchFromGitHub above. Don't forget the tilde (~) in front of the user name! diff --git a/pkgs/build-support/fetchsourcehut/default.nix b/pkgs/build-support/fetchsourcehut/default.nix new file mode 100644 index 00000000000..ed2f074200c --- /dev/null +++ b/pkgs/build-support/fetchsourcehut/default.nix @@ -0,0 +1,25 @@ +{ fetchzip, lib }: + +{ owner +, repo, rev +, domain ? "sr.ht" +, vc ? "git" +, name ? "source" +, ... # For hash agility +} @ args: + +with lib; + +assert (lib.assertOneOf "vc" vc [ "hg" "git" ]); + +let + baseUrl = "https://${vc}.${domain}/${owner}/${repo}"; + +in fetchzip (recursiveUpdate { + inherit name; + url = "${baseUrl}/archive/${rev}.tar.gz"; + meta.homepage = "${baseUrl}/"; + extraPostFetch = optionalString (vc == "hg") '' + rm -f "$out/.hg_archival.txt" + ''; # impure file; see #12002 +} (removeAttrs args [ "owner" "repo" "rev" "domain" "vc" ])) // { inherit rev; } diff --git a/pkgs/top-level/all-packages.nix b/pkgs/top-level/all-packages.nix index 6b91ac6a9ac..e9aabbb7762 100644 --- a/pkgs/top-level/all-packages.nix +++ b/pkgs/top-level/all-packages.nix @@ -475,6 +475,8 @@ in fetchFromSavannah = callPackage ../build-support/fetchsavannah {}; + fetchFromSourcehut = callPackage ../build-support/fetchsourcehut { }; + fetchFromGitLab = callPackage ../build-support/fetchgitlab {}; fetchFromGitiles = callPackage ../build-support/fetchgitiles {};