1{ lib, stdenv, fetchurl }:
2
3# Note: this package is used for bootstrapping fetchurl, and thus
4# cannot use fetchpatch! All mutable patches (generated by GitHub or
5# cgit) that are needed here should be included directly in Nixpkgs as
6# files.
7
8let
9 rev = "28ea239c53a2d5d8800c472bc2452eaa16e37af2";
10
11 # Don't use fetchgit as this is needed during Aarch64 bootstrapping
12 configGuess = fetchurl {
13 name = "config.guess-${builtins.substring 0 7 rev}";
14 url = "https://git.savannah.gnu.org/cgit/config.git/plain/config.guess?id=${rev}";
15 hash = "sha256-7CV3YUJSMm+InfHel7mkV8A6mpSBEEhWPCEaRElti6M=";
16 };
17 configSub = fetchurl {
18 name = "config.sub-${builtins.substring 0 7 rev}";
19 url = "https://git.savannah.gnu.org/cgit/config.git/plain/config.sub?id=${rev}";
20 hash = "sha256-Rlxf5nx9NrcugIgScWRF1NONS5RzTKjTaoY50SMjh4s=";
21 };
22in stdenv.mkDerivation {
23 pname = "gnu-config";
24 version = "2023-09-19";
25
26 unpackPhase = ''
27 runHook preUnpack
28 cp ${configGuess} ./config.guess
29 cp ${configSub} ./config.sub
30 chmod +w ./config.sub ./config.guess
31 runHook postUnpack
32 '';
33
34 # If this isn't set, `pkgs.gnu-config.overrideAttrs( _: { patches
35 # = ...; })` will behave very counterintuitively: the (unpatched)
36 # gnu-config from the updateAutotoolsGnuConfigScriptsHook stdenv's
37 # defaultNativeBuildInputs will "update" the patched gnu-config by
38 # reverting the patch!
39 dontUpdateAutotoolsGnuConfigScripts = true;
40
41 dontConfigure = true;
42 dontBuild = true;
43
44 installPhase = ''
45 runHook preInstall
46 install -Dm755 ./config.guess $out/config.guess
47 install -Dm755 ./config.sub $out/config.sub
48 runHook postInstall
49 '';
50
51 meta = with lib; {
52 description = "Attempt to guess a canonical system name";
53 homepage = "https://savannah.gnu.org/projects/config";
54 license = licenses.gpl3;
55 # In addition to GPLv3:
56 # As a special exception to the GNU General Public License, if you
57 # distribute this file as part of a program that contains a
58 # configuration script generated by Autoconf, you may include it under
59 # the same distribution terms that you use for the rest of that
60 # program.
61 maintainers = with maintainers; [ dezgeg emilytrau ];
62 platforms = platforms.all;
63 };
64}