From a85c73e8a708776c72ae69161f1e81781933535c Mon Sep 17 00:00:00 2001 From: Jonathan Ringer Date: Tue, 10 Mar 2026 07:09:09 -0700 Subject: [PATCH] libtool: adopt mkManyVersions --- pkgs-many/libtool/default.nix | 9 ++++ .../libtool/generic.nix | 54 +++++++++++++------ pkgs-many/libtool/variants.nix | 11 ++++ pkgs/libtool/default.nix | 42 --------------- stdenv/aliases.nix | 2 + top-level.nix | 5 -- 6 files changed, 59 insertions(+), 64 deletions(-) create mode 100644 pkgs-many/libtool/default.nix rename pkgs/libtool/libtool2.nix => pkgs-many/libtool/generic.nix (72%) create mode 100644 pkgs-many/libtool/variants.nix delete mode 100644 pkgs/libtool/default.nix diff --git a/pkgs-many/libtool/default.nix b/pkgs-many/libtool/default.nix new file mode 100644 index 00000000..34986d07 --- /dev/null +++ b/pkgs-many/libtool/default.nix @@ -0,0 +1,9 @@ +{ mkManyVariants, callPackage }: + +mkManyVariants { + variants = ./variants.nix; + aliases = { }; + defaultSelector = (p: p.v2_5); + genericBuilder = ./generic.nix; + inherit callPackage; +} diff --git a/pkgs/libtool/libtool2.nix b/pkgs-many/libtool/generic.nix similarity index 72% rename from pkgs/libtool/libtool2.nix rename to pkgs-many/libtool/generic.nix index 2e844018..8ce62bc4 100644 --- a/pkgs/libtool/libtool2.nix +++ b/pkgs-many/libtool/generic.nix @@ -1,25 +1,37 @@ +{ + version, + src-hash, + packageOlder, + packageAtLeast, + ... +}@variantArgs: + { lib, stdenv, fetchurl, m4, + perl, runtimeShell, updateAutotoolsGnuConfigScriptsHook, file, -}: + + # tests + readline, +}@args: # 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. -stdenv.mkDerivation rec { +stdenv.mkDerivation (finalAttrs: { pname = "libtool"; - version = "2.5.4"; + inherit version; src = fetchurl { - url = "mirror://gnu/libtool/${pname}-${version}.tar.gz"; - sha256 = "sha256-2o67LOTc9GuQCY2vliz/po9LT2LqYPeY0O8Skp7eat8="; + url = "mirror://gnu/libtool/libtool-${version}.tar.gz"; + hash = src-hash; }; outputs = [ @@ -29,9 +41,9 @@ stdenv.mkDerivation rec { # FILECMD was added in libtool 2.4.7; previous versions hardwired `/usr/bin/file` # https://lists.gnu.org/archive/html/autotools-announce/2022-03/msg00000.html - FILECMD = "${file}/bin/file"; + FILECMD = lib.optionalString (packageAtLeast "2") "${file}/bin/file"; - postPatch = + postPatch = lib.optionalString (packageAtLeast "2") ( # libtool commit da2e352735722917bf0786284411262195a6a3f6 changed # the shebang from `/bin/sh` (which is a special sandbox exception) # to `/usr/bin/env sh`, meaning that we now need to patch shebangs @@ -40,18 +52,24 @@ stdenv.mkDerivation rec { substituteInPlace libtoolize.in --replace '#! /usr/bin/env sh' '#!${runtimeShell}' # avoid help2man run after 'libtoolize.in' update touch doc/libtoolize.1 - ''; + ''); strictDeps = true; + # As libtool is an early bootstrap dependency try hard not to # add autoconf and automake or help2man dependencies here. That way we can # avoid pulling in perl and get away with just an `m4` depend. - nativeBuildInputs = [ - updateAutotoolsGnuConfigScriptsHook - m4 - file - ]; - propagatedBuildInputs = [ + nativeBuildInputs = + lib.optionals (packageAtLeast "2") [ + updateAutotoolsGnuConfigScriptsHook + m4 + file + ] + ++ lib.optionals (packageOlder "2") [ m4 ]; + + buildInputs = lib.optionals (packageOlder "2") [ perl ]; + + propagatedBuildInputs = lib.optionals (packageAtLeast "2") [ m4 file ]; @@ -61,15 +79,17 @@ stdenv.mkDerivation rec { dontPatchShebangs = true; dontFixLibtool = true; + enableParallelBuilding = true; + # XXX: The GNU ld wrapper does all sorts of nasty things wrt. RPATH, which # leads to the failure of a number of tests. doCheck = false; doInstallCheck = false; - enableParallelBuilding = true; + passthru.tests = { inherit readline; }; meta = { - description = "GNU Libtool, a generic library support script"; + description = "Generic library support script"; longDescription = '' GNU libtool is a generic library support script. Libtool hides the complexity of using shared libraries behind a consistent, @@ -84,4 +104,4 @@ stdenv.mkDerivation rec { platforms = lib.platforms.unix; mainProgram = "libtool"; }; -} +}) diff --git a/pkgs-many/libtool/variants.nix b/pkgs-many/libtool/variants.nix new file mode 100644 index 00000000..0ecf1b34 --- /dev/null +++ b/pkgs-many/libtool/variants.nix @@ -0,0 +1,11 @@ +{ + v1_5 = { + version = "1.5.26"; + src-hash = "sha256-HDWuNP6FqhZ716tLyfR3/gGROOGvYmeNlS/EPAt+Lwk="; + }; + + v2_5 = { + version = "2.5.4"; + src-hash = "sha256-2o67LOTc9GuQCY2vliz/po9LT2LqYPeY0O8Skp7eat8="; + }; +} diff --git a/pkgs/libtool/default.nix b/pkgs/libtool/default.nix deleted file mode 100644 index 26708881..00000000 --- a/pkgs/libtool/default.nix +++ /dev/null @@ -1,42 +0,0 @@ -{ - lib, - stdenv, - fetchurl, - m4, - perl, -}: - -stdenv.mkDerivation rec { - pname = "libtool"; - version = "1.5.26"; - - src = fetchurl { - url = "mirror://gnu/${pname}/${pname}-${version}.tar.gz"; - sha256 = "029ggq5kri1gjn6nfqmgw4w920gyfzscjjxbsxxidal5zqsawd8w"; - }; - - nativeBuildInputs = [ m4 ]; - buildInputs = [ perl ]; - - # Don't fixup "#! /bin/sh" in Libtool, otherwise it will use the - # "fixed" path in generated files! - dontPatchShebangs = true; - dontFixLibtool = true; - - meta = { - description = "Generic library support script"; - longDescription = '' - GNU libtool is a generic library support script. Libtool hides - the complexity of using shared libraries behind a consistent, - portable interface. - - To use libtool, add the new generic library building commands to - your Makefile, Makefile.in, or Makefile.am. See the - documentation for details. - ''; - homepage = "https://www.gnu.org/software/libtool/"; - license = lib.licenses.gpl2Plus; - platforms = lib.platforms.unix; - mainProgram = "libtool"; - }; -} diff --git a/stdenv/aliases.nix b/stdenv/aliases.nix index 39e0a215..6ec9e117 100644 --- a/stdenv/aliases.nix +++ b/stdenv/aliases.nix @@ -43,6 +43,8 @@ mapAliases { guile_2_0 = guile.v2_0; guile_2_2 = guile.v2_2; guile_3_0 = guile.v3_0; + libtool2 = libtool.v2_5; + libtool_1_5 = libtool.v1_5; ncurses5 = ncurses.v5; ncurses6 = ncurses.v6; openssl_oqs = openssl.oqs; diff --git a/top-level.nix b/top-level.nix index d06c6af6..659b4b11 100644 --- a/top-level.nix +++ b/top-level.nix @@ -681,11 +681,6 @@ with final; # TODO: Remove alias libjpeg = libjpeg_turbo; - # TODO(corepkgs): gross - libtool = libtool2; - libtool2 = callPackage ./pkgs/libtool/libtool2.nix { }; - libtool_1_5 = callPackage ./pkgs/libtool { }; - # Less secure variant of lowdown for use inside Nix builds. lowdown-unsandboxed = lowdown.override { enableDarwinSandbox = false;