Skip to content
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

allow fetchpatch everywhere, without restrictions #188587

Closed
wants to merge 15 commits into from
Closed
Show file tree
Hide file tree
Changes from 9 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
35 changes: 29 additions & 6 deletions pkgs/build-support/fetchurl/boot.nix
Original file line number Diff line number Diff line change
@@ -1,20 +1,25 @@
let mirrors = import ./mirrors.nix; in

{ system }:
{ system
, stdenv
, fetchurl }:

{ url ? builtins.head urls
, urls ? []
, sha256 ? ""
, hash ? ""
, name ? baseNameOf (toString url)
}:
, __impure ? false
, postFetch ? null
}@args:

# assert exactly one hash is set
assert hash != "" || sha256 != "";
# assert at most one hash is set
assert hash != "" -> sha256 == "";
assert sha256 != "" -> hash == "";

import <nix/fetchurl.nix> {
inherit system hash sha256 name;
if postFetch==null
then import <nix/fetchurl.nix> {
inherit system hash sha256 name __impure;

url =
# Handle mirror:// URIs. Since <nix/fetchurl.nix> currently
Expand All @@ -23,3 +28,21 @@ import <nix/fetchurl.nix> {
if m == null then url
else builtins.head (mirrors.${builtins.elemAt m 0}) + (builtins.elemAt m 1);
}
else stdenv.mkDerivation {
inherit name;
srcs = [ ];
unpackPhase = ''
runHook preUnpack
cp '${fetchurl (args // { postFetch=null; hash=""; sha256=""; __impure=true; })}' $out
This conversation was marked as resolved.
Show resolved Hide resolved
chmod +w $out
runHook postUnpack
'';
installPhase = ''
runHook preInstall
'' + postFetch + ''
runHook postInstall
'';
outputHash = if hash != "" then hash else sha256;
outputHashAlgo = if hash != "" then "" else "sha256";
outputHashMode = "flat";
}
20 changes: 18 additions & 2 deletions pkgs/development/tools/misc/binutils/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ in
, buildPackages
, fetchFromGitHub
, fetchurl
, fetchpatch
, flex
, gettext
, lib
Expand Down Expand Up @@ -68,11 +69,26 @@ stdenv.mkDerivation {
# Make binutils output deterministic by default.
./deterministic.patch


# Breaks nm BSD flag detection, heeds an upstream fix:
# https://sourceware.org/PR29547
./0001-Revert-libtool.m4-fix-the-NM-nm-over-here-B-option-w.patch
./0001-Revert-libtool.m4-fix-nm-BSD-flag-detection.patch

# If the following patch is ever dropped, please ensure that at
# least one other patch in binutils uses `fetchpatch`, and move
# this comment to that patch. Having a `fetchpatch` in binutils
# serves as a regression test to ensure that there are no
# dependency cycles preventing it from being used in even the
# earliest stages of stdenv bootstrapping.
This conversation was marked as resolved.
Show resolved Hide resolved
(fetchpatch {
# Breaks nm BSD flag detection
name = "0001-Revert-libtool.m4-fix-nm-BSD-flag-detection.patch";
url = "https://sourceware.org/git/?p=binutils-gdb.git;a=patch;h=bef9ef8ca0f941d743c77cc55b5fe7985990b2a7";
revert = true;
excludes = [ "ChangeLog" ];
#hash = "sha256-VQyyPmY1P9NT7PYwu0vqocWmQGSyt45tADe6ecTc8fk=";
This conversation was marked as resolved.
Show resolved Hide resolved
hash = "sha256-FcTkFK9FfbgDR6iS+H6w7KRpPo/mFJ+0u7v5EvIlecQ=";
})
#./0001-Revert-libtool.m4-fix-nm-BSD-flag-detection.patch
This conversation was marked as resolved.
Show resolved Hide resolved

# Required for newer macos versions
./0001-libtool.m4-update-macos-version-detection-block.patch
Expand Down
14 changes: 14 additions & 0 deletions pkgs/stdenv/darwin/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -186,6 +186,8 @@ rec {

fetchurlBoot = import ../../build-support/fetchurl {
inherit lib;
inherit (prevStage) stdenv;
fetchurl = thisStdenv.fetchurlBoot;
stdenvNoCC = stage0.stdenv;
curl = bootstrapTools;
};
Expand All @@ -208,6 +210,18 @@ rec {

stage0 = stageFun 0 null {
overrides = self: super: with stage0; {

fetchpatch = import ../../build-support/fetchpatch/default.nix {
inherit lib;
buildPackages.patchutils_0_3_3 = prevStage.patchutils_0_3_3.override {
forStdenvBootstrap = true;
# the parts of patchutils used by fetchpatch do not
# require perl, so we could eliminate this by patching
# patchutils' build scripts...
perl = bootstrapTools;
};
};

coreutils = stdenv.mkDerivation {
name = "bootstrap-stage0-coreutils";
buildCommand = ''
Expand Down
13 changes: 13 additions & 0 deletions pkgs/stdenv/linux/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,8 @@ let

fetchurlBoot = import ../../build-support/fetchurl/boot.nix {
inherit system;
inherit (prevStage) stdenv;
fetchurl = thisStdenv.fetchurlBoot;
};

cc = if prevStage.gcc-unwrapped == null
Expand Down Expand Up @@ -188,6 +190,17 @@ in
};
coreutils = bootstrapTools;
gnugrep = bootstrapTools;

fetchpatch = import ../../build-support/fetchpatch/default.nix {
inherit lib;
buildPackages.patchutils_0_3_3 = prevStage.patchutils_0_3_3.override {
forStdenvBootstrap = true;
# the parts of patchutils used by fetchpatch do not
# require perl, so we could eliminate this by patching
# patchutils' build scripts...
perl = bootstrapTools;
Comment on lines +198 to +201
Copy link
Member

Choose a reason for hiding this comment

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

I am not sure if bootstrapTools contains anything related to perl. If not then I think it would be cleaner to exclude it like makeWrapper.

Copy link
Author

Choose a reason for hiding this comment

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

The bootstrapTools contain a copy of perl. Mainly because autoconf/automake need it.

I would love to eliminate perl from the bootstrapTools. I tried a while back and while it is probably possible it is a very major undertaking. If it ever were eliminated we could (as my comment explains) apply a small patch to patchutils to drop all the parts of it that need perl (fetchpatch doesn't use those parts).

};
};
};
})

Expand Down
5 changes: 3 additions & 2 deletions pkgs/tools/text/patchutils/generic.nix
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
{ lib, stdenv, fetchurl, perl, makeWrapper
, version, sha256, patches ? [], extraBuildInputs ? []
, forStdenvBootstrap ? false
, ...
}:
stdenv.mkDerivation rec {
Expand All @@ -11,14 +12,14 @@ stdenv.mkDerivation rec {
inherit sha256;
};

nativeBuildInputs = [ makeWrapper ];
nativeBuildInputs = lib.optionals (!forStdenvBootstrap) [ makeWrapper ];
buildInputs = [ perl ] ++ extraBuildInputs;
hardeningDisable = [ "format" ];

# tests fail when building in parallel
enableParallelBuilding = false;

postInstall = ''
postInstall = lib.optionalString (!forStdenvBootstrap) ''
for bin in $out/bin/{splitdiff,rediff,editdiff,dehtmldiff}; do
wrapProgram "$bin" \
--prefix PATH : "$out/bin"
Expand Down