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