-
-
Notifications
You must be signed in to change notification settings - Fork 18.1k
prefer-remote-fetch: Fix evaluation for all fetchers and export additional attributes #475142
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -10,24 +10,38 @@ | |
| # $ mkdir ~/.config/nixpkgs/overlays/ | ||
| # $ echo 'self: super: super.prefer-remote-fetch self super' > ~/.config/nixpkgs/overlays/prefer-remote-fetch.nix | ||
| # | ||
| self: super: { | ||
| binary-cache = args: super.binary-cache ({ preferLocalBuild = false; } // args); | ||
| buildenv = args: super.buildenv ({ preferLocalBuild = false; } // args); | ||
| fetchfossil = args: super.fetchfossil ({ preferLocalBuild = false; } // args); | ||
| fetchdocker = args: super.fetchdocker ({ preferLocalBuild = false; } // args); | ||
| fetchgit = args: super.fetchgit ({ preferLocalBuild = false; } // args); | ||
| fetchgx = args: super.fetchgx ({ preferLocalBuild = false; } // args); | ||
| fetchhg = args: super.fetchhg ({ preferLocalBuild = false; } // args); | ||
| fetchipfs = args: super.fetchipfs ({ preferLocalBuild = false; } // args); | ||
| fetchrepoproject = args: super.fetchrepoproject ({ preferLocalBuild = false; } // args); | ||
| fetchs3 = args: super.fetchs3 ({ preferLocalBuild = false; } // args); | ||
| fetchsvn = args: super.fetchsvn ({ preferLocalBuild = false; } // args); | ||
| fetchurl = | ||
| fpArgs: | ||
| super.fetchurl ( | ||
| super.lib.extends (finalAttrs: args: { preferLocalBuild = args.preferLocalBuild or false; }) ( | ||
| super.lib.toFunction fpArgs | ||
| ) | ||
| ); | ||
| mkNugetSource = args: super.mkNugetSource ({ preferLocalBuild = false; } // args); | ||
| self: super: | ||
| let | ||
| preferLocal = | ||
| orig: | ||
| self.lib.extendMkDerivation { | ||
| constructDrv = orig; | ||
| extendDrvArgs = | ||
| finalAttrs: | ||
| { | ||
| preferLocalBuild ? false, | ||
| ... | ||
| }: | ||
| { | ||
| inherit preferLocalBuild; | ||
| }; | ||
| }; | ||
|
|
||
| in | ||
| { | ||
| binary-cache = preferLocal super.binary-cache; | ||
| buildenv = preferLocal super.buildenv; | ||
| fetchfossil = preferLocal super.fetchfossil; | ||
| fetchdocker = preferLocal super.fetchdocker; | ||
| fetchgit = (preferLocal super.fetchgit) // { | ||
| inherit (super.fetchgit) getRevWithTag; | ||
| }; | ||
| fetchgx = preferLocal super.fetchgx; | ||
| fetchhg = preferLocal super.fetchhg; | ||
| fetchipfs = preferLocal super.fetchipfs; | ||
| fetchrepoproject = preferLocal super.fetchrepoproject; | ||
| fetchs3 = preferLocal super.fetchs3; | ||
| fetchsvn = preferLocal super.fetchsvn; | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This broke fetchsvn for me: I would guess because it did not, yet (?) get the same updates as other by @ShamrockLee https://github.com/NixOS/nixpkgs/commits/master/pkgs/build-support/fetchsvn Not sure if we should revert or change it to the newer ways to do things. In the meantime I just applied this locally: diff --git a/pkgs/build-support/prefer-remote-fetch/default.nix b/pkgs/build-support/prefer-remote-fetch/default.nix
index c39caf4d6b4d..593866ddee78 100644
--- a/pkgs/build-support/prefer-remote-fetch/default.nix
+++ b/pkgs/build-support/prefer-remote-fetch/default.nix
@@ -41,7 +41,7 @@
fetchipfs = preferLocal super.fetchipfs;
fetchrepoproject = preferLocal super.fetchrepoproject;
fetchs3 = preferLocal super.fetchs3;
- fetchsvn = preferLocal super.fetchsvn;
+ fetchsvn = args: super.fetchsvn ({ preferLocalBuild = false; } // args);
fetchurl = preferLocal super.fetchurl;
mkNugetSource = preferLocal super.mkNugetSource;
} |
||
| fetchurl = preferLocal super.fetchurl; | ||
| mkNugetSource = preferLocal super.mkNugetSource; | ||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,49 @@ | ||
| { pkgs, ... }: | ||
|
|
||
| let | ||
| pkgs' = pkgs.extend (self: super: super.prefer-remote-fetch self super); | ||
|
|
||
| check = | ||
| fn: args: | ||
| let | ||
| drv = pkgs'.testers.invalidateFetcherByDrvHash fn args; | ||
| in | ||
| if drv.preferLocalBuild then throw "Fetcher must not prefer local builds" else drv; | ||
|
|
||
| in | ||
| pkgs'.callPackage ( | ||
| { | ||
| testers, | ||
| fetchgit, | ||
| fetchFromGitHub, | ||
| fetchurl, | ||
| fetchzip, | ||
| ... | ||
| }: | ||
| { | ||
| fetchgit = check fetchgit { | ||
| name = "simple-nix-source"; | ||
| url = "https://github.com/NixOS/nix"; | ||
| rev = "9d9dbe6ed05854e03811c361a3380e09183f4f4a"; | ||
| sha256 = "sha256-7DszvbCNTjpzGRmpIVAWXk20P0/XTrWZ79KSOGLrUWY="; | ||
| }; | ||
|
|
||
| fetchFromGitHub = check fetchFromGitHub { | ||
| name = "simple-nix-source"; | ||
| owner = "NixOS"; | ||
| repo = "nix"; | ||
| rev = "9d9dbe6ed05854e03811c361a3380e09183f4f4a"; | ||
| hash = "sha256-7DszvbCNTjpzGRmpIVAWXk20P0/XTrWZ79KSOGLrUWY="; | ||
| }; | ||
|
|
||
| fetchurl = check fetchurl { | ||
| url = "https://gist.github.com/glandium/01d54cefdb70561b5f6675e08f2990f2/archive/2f430f0c136a69b0886281d0c76708997d8878af.zip"; | ||
| sha256 = "sha256-J/ZWC23GmFfew/56NQvPqKzqkWgjOaPvbMicFJnuJxI="; | ||
| }; | ||
|
|
||
| fetchzip = check fetchzip { | ||
| url = "https://gist.github.com/glandium/01d54cefdb70561b5f6675e08f2990f2/archive/2f430f0c136a69b0886281d0c76708997d8878af.zip"; | ||
| sha256 = "sha256-0ecwgL8qUavSj1+WkaxpmRBmu7cvj53V5eXQV71fddU="; | ||
| }; | ||
| } | ||
| ) { } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looks fishy to me: I think it's adding the name into the
__functorattrset. If it works for you, I think it's fine though.