From 9375cf20083c296b6db94f8534b3372c21f0cb69 Mon Sep 17 00:00:00 2001 From: Nicolas Benes Date: Sat, 18 Nov 2023 13:14:08 +0100 Subject: [PATCH 1/3] fetchgitlab: make args more similar to fetchgithub --- pkgs/build-support/fetchgitlab/default.nix | 7 ++++--- pkgs/build-support/fetchzip/default.nix | 2 +- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/pkgs/build-support/fetchgitlab/default.nix b/pkgs/build-support/fetchgitlab/default.nix index 146845e06a71..69361fcbdf81 100644 --- a/pkgs/build-support/fetchgitlab/default.nix +++ b/pkgs/build-support/fetchgitlab/default.nix @@ -1,9 +1,10 @@ -{ fetchgit, fetchzip, lib }: +{ lib, fetchgit, fetchzip }: lib.makeOverridable ( # gitlab example { owner, repo, rev, protocol ? "https", domain ? "gitlab.com", name ? "source", group ? null -, fetchSubmodules ? false, leaveDotGit ? false, deepClone ? false +, fetchSubmodules ? false, leaveDotGit ? false +, deepClone ? false , ... # For hash agility } @ args: @@ -13,7 +14,7 @@ let escapedRev = lib.replaceStrings [ "+" "%" "/" ] [ "%2B" "%25" "%2F" ] rev; passthruAttrs = removeAttrs args [ "protocol" "domain" "owner" "group" "repo" "rev" "fetchSubmodules" "leaveDotGit" "deepClone" ]; - useFetchGit = deepClone || fetchSubmodules || leaveDotGit; + useFetchGit = fetchSubmodules || leaveDotGit || deepClone; fetcher = if useFetchGit then fetchgit else fetchzip; gitRepoUrl = "${protocol}://${domain}/${slug}.git"; diff --git a/pkgs/build-support/fetchzip/default.nix b/pkgs/build-support/fetchzip/default.nix index 0446851d6409..6e6c5270a750 100644 --- a/pkgs/build-support/fetchzip/default.nix +++ b/pkgs/build-support/fetchzip/default.nix @@ -24,7 +24,7 @@ # the rest are given to fetchurl as is , ... } @ args: -assert (extraPostFetch != "") -> lib.warn "use 'postFetch' instead of 'extraPostFetch' with 'fetchzip' and 'fetchFromGitHub'." true; +assert (extraPostFetch != "") -> lib.warn "use 'postFetch' instead of 'extraPostFetch' with 'fetchzip' and 'fetchFromGitHub' or 'fetchFromGitLab'." true; let tmpFilename = From a838881cdacef7685b95f0c9088c6ed14228dc1f Mon Sep 17 00:00:00 2001 From: Nicolas Benes Date: Sat, 18 Nov 2023 13:14:08 +0100 Subject: [PATCH 2/3] fetchgitlab: add option for sparse checkout --- pkgs/build-support/fetchgitlab/default.nix | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/pkgs/build-support/fetchgitlab/default.nix b/pkgs/build-support/fetchgitlab/default.nix index 69361fcbdf81..33c19bd1cab9 100644 --- a/pkgs/build-support/fetchgitlab/default.nix +++ b/pkgs/build-support/fetchgitlab/default.nix @@ -5,6 +5,7 @@ lib.makeOverridable ( { owner, repo, rev, protocol ? "https", domain ? "gitlab.com", name ? "source", group ? null , fetchSubmodules ? false, leaveDotGit ? false , deepClone ? false +, sparseCheckout ? [] , ... # For hash agility } @ args: @@ -14,13 +15,13 @@ let escapedRev = lib.replaceStrings [ "+" "%" "/" ] [ "%2B" "%25" "%2F" ] rev; passthruAttrs = removeAttrs args [ "protocol" "domain" "owner" "group" "repo" "rev" "fetchSubmodules" "leaveDotGit" "deepClone" ]; - useFetchGit = fetchSubmodules || leaveDotGit || deepClone; + useFetchGit = fetchSubmodules || leaveDotGit || deepClone || (sparseCheckout != []); fetcher = if useFetchGit then fetchgit else fetchzip; gitRepoUrl = "${protocol}://${domain}/${slug}.git"; fetcherArgs = (if useFetchGit then { - inherit rev deepClone fetchSubmodules leaveDotGit; + inherit rev deepClone fetchSubmodules sparseCheckout leaveDotGit; url = gitRepoUrl; } else { url = "${protocol}://${domain}/api/v4/projects/${escapedSlug}/repository/archive.tar.gz?sha=${escapedRev}"; From cf00f9c2ea24f80f1ecea7d9fdd5c5a11e12f997 Mon Sep 17 00:00:00 2001 From: Nicolas Benes Date: Sat, 18 Nov 2023 13:14:08 +0100 Subject: [PATCH 3/3] fetchgitlab: add option to force fetchgit --- pkgs/build-support/fetchgitlab/default.nix | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/pkgs/build-support/fetchgitlab/default.nix b/pkgs/build-support/fetchgitlab/default.nix index 33c19bd1cab9..16ece2715357 100644 --- a/pkgs/build-support/fetchgitlab/default.nix +++ b/pkgs/build-support/fetchgitlab/default.nix @@ -4,7 +4,7 @@ lib.makeOverridable ( # gitlab example { owner, repo, rev, protocol ? "https", domain ? "gitlab.com", name ? "source", group ? null , fetchSubmodules ? false, leaveDotGit ? false -, deepClone ? false +, deepClone ? false, forceFetchGit ? false , sparseCheckout ? [] , ... # For hash agility } @ args: @@ -13,9 +13,9 @@ let slug = lib.concatStringsSep "/" ((lib.optional (group != null) group) ++ [ owner repo ]); escapedSlug = lib.replaceStrings [ "." "/" ] [ "%2E" "%2F" ] slug; escapedRev = lib.replaceStrings [ "+" "%" "/" ] [ "%2B" "%25" "%2F" ] rev; - passthruAttrs = removeAttrs args [ "protocol" "domain" "owner" "group" "repo" "rev" "fetchSubmodules" "leaveDotGit" "deepClone" ]; + passthruAttrs = removeAttrs args [ "protocol" "domain" "owner" "group" "repo" "rev" "fetchSubmodules" "forceFetchGit" "leaveDotGit" "deepClone" ]; - useFetchGit = fetchSubmodules || leaveDotGit || deepClone || (sparseCheckout != []); + useFetchGit = fetchSubmodules || leaveDotGit || deepClone || forceFetchGit || (sparseCheckout != []); fetcher = if useFetchGit then fetchgit else fetchzip; gitRepoUrl = "${protocol}://${domain}/${slug}.git";