about summary refs log tree commit diff
path: root/nixpkgs/pkgs/development/libraries/gnu-config/default.nix
blob: 0315f39c6059261b2a5c79a4f0bb0e1326be1832 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
{ lib, stdenv, fetchurl }:

# Note: this package is used for bootstrapping fetchurl, and thus
# cannot use fetchpatch! All mutable patches (generated by GitHub or
# cgit) that are needed here should be included directly in Nixpkgs as
# files.

let
  rev = "28ea239c53a2d5d8800c472bc2452eaa16e37af2";

  # Don't use fetchgit as this is needed during Aarch64 bootstrapping
  configGuess = fetchurl {
    name = "config.guess-${builtins.substring 0 7 rev}";
    url = "https://git.savannah.gnu.org/cgit/config.git/plain/config.guess?id=${rev}";
    hash = "sha256-7CV3YUJSMm+InfHel7mkV8A6mpSBEEhWPCEaRElti6M=";
  };
  configSub = fetchurl {
    name = "config.sub-${builtins.substring 0 7 rev}";
    url = "https://git.savannah.gnu.org/cgit/config.git/plain/config.sub?id=${rev}";
    hash = "sha256-Rlxf5nx9NrcugIgScWRF1NONS5RzTKjTaoY50SMjh4s=";
  };
in stdenv.mkDerivation {
  pname = "gnu-config";
  version = "2023-09-19";

  unpackPhase = ''
    runHook preUnpack
    cp ${configGuess} ./config.guess
    cp ${configSub} ./config.sub
    chmod +w ./config.sub ./config.guess
    runHook postUnpack
  '';

  # If this isn't set, `pkgs.gnu-config.overrideAttrs( _: { patches
  # = ...; })` will behave very counterintuitively: the (unpatched)
  # gnu-config from the updateAutotoolsGnuConfigScriptsHook stdenv's
  # defaultNativeBuildInputs will "update" the patched gnu-config by
  # reverting the patch!
  dontUpdateAutotoolsGnuConfigScripts = true;

  dontConfigure = true;
  dontBuild = true;

  installPhase = ''
    runHook preInstall
    install -Dm755 ./config.guess $out/config.guess
    install -Dm755 ./config.sub $out/config.sub
    runHook postInstall
  '';

  meta = with lib; {
    description = "Attempt to guess a canonical system name";
    homepage = "https://savannah.gnu.org/projects/config";
    license = licenses.gpl3;
    # In addition to GPLv3:
    #   As a special exception to the GNU General Public License, if you
    #   distribute this file as part of a program that contains a
    #   configuration script generated by Autoconf, you may include it under
    #   the same distribution terms that you use for the rest of that
    #   program.
    maintainers = with maintainers; [ dezgeg emilytrau ];
    platforms = platforms.all;
  };
}