From db097eb3b5b82965eb7dce659479f77a25241d27 Mon Sep 17 00:00:00 2001 From: Jacob Moody Date: Sun, 16 Jul 2023 22:48:14 -0500 Subject: [PATCH] lib: add fetchFrom9Front --- pkgs/build-support/fetch9front/default.nix | 36 ++++++++++++++++++++++ pkgs/top-level/all-packages.nix | 2 ++ 2 files changed, 38 insertions(+) create mode 100644 pkgs/build-support/fetch9front/default.nix diff --git a/pkgs/build-support/fetch9front/default.nix b/pkgs/build-support/fetch9front/default.nix new file mode 100644 index 000000000000..677fee1decd7 --- /dev/null +++ b/pkgs/build-support/fetch9front/default.nix @@ -0,0 +1,36 @@ +{ fetchgit, fetchzip, lib }: + +lib.makeOverridable ( + { owner + , repo + , rev + , domain ? "git.9front.org" + , name ? "source" + , leaveDotGit ? false + , deepClone ? false + , ... # For hash agility + } @ args: + + let + passthruAttrs = removeAttrs args [ "domain" "owner" "repo" "rev" "leaveDotGit" "deepClone" ]; + + useFetchGit = leaveDotGit || deepClone; + fetcher = if useFetchGit then fetchgit else fetchzip; + + gitRepoUrl = "git://${domain}/${owner}/${repo}"; + + fetcherArgs = (if useFetchGit then { + # git9 does not support shallow fetches + inherit rev leaveDotGit; + url = gitRepoUrl; + } else { + url = "https://${domain}/${owner}/${repo}/${rev}/snap.tar.gz"; + + passthru = { + inherit gitRepoUrl; + }; + }) // passthruAttrs // { inherit name; }; + in + + fetcher fetcherArgs // { inherit rev; } +) diff --git a/pkgs/top-level/all-packages.nix b/pkgs/top-level/all-packages.nix index 6194bb7a42aa..9043276231d4 100644 --- a/pkgs/top-level/all-packages.nix +++ b/pkgs/top-level/all-packages.nix @@ -1122,6 +1122,8 @@ with pkgs; fetchFromGitiles = callPackage ../build-support/fetchgitiles { }; + fetchFrom9Front = callPackage ../build-support/fetch9front { }; + fetchFromRepoOrCz = callPackage ../build-support/fetchrepoorcz { }; fetchgx = callPackage ../build-support/fetchgx { };