fetchzip and friends: Set "name" to "source" by default
This makes them produce the same store paths as builtins.fetchgit,
builtins.fetchTarball etc. See
65b5f177b5
.
This commit is contained in:
parent
6d41ae55dd
commit
c3255fe8ec
|
@ -1,19 +0,0 @@
|
||||||
{ lib }:
|
|
||||||
|
|
||||||
let
|
|
||||||
inherit (lib) removeSuffix hasPrefix removePrefix splitString stringToCharacters concatMapStrings last elem;
|
|
||||||
|
|
||||||
allowedChars = stringToCharacters "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789+-._?=";
|
|
||||||
sanitizeStoreName = s:
|
|
||||||
let
|
|
||||||
s' = concatMapStrings (c: if elem c allowedChars then c else "") (stringToCharacters s);
|
|
||||||
s'' = if hasPrefix "." s' then "_${removePrefix "." s'}" else s';
|
|
||||||
in
|
|
||||||
s'';
|
|
||||||
in
|
|
||||||
urlOrRepo: rev:
|
|
||||||
let
|
|
||||||
repo' = last (splitString ":" (baseNameOf (removeSuffix ".git" (removeSuffix "/" urlOrRepo))));
|
|
||||||
rev' = baseNameOf rev;
|
|
||||||
in
|
|
||||||
"${sanitizeStoreName repo'}-${sanitizeStoreName rev'}-src"
|
|
|
@ -11,10 +11,11 @@
|
||||||
stripRoot ? true
|
stripRoot ? true
|
||||||
, url
|
, url
|
||||||
, extraPostFetch ? ""
|
, extraPostFetch ? ""
|
||||||
|
, name ? "source"
|
||||||
, ... } @ args:
|
, ... } @ args:
|
||||||
|
|
||||||
lib.overrideDerivation (fetchurl ({
|
lib.overrideDerivation (fetchurl ({
|
||||||
name = args.name or (baseNameOf url);
|
inherit name;
|
||||||
|
|
||||||
recursiveHash = true;
|
recursiveHash = true;
|
||||||
|
|
||||||
|
|
|
@ -195,10 +195,8 @@ with pkgs;
|
||||||
|
|
||||||
fetchzip = callPackage ../build-support/fetchzip { };
|
fetchzip = callPackage ../build-support/fetchzip { };
|
||||||
|
|
||||||
gitRepoToName = callPackage ../build-support/fetchgit/gitrepotoname.nix { };
|
|
||||||
|
|
||||||
fetchFromGitHub = {
|
fetchFromGitHub = {
|
||||||
owner, repo, rev, name ? gitRepoToName repo rev,
|
owner, repo, rev, name ? "source",
|
||||||
fetchSubmodules ? false, private ? false,
|
fetchSubmodules ? false, private ? false,
|
||||||
githubBase ? "github.com", varPrefix ? null,
|
githubBase ? "github.com", varPrefix ? null,
|
||||||
... # For hash agility
|
... # For hash agility
|
||||||
|
@ -231,7 +229,7 @@ with pkgs;
|
||||||
in fetcher fetcherArgs // { meta.homepage = baseUrl; inherit rev; };
|
in fetcher fetcherArgs // { meta.homepage = baseUrl; inherit rev; };
|
||||||
|
|
||||||
fetchFromBitbucket = {
|
fetchFromBitbucket = {
|
||||||
owner, repo, rev, name ? gitRepoToName repo rev,
|
owner, repo, rev, name ? "source",
|
||||||
... # For hash agility
|
... # For hash agility
|
||||||
}@args: fetchzip ({
|
}@args: fetchzip ({
|
||||||
inherit name;
|
inherit name;
|
||||||
|
@ -242,7 +240,7 @@ with pkgs;
|
||||||
|
|
||||||
# cgit example, snapshot support is optional in cgit
|
# cgit example, snapshot support is optional in cgit
|
||||||
fetchFromSavannah = {
|
fetchFromSavannah = {
|
||||||
repo, rev, name ? gitRepoToName repo rev,
|
repo, rev, name ? "source",
|
||||||
... # For hash agility
|
... # For hash agility
|
||||||
}@args: fetchzip ({
|
}@args: fetchzip ({
|
||||||
inherit name;
|
inherit name;
|
||||||
|
@ -252,7 +250,7 @@ with pkgs;
|
||||||
|
|
||||||
# gitlab example
|
# gitlab example
|
||||||
fetchFromGitLab = {
|
fetchFromGitLab = {
|
||||||
owner, repo, rev, name ? gitRepoToName repo rev,
|
owner, repo, rev, name ? "source",
|
||||||
... # For hash agility
|
... # For hash agility
|
||||||
}@args: fetchzip ({
|
}@args: fetchzip ({
|
||||||
inherit name;
|
inherit name;
|
||||||
|
@ -262,7 +260,7 @@ with pkgs;
|
||||||
|
|
||||||
# gitweb example, snapshot support is optional in gitweb
|
# gitweb example, snapshot support is optional in gitweb
|
||||||
fetchFromRepoOrCz = {
|
fetchFromRepoOrCz = {
|
||||||
repo, rev, name ? gitRepoToName repo rev,
|
repo, rev, name ? "source",
|
||||||
... # For hash agility
|
... # For hash agility
|
||||||
}@args: fetchzip ({
|
}@args: fetchzip ({
|
||||||
inherit name;
|
inherit name;
|
||||||
|
|
Loading…
Reference in a new issue