Skip to content

Commit

Permalink
fetchzip and friends: Set "name" to "source" by default
Browse files Browse the repository at this point in the history
This makes them produce the same store paths as builtins.fetchgit,
builtins.fetchTarball etc. See
NixOS/nix@65b5f17.
  • Loading branch information
edolstra committed Oct 30, 2017
1 parent 6d41ae5 commit c3255fe
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 27 deletions.
19 changes: 0 additions & 19 deletions pkgs/build-support/fetchgit/gitrepotoname.nix

This file was deleted.

3 changes: 2 additions & 1 deletion pkgs/build-support/fetchzip/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,11 @@
stripRoot ? true
, url
, extraPostFetch ? ""
, name ? "source"
, ... } @ args:

lib.overrideDerivation (fetchurl ({
name = args.name or (baseNameOf url);
inherit name;

recursiveHash = true;

Expand Down
12 changes: 5 additions & 7 deletions pkgs/top-level/all-packages.nix
Original file line number Diff line number Diff line change
Expand Up @@ -195,10 +195,8 @@ with pkgs;

fetchzip = callPackage ../build-support/fetchzip { };

gitRepoToName = callPackage ../build-support/fetchgit/gitrepotoname.nix { };

fetchFromGitHub = {
owner, repo, rev, name ? gitRepoToName repo rev,
owner, repo, rev, name ? "source",
fetchSubmodules ? false, private ? false,
githubBase ? "github.com", varPrefix ? null,
... # For hash agility
Expand Down Expand Up @@ -231,7 +229,7 @@ with pkgs;
in fetcher fetcherArgs // { meta.homepage = baseUrl; inherit rev; };

fetchFromBitbucket = {
owner, repo, rev, name ? gitRepoToName repo rev,
owner, repo, rev, name ? "source",
... # For hash agility
}@args: fetchzip ({
inherit name;
Expand All @@ -242,7 +240,7 @@ with pkgs;

# cgit example, snapshot support is optional in cgit
fetchFromSavannah = {
repo, rev, name ? gitRepoToName repo rev,
repo, rev, name ? "source",
... # For hash agility
}@args: fetchzip ({
inherit name;
Expand All @@ -252,7 +250,7 @@ with pkgs;

# gitlab example
fetchFromGitLab = {
owner, repo, rev, name ? gitRepoToName repo rev,
owner, repo, rev, name ? "source",
... # For hash agility
}@args: fetchzip ({
inherit name;
Expand All @@ -262,7 +260,7 @@ with pkgs;

# gitweb example, snapshot support is optional in gitweb
fetchFromRepoOrCz = {
repo, rev, name ? gitRepoToName repo rev,
repo, rev, name ? "source",
... # For hash agility
}@args: fetchzip ({
inherit name;
Expand Down

4 comments on commit c3255fe

@dezgeg
Copy link
Contributor

@dezgeg dezgeg commented on c3255fe Oct 30, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Doesn't this invalidate every existing fetch* hash?

@orivej
Copy link
Contributor

@orivej orivej commented on c3255fe Oct 30, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

At least for me descriptive names in /nix/store are important (for example if I want to look at the sources of a package that I've recently built I just ls -d /nix/store/*name*), and independence of the hash from the fetch method is not, although it's nice if it's achievable just by setting a constant name.

@orivej
Copy link
Contributor

@orivej orivej commented on c3255fe Oct 30, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Doesn't this invalidate every existing fetch* hash?

It does, here is PR to revert: #31004

@orivej
Copy link
Contributor

@orivej orivej commented on c3255fe Oct 31, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actually it does not: #31004 (comment)

Please sign in to comment.