Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
54 changes: 34 additions & 20 deletions pkgs/build-support/prefer-remote-fetch/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -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;
};
Comment on lines +36 to +38
Copy link
Contributor

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 __functor attrset. If it works for you, I think it's fine though.

fetchgx = preferLocal super.fetchgx;
fetchhg = preferLocal super.fetchhg;
fetchipfs = preferLocal super.fetchipfs;
fetchrepoproject = preferLocal super.fetchrepoproject;
fetchs3 = preferLocal super.fetchs3;
fetchsvn = preferLocal super.fetchsvn;
Copy link
Member

Choose a reason for hiding this comment

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

This broke fetchsvn for me:

       … while evaluating derivation 'spandsp-0.0.6'
         whose name attribute is located at «github:SuperSandro2000/nixpkgs/d2c08b67266740e96efa12a20e3cbf4f3ddee847?narHash=sha256-Cqa2%2BMhtVjob3bncQlNMVAWS/BJSAA%2BDYyUhFZF1%2B78%3D»/pkgs/stdenv/generic/make-derivation.nix:541:13

       … while evaluating attribute 'nativeBuildInputs' of derivation 'spandsp-0.0.6'
         at «github:SuperSandro2000/nixpkgs/d2c08b67266740e96efa12a20e3cbf4f3ddee847?narHash=sha256-Cqa2%2BMhtVjob3bncQlNMVAWS/BJSAA%2BDYyUhFZF1%2B78%3D»/pkgs/stdenv/generic/make-derivation.nix:590:13:
          589|             depsBuildBuild = elemAt (elemAt dependencies 0) 0;
          590|             nativeBuildInputs = elemAt (elemAt dependencies 0) 1;
             |             ^
          591|             depsBuildTarget = elemAt (elemAt dependencies 0) 2;

       … in the condition of the assert statement
         at «github:SuperSandro2000/nixpkgs/d2c08b67266740e96efa12a20e3cbf4f3ddee847?narHash=sha256-Cqa2%2BMhtVjob3bncQlNMVAWS/BJSAA%2BDYyUhFZF1%2B78%3D»/lib/customisation.nix:429:15:
          428|             outPath =
          429|               assert condition;
             |               ^
          430|               drv.${outputName}.outPath;

       … from call site
         at «github:SuperSandro2000/nixpkgs/d2c08b67266740e96efa12a20e3cbf4f3ddee847?narHash=sha256-Cqa2%2BMhtVjob3bncQlNMVAWS/BJSAA%2BDYyUhFZF1%2B78%3D»/pkgs/stdenv/generic/make-derivation.nix:835:18:
          834|       };
          835|       validity = checkMeta.assertValidity { inherit meta attrs; };
             |                  ^
          836|

       … while calling 'assertValidity'
         at «github:SuperSandro2000/nixpkgs/d2c08b67266740e96efa12a20e3cbf4f3ddee847?narHash=sha256-Cqa2%2BMhtVjob3bncQlNMVAWS/BJSAA%2BDYyUhFZF1%2B78%3D»/pkgs/stdenv/generic/check-meta.nix:696:5:
          695|   assertValidity =
          696|     { meta, attrs }:
             |     ^
          697|     let

       … while evaluating a branch condition
         at «github:SuperSandro2000/nixpkgs/d2c08b67266740e96efa12a20e3cbf4f3ddee847?narHash=sha256-Cqa2%2BMhtVjob3bncQlNMVAWS/BJSAA%2BDYyUhFZF1%2B78%3D»/pkgs/stdenv/generic/check-meta.nix:701:5:
          700|     in
          701|     if isNull invalid then
             |     ^
          702|       if isNull warning then

       … while calling the 'isNull' builtin
         at «github:SuperSandro2000/nixpkgs/d2c08b67266740e96efa12a20e3cbf4f3ddee847?narHash=sha256-Cqa2%2BMhtVjob3bncQlNMVAWS/BJSAA%2BDYyUhFZF1%2B78%3D»/pkgs/stdenv/generic/check-meta.nix:701:8:
          700|     in
          701|     if isNull invalid then
             |        ^
          702|       if isNull warning then

       … from call site
         at «github:SuperSandro2000/nixpkgs/d2c08b67266740e96efa12a20e3cbf4f3ddee847?narHash=sha256-Cqa2%2BMhtVjob3bncQlNMVAWS/BJSAA%2BDYyUhFZF1%2B78%3D»/pkgs/stdenv/generic/check-meta.nix:698:17:
          697|     let
          698|       invalid = checkValidity attrs;
             |                 ^
          699|       warning = checkWarnings attrs;

       … while calling 'checkValidity'
         at «github:SuperSandro2000/nixpkgs/d2c08b67266740e96efa12a20e3cbf4f3ddee847?narHash=sha256-Cqa2%2BMhtVjob3bncQlNMVAWS/BJSAA%2BDYyUhFZF1%2B78%3D»/pkgs/stdenv/generic/check-meta.nix:451:5:
          450|   checkValidity =
          451|     attrs:
             |     ^
          452|     # Check meta attribute types first, to make sure it is always called even when there are other issues

       … while evaluating a branch condition
         at «github:SuperSandro2000/nixpkgs/d2c08b67266740e96efa12a20e3cbf4f3ddee847?narHash=sha256-Cqa2%2BMhtVjob3bncQlNMVAWS/BJSAA%2BDYyUhFZF1%2B78%3D»/pkgs/stdenv/generic/check-meta.nix:454:5:
          453|     # Note that this is not a full type check and functions below still need to by careful about their inputs!
          454|     if metaInvalid (attrs.meta or { }) then
             |     ^
          455|       {

       … from call site
         at «github:SuperSandro2000/nixpkgs/d2c08b67266740e96efa12a20e3cbf4f3ddee847?narHash=sha256-Cqa2%2BMhtVjob3bncQlNMVAWS/BJSAA%2BDYyUhFZF1%2B78%3D»/pkgs/stdenv/generic/check-meta.nix:454:8:
          453|     # Note that this is not a full type check and functions below still need to by careful about their inputs!
          454|     if metaInvalid (attrs.meta or { }) then
             |        ^
          455|       {

       … while calling anonymous lambda
         at «github:SuperSandro2000/nixpkgs/d2c08b67266740e96efa12a20e3cbf4f3ddee847?narHash=sha256-Cqa2%2BMhtVjob3bncQlNMVAWS/BJSAA%2BDYyUhFZF1%2B78%3D»/pkgs/stdenv/generic/check-meta.nix:428:7:
          427|     if config.checkMeta then
          428|       meta: !all (attr: metaTypes ? ${attr} && metaTypes'.${attr} meta.${attr}) (attrNames meta)
             |       ^
          429|     else

       … in the argument of the not operator
         at «github:SuperSandro2000/nixpkgs/d2c08b67266740e96efa12a20e3cbf4f3ddee847?narHash=sha256-Cqa2%2BMhtVjob3bncQlNMVAWS/BJSAA%2BDYyUhFZF1%2B78%3D»/pkgs/stdenv/generic/check-meta.nix:428:14:
          427|     if config.checkMeta then
          428|       meta: !all (attr: metaTypes ? ${attr} && metaTypes'.${attr} meta.${attr}) (attrNames meta)
             |              ^
          429|     else

       … while calling the 'all' builtin
         at «github:SuperSandro2000/nixpkgs/d2c08b67266740e96efa12a20e3cbf4f3ddee847?narHash=sha256-Cqa2%2BMhtVjob3bncQlNMVAWS/BJSAA%2BDYyUhFZF1%2B78%3D»/pkgs/stdenv/generic/check-meta.nix:428:14:
          427|     if config.checkMeta then
          428|       meta: !all (attr: metaTypes ? ${attr} && metaTypes'.${attr} meta.${attr}) (attrNames meta)
             |              ^
          429|     else

       … while calling anonymous lambda
         at «github:SuperSandro2000/nixpkgs/d2c08b67266740e96efa12a20e3cbf4f3ddee847?narHash=sha256-Cqa2%2BMhtVjob3bncQlNMVAWS/BJSAA%2BDYyUhFZF1%2B78%3D»/pkgs/stdenv/generic/check-meta.nix:428:19:
          427|     if config.checkMeta then
          428|       meta: !all (attr: metaTypes ? ${attr} && metaTypes'.${attr} meta.${attr}) (attrNames meta)
             |                   ^
          429|     else

       … in the right operand of the AND (&&) operator
         at «github:SuperSandro2000/nixpkgs/d2c08b67266740e96efa12a20e3cbf4f3ddee847?narHash=sha256-Cqa2%2BMhtVjob3bncQlNMVAWS/BJSAA%2BDYyUhFZF1%2B78%3D»/pkgs/stdenv/generic/check-meta.nix:428:45:
          427|     if config.checkMeta then
          428|       meta: !all (attr: metaTypes ? ${attr} && metaTypes'.${attr} meta.${attr}) (attrNames meta)
             |                                             ^
          429|     else

       … from call site
         at «github:SuperSandro2000/nixpkgs/d2c08b67266740e96efa12a20e3cbf4f3ddee847?narHash=sha256-Cqa2%2BMhtVjob3bncQlNMVAWS/BJSAA%2BDYyUhFZF1%2B78%3D»/pkgs/stdenv/generic/check-meta.nix:428:48:
          427|     if config.checkMeta then
          428|       meta: !all (attr: metaTypes ? ${attr} && metaTypes'.${attr} meta.${attr}) (attrNames meta)
             |                                                ^
          429|     else

       … while calling 'verify'
         at «github:SuperSandro2000/nixpkgs/d2c08b67266740e96efa12a20e3cbf4f3ddee847?narHash=sha256-Cqa2%2BMhtVjob3bncQlNMVAWS/BJSAA%2BDYyUhFZF1%2B78%3D»/pkgs/stdenv/generic/meta-types.nix:96:16:
           95|       name = "union<${concatStringsSep "," (map (t: t.name) types)}>";
           96|       verify = v: any (func: func v) funcs;
             |                ^
           97|     };

       … while calling the 'any' builtin
         at «github:SuperSandro2000/nixpkgs/d2c08b67266740e96efa12a20e3cbf4f3ddee847?narHash=sha256-Cqa2%2BMhtVjob3bncQlNMVAWS/BJSAA%2BDYyUhFZF1%2B78%3D»/pkgs/stdenv/generic/meta-types.nix:96:19:
           95|       name = "union<${concatStringsSep "," (map (t: t.name) types)}>";
           96|       verify = v: any (func: func v) funcs;
             |                   ^
           97|     };

       … while calling anonymous lambda
         at «github:SuperSandro2000/nixpkgs/d2c08b67266740e96efa12a20e3cbf4f3ddee847?narHash=sha256-Cqa2%2BMhtVjob3bncQlNMVAWS/BJSAA%2BDYyUhFZF1%2B78%3D»/pkgs/stdenv/generic/meta-types.nix:96:24:
           95|       name = "union<${concatStringsSep "," (map (t: t.name) types)}>";
           96|       verify = v: any (func: func v) funcs;
             |                        ^
           97|     };

       … from call site
         at «github:SuperSandro2000/nixpkgs/d2c08b67266740e96efa12a20e3cbf4f3ddee847?narHash=sha256-Cqa2%2BMhtVjob3bncQlNMVAWS/BJSAA%2BDYyUhFZF1%2B78%3D»/pkgs/stdenv/generic/meta-types.nix:96:30:
           95|       name = "union<${concatStringsSep "," (map (t: t.name) types)}>";
           96|       verify = v: any (func: func v) funcs;
             |                              ^
           97|     };

       … while calling anonymous lambda
         at «github:SuperSandro2000/nixpkgs/d2c08b67266740e96efa12a20e3cbf4f3ddee847?narHash=sha256-Cqa2%2BMhtVjob3bncQlNMVAWS/BJSAA%2BDYyUhFZF1%2B78%3D»/pkgs/stdenv/generic/meta-types.nix:84:43:
           83|         # listOf<any> can be optimised to just isList
           84|         if t == self.any then isList else v: isList v && all verify v;
             |                                           ^
           85|     };

       … in the left operand of the AND (&&) operator
         at «github:SuperSandro2000/nixpkgs/d2c08b67266740e96efa12a20e3cbf4f3ddee847?narHash=sha256-Cqa2%2BMhtVjob3bncQlNMVAWS/BJSAA%2BDYyUhFZF1%2B78%3D»/pkgs/stdenv/generic/meta-types.nix:84:55:
           83|         # listOf<any> can be optimised to just isList
           84|         if t == self.any then isList else v: isList v && all verify v;
             |                                                       ^
           85|     };

       … while calling the 'isList' builtin
         at «github:SuperSandro2000/nixpkgs/d2c08b67266740e96efa12a20e3cbf4f3ddee847?narHash=sha256-Cqa2%2BMhtVjob3bncQlNMVAWS/BJSAA%2BDYyUhFZF1%2B78%3D»/pkgs/stdenv/generic/meta-types.nix:84:46:
           83|         # listOf<any> can be optimised to just isList
           84|         if t == self.any then isList else v: isList v && all verify v;
             |                                              ^
           85|     };

       … while evaluating the attribute 'changelog'
         at «github:SuperSandro2000/nixpkgs/d2c08b67266740e96efa12a20e3cbf4f3ddee847?narHash=sha256-Cqa2%2BMhtVjob3bncQlNMVAWS/BJSAA%2BDYyUhFZF1%2B78%3D»/pkgs/by-name/ne/netpbm/package.nix:132:5:
          131|   meta = {
          132|     changelog = "https://sourceforge.net/p/netpbm/code/${src.rev}/tree/advanced/doc/HISTORY";
             |     ^
          133|     homepage = "https://netpbm.sourceforge.net/";

       … while calling a functor (an attribute set with a '__functor' attribute)
         at «github:SuperSandro2000/nixpkgs/d2c08b67266740e96efa12a20e3cbf4f3ddee847?narHash=sha256-Cqa2%2BMhtVjob3bncQlNMVAWS/BJSAA%2BDYyUhFZF1%2B78%3D»/pkgs/by-name/ne/netpbm/package.nix:32:9:
           31|
           32|   src = fetchsvn {
             |         ^
           33|     url = "https://svn.code.sf.net/p/netpbm/code/advanced";

       … from call site
         at «github:SuperSandro2000/nixpkgs/d2c08b67266740e96efa12a20e3cbf4f3ddee847?narHash=sha256-Cqa2%2BMhtVjob3bncQlNMVAWS/BJSAA%2BDYyUhFZF1%2B78%3D»/lib/trivial.nix:1017:5:
         1016|     # TODO: Should we add call-time "type" checking like built in?
         1017|     __functor = self: f;
             |     ^
         1018|     __functionArgs = args;

       … while calling anonymous lambda
         at «github:SuperSandro2000/nixpkgs/d2c08b67266740e96efa12a20e3cbf4f3ddee847?narHash=sha256-Cqa2%2BMhtVjob3bncQlNMVAWS/BJSAA%2BDYyUhFZF1%2B78%3D»/lib/customisation.nix:880:9:
          879|       (
          880|         fpargs:
             |         ^
          881|         transformDrv (

       … from call site
         at «github:SuperSandro2000/nixpkgs/d2c08b67266740e96efa12a20e3cbf4f3ddee847?narHash=sha256-Cqa2%2BMhtVjob3bncQlNMVAWS/BJSAA%2BDYyUhFZF1%2B78%3D»/lib/customisation.nix:881:9:
          880|         fpargs:
          881|         transformDrv (
             |         ^
          882|           constructDrv (extendsWithExclusion excludeDrvArgNames extendDrvArgs (toFunction fpargs))

       … while calling 'id'
         at «github:SuperSandro2000/nixpkgs/d2c08b67266740e96efa12a20e3cbf4f3ddee847?narHash=sha256-Cqa2%2BMhtVjob3bncQlNMVAWS/BJSAA%2BDYyUhFZF1%2B78%3D»/lib/trivial.nix:57:8:
           56|   */
           57|   id = x: x;
             |        ^
           58|

       … while calling a functor (an attribute set with a '__functor' attribute)
         at «github:SuperSandro2000/nixpkgs/d2c08b67266740e96efa12a20e3cbf4f3ddee847?narHash=sha256-Cqa2%2BMhtVjob3bncQlNMVAWS/BJSAA%2BDYyUhFZF1%2B78%3D»/lib/customisation.nix:882:11:
          881|         transformDrv (
          882|           constructDrv (extendsWithExclusion excludeDrvArgNames extendDrvArgs (toFunction fpargs))
             |           ^
          883|         )

       … from call site
         at «github:SuperSandro2000/nixpkgs/d2c08b67266740e96efa12a20e3cbf4f3ddee847?narHash=sha256-Cqa2%2BMhtVjob3bncQlNMVAWS/BJSAA%2BDYyUhFZF1%2B78%3D»/lib/trivial.nix:1017:5:
         1016|     # TODO: Should we add call-time "type" checking like built in?
         1017|     __functor = self: f;
             |     ^
         1018|     __functionArgs = args;

       … while evaluating the value passed for the lambda argument
         at «github:SuperSandro2000/nixpkgs/d2c08b67266740e96efa12a20e3cbf4f3ddee847?narHash=sha256-Cqa2%2BMhtVjob3bncQlNMVAWS/BJSAA%2BDYyUhFZF1%2B78%3D»/pkgs/build-support/fetchsvn/default.nix:43:1:
           42|
           43| {
             | ^
           44|   url,

       error: expected a set but found a function: «lambda extendsWithExclusion @ «github:SuperSandro2000/nixpkgs/d2c08b67266740e96efa12a20e3cbf4f3ddee847?narHash=sha256-Cqa2%2BMhtVjob3bncQlNMVAWS/BJSAA%2BDYyUhFZF1%2B78%3D»/lib/customisation.nix:863:30»

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;
}
49 changes: 49 additions & 0 deletions pkgs/build-support/prefer-remote-fetch/tests.nix
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=";
};
}
) { }
4 changes: 4 additions & 0 deletions pkgs/test/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -246,4 +246,8 @@ in
build-environment-info = callPackage ./build-environment-info { };

rust-hooks = recurseIntoAttrs (callPackages ../build-support/rust/hooks/test { });

prefer-remote-fetch = recurseIntoAttrs (
callPackages ../build-support/prefer-remote-fetch/tests.nix { }
);
}
Loading