From 208f1fb7e153ab5076aeb826050833e428c17716 Mon Sep 17 00:00:00 2001 From: Aneesh Agrawal Date: Sun, 1 May 2016 13:00:49 -0400 Subject: [PATCH] Allow any hash for git-based fetch* derivations Instead of hard-coding which hash types are available, merge the input arg set into the fetchzip arguments to enable passing any hash type that the underyling fetchurl (underneath fetchzip, which does the same thing) supports for hash agility. Also, provide rev attributes on all of these derivations, not just fetchFromGitHub. --- pkgs/top-level/all-packages.nix | 45 ++++++++++++++++++++++----------- 1 file changed, 30 insertions(+), 15 deletions(-) diff --git a/pkgs/top-level/all-packages.nix b/pkgs/top-level/all-packages.nix index 5a52289d7e2b..4f38ab19a0d7 100644 --- a/pkgs/top-level/all-packages.nix +++ b/pkgs/top-level/all-packages.nix @@ -223,39 +223,54 @@ in fetchzip = callPackage ../build-support/fetchzip { }; - fetchFromGitHub = { owner, repo, rev, sha256, name ? "${repo}-${rev}-src" }: fetchzip { - inherit name sha256; + fetchFromGitHub = { + owner, repo, rev, name ? "${repo}-${rev}-src", + ... # For hash agility + }@args: fetchzip ({ + inherit name; url = "https://github.com/${owner}/${repo}/archive/${rev}.tar.gz"; meta.homepage = "https://github.com/${owner}/${repo}/"; - } // { inherit rev; }; + } // removeAttrs args [ "owner" "repo" "rev" ]) // { inherit rev; }; - fetchFromBitbucket = { owner, repo, rev, sha256, name ? "${repo}-${rev}-src" }: fetchzip { - inherit name sha256; + fetchFromBitbucket = { + owner, repo, rev, name ? "${repo}-${rev}-src", + ... # For hash agility + }@args: fetchzip ({ + inherit name; url = "https://bitbucket.org/${owner}/${repo}/get/${rev}.tar.gz"; meta.homepage = "https://bitbucket.org/${owner}/${repo}/"; extraPostFetch = ''rm -f "$out"/.hg_archival.txt''; # impure file; see #12002 - }; + } // removeAttrs args [ "owner" "repo" "rev" ]) // { inherit rev; }; # cgit example, snapshot support is optional in cgit - fetchFromSavannah = { repo, rev, sha256, name ? "${repo}-${rev}-src" }: fetchzip { - inherit name sha256; + fetchFromSavannah = { + repo, rev, name ? "${repo}-${rev}-src", + ... # For hash agility + }@args: fetchzip ({ + inherit name; url = "http://git.savannah.gnu.org/cgit/${repo}.git/snapshot/${repo}-${rev}.tar.gz"; meta.homepage = "http://git.savannah.gnu.org/cgit/${repo}.git/"; - }; + } // removeAttrs args [ "repo" "rev" ]) // { inherit rev; }; # gitlab example - fetchFromGitLab = { owner, repo, rev, sha256, name ? "${repo}-${rev}-src" }: fetchzip { - inherit name sha256; + fetchFromGitLab = { + owner, repo, rev, name ? "${repo}-${rev}-src", + ... # For hash agility + }@args: fetchzip ({ + inherit name; url = "https://gitlab.com/${owner}/${repo}/repository/archive.tar.gz?ref=${rev}"; meta.homepage = "https://gitlab.com/${owner}/${repo}/"; - }; + } // removeAttrs args [ "owner" "repo" "rev" ]) // { inherit rev; }; # gitweb example, snapshot support is optional in gitweb - fetchFromRepoOrCz = { repo, rev, sha256, name ? "${repo}-${rev}-src" }: fetchzip { - inherit name sha256; + fetchFromRepoOrCz = { + repo, rev, name ? "${repo}-${rev}-src", + ... # For hash agility + }@args: fetchzip ({ + inherit name; url = "http://repo.or.cz/${repo}.git/snapshot/${rev}.tar.gz"; meta.homepage = "http://repo.or.cz/${repo}.git/"; - }; + } // removeAttrs args [ "repo" "rev" ]) // { inherit rev; }; fetchNuGet = callPackage ../build-support/fetchnuget { }; buildDotnetPackage = callPackage ../build-support/build-dotnet-package { };