diff --git a/doc/builders/fetchers.chapter.md b/doc/builders/fetchers.chapter.md index 16e4baa966b0..317c9430cd00 100644 --- a/doc/builders/fetchers.chapter.md +++ b/doc/builders/fetchers.chapter.md @@ -72,3 +72,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/applications/networking/browsers/castor/default.nix b/pkgs/applications/networking/browsers/castor/default.nix index daead82e4854..259a8780901e 100644 --- a/pkgs/applications/networking/browsers/castor/default.nix +++ b/pkgs/applications/networking/browsers/castor/default.nix @@ -1,5 +1,5 @@ { lib -, fetchurl +, fetchFromSourcehut , rustPlatform , pkg-config , wrapGAppsHook @@ -15,9 +15,11 @@ rustPlatform.buildRustPackage rec { pname = "castor"; version = "0.8.16"; - src = fetchurl { - url = "https://git.sr.ht/~julienxx/castor/archive/${version}.tar.gz"; - sha256 = "1qwsprwazkzcs70h219fhh5jj5s5hm1k120fn3pk4qivii4lyhah"; + src = fetchFromSourcehut { + owner = "~julienxx"; + repo = pname; + rev = version; + sha256 = "0rwg1w7srjwa23mkypl8zk6674nhph4xsc6nc01f6g5k959szylr"; }; cargoSha256 = "0yn2kfiaz6d8wc8rdqli2pwffp5vb1v3zi7520ysrd5b6fc2csf2"; diff --git a/pkgs/build-support/fetchsourcehut/default.nix b/pkgs/build-support/fetchsourcehut/default.nix new file mode 100644 index 000000000000..ed2f074200cd --- /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/development/tools/glpaper/default.nix b/pkgs/development/tools/glpaper/default.nix index 6b7b13437cc6..f6465d53cae0 100644 --- a/pkgs/development/tools/glpaper/default.nix +++ b/pkgs/development/tools/glpaper/default.nix @@ -1,12 +1,14 @@ -{ lib, stdenv, fetchhg, meson, ninja, pkg-config, wlroots, wayland, wayland-protocols +{ lib, stdenv, fetchFromSourcehut, meson, ninja, pkg-config, wlroots, wayland, wayland-protocols , libX11, libGL }: -stdenv.mkDerivation { - name = "glpaper"; +stdenv.mkDerivation rec { + pname = "glpaper"; version = "unstable-2020-10-11"; - src = fetchhg { - url = "https://hg.sr.ht/~scoopta/glpaper"; + src = fetchFromSourcehut { + owner = "~scoopta"; + repo = pname; + vc = "hg"; rev = "9e7ec7cd270af330039c395345c7d23c04682267"; sha256 = "sha256-yBHRg6eg+PK/ixuM0MBty3RJY9qcemr3Dt+8SAitqnk="; }; diff --git a/pkgs/games/among-sus/default.nix b/pkgs/games/among-sus/default.nix index 1ec0a42ea18e..454c7d181f95 100644 --- a/pkgs/games/among-sus/default.nix +++ b/pkgs/games/among-sus/default.nix @@ -1,11 +1,12 @@ -{ lib, stdenv, fetchgit, port ? "1234" }: +{ lib, stdenv, fetchFromSourcehut, port ? "1234" }: stdenv.mkDerivation { pname = "among-sus-unstable"; version = "2020-10-29"; - src = fetchgit { - url = "https://git.sr.ht/~martijnbraam/among-sus"; + src = fetchFromSourcehut { + owner = "~martijnbraam"; + repo = "among-sus"; rev = "1f4c8d800d025d36ac66826937161be3252fbc57"; sha256 = "19jq7ygh9l11dl1h6702bg57m04y35nqd6yqx1rgp1kxwhp45xyh"; }; diff --git a/pkgs/games/eidolon/default.nix b/pkgs/games/eidolon/default.nix index dcb72d53b328..7112c6bf49c5 100644 --- a/pkgs/games/eidolon/default.nix +++ b/pkgs/games/eidolon/default.nix @@ -1,11 +1,12 @@ -{ lib, fetchgit, rustPlatform, pkg-config, openssl }: +{ lib, fetchFromSourcehut, rustPlatform, pkg-config, openssl }: rustPlatform.buildRustPackage rec { pname = "eidolon"; version = "1.4.6"; - src = fetchgit { - url = "https://git.sr.ht/~nicohman/eidolon"; + src = fetchFromSourcehut { + owner = "~nicohman"; + repo = pname; rev = version; sha256 = "1yn3k569pxzw43mmsk97088xpkdc714rks3ncchbb6ccx25kgxrr"; }; diff --git a/pkgs/top-level/all-packages.nix b/pkgs/top-level/all-packages.nix index da4d58484dbf..69a72c158f08 100644 --- a/pkgs/top-level/all-packages.nix +++ b/pkgs/top-level/all-packages.nix @@ -482,6 +482,8 @@ in fetchFromSavannah = callPackage ../build-support/fetchsavannah {}; + fetchFromSourcehut = callPackage ../build-support/fetchsourcehut { }; + fetchFromGitLab = callPackage ../build-support/fetchgitlab {}; fetchFromGitiles = callPackage ../build-support/fetchgitiles {};