From 49d64a9d537f1cba2f2bb99dbeb269c6afc67727 Mon Sep 17 00:00:00 2001 From: Michael Weiss Date: Tue, 26 Sep 2017 20:47:18 +0200 Subject: [PATCH 1/2] fetchFromGitHub: Always add meta.homepage to the derivation The attribute meta.homepage was only added if "fetchFromGitHub = false" which might be unexpected. Now, it will be set unconditionally. --- pkgs/top-level/all-packages.nix | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/pkgs/top-level/all-packages.nix b/pkgs/top-level/all-packages.nix index 833322f3fd2d..0fe68b5ef8d6 100644 --- a/pkgs/top-level/all-packages.nix +++ b/pkgs/top-level/all-packages.nix @@ -198,7 +198,7 @@ with pkgs; baseUrl = "https://${githubBase}/${owner}/${repo}"; passthruAttrs = removeAttrs args [ "owner" "repo" "rev" "fetchSubmodules" "private" "githubBase" "varPrefix" ]; varBase = "NIX${if varPrefix == null then "" else "_${varPrefix}"}_GITHUB_PRIVATE_"; - in if fetchSubmodules then + in (if fetchSubmodules then fetchgit ({ inherit name rev fetchSubmodules; url = "${baseUrl}.git"; @@ -209,7 +209,6 @@ with pkgs; fetchzip ({ inherit name; url = "${baseUrl}/archive/${rev}.tar.gz"; - meta.homepage = "${baseUrl}/"; } // lib.optionalAttrs private { netrcPhase = '' if [ -z "''$${varBase}USERNAME" -o -z "''$${varBase}PASSWORD" ]; then @@ -223,7 +222,8 @@ with pkgs; EOF ''; netrcImpureEnvVars = [ "${varBase}USERNAME" "${varBase}PASSWORD" ]; - } // passthruAttrs) // { inherit rev; }; + } // passthruAttrs) // { inherit rev; }) + // { meta.homepage = baseUrl; }; fetchFromBitbucket = { owner, repo, rev, name ? gitRepoToName repo rev, From fe02d8c7b62ea341f1148a867b63bd755967ab4c Mon Sep 17 00:00:00 2001 From: Michael Weiss Date: Fri, 29 Sep 2017 16:48:50 +0200 Subject: [PATCH 2/2] fetchFromGitHub: Refactor the code And remove the tailing slash from "meta.homepage" as suggested by @orivej (because GitHub doesn't add the final slash). --- pkgs/top-level/all-packages.nix | 20 ++++++++------------ 1 file changed, 8 insertions(+), 12 deletions(-) diff --git a/pkgs/top-level/all-packages.nix b/pkgs/top-level/all-packages.nix index 0fe68b5ef8d6..db86a673e59a 100644 --- a/pkgs/top-level/all-packages.nix +++ b/pkgs/top-level/all-packages.nix @@ -198,18 +198,10 @@ with pkgs; baseUrl = "https://${githubBase}/${owner}/${repo}"; passthruAttrs = removeAttrs args [ "owner" "repo" "rev" "fetchSubmodules" "private" "githubBase" "varPrefix" ]; varBase = "NIX${if varPrefix == null then "" else "_${varPrefix}"}_GITHUB_PRIVATE_"; - in (if fetchSubmodules then - fetchgit ({ - inherit name rev fetchSubmodules; - url = "${baseUrl}.git"; - } // passthruAttrs) - else # We prefer fetchzip in cases we don't need submodules as the hash # is more stable in that case. - fetchzip ({ - inherit name; - url = "${baseUrl}/archive/${rev}.tar.gz"; - } // lib.optionalAttrs private { + fetcher = if fetchSubmodules then fetchgit else fetchzip; + privateAttrs = lib.optionalAttrs private { netrcPhase = '' if [ -z "''$${varBase}USERNAME" -o -z "''$${varBase}PASSWORD" ]; then echo "Error: Private fetchFromGitHub requires the nix building process (nix-daemon in multi user mode) to have the ${varBase}USERNAME and ${varBase}PASSWORD env vars set." >&2 @@ -222,8 +214,12 @@ with pkgs; EOF ''; netrcImpureEnvVars = [ "${varBase}USERNAME" "${varBase}PASSWORD" ]; - } // passthruAttrs) // { inherit rev; }) - // { meta.homepage = baseUrl; }; + }; + fetcherArgs = (if fetchSubmodules + then { inherit rev fetchSubmodules; url = "${baseUrl}.git"; } + else ({ url = "${baseUrl}/archive/${rev}.tar.gz"; } // privateAttrs) + ) // passthruAttrs // { inherit name; }; + in fetcher fetcherArgs // { meta.homepage = baseUrl; inherit rev; }; fetchFromBitbucket = { owner, repo, rev, name ? gitRepoToName repo rev,