# SPDX-FileCopyrightText: 2025 OrIdow6 # SPDX-License-Identifier: GPL-3.0-or-later { basex, autoconf-archive, autoreconfHook, c-ares, coreutils, fetchFromGitHub, fetchurl, flex, gettext, gnulib, gnutls, gperf, lib, libiconv, libidn2, libintl, libpsl, libuuid, lua51Packages, lzip, makeBinaryWrapper, nukeReferences, pcre2, perlPackages, pkg-config, stdenv, texinfo, writeText, zlib, zstd, brotli, }: let luaEnv = lua51Packages.lua.withPackages ( ps: with ps; [ luasocket luafilesystem luasec luazip #crc32 #md5 #base64 cjson # luautf8 is a newer version of utf8; # the canonical DF uses the latter # so I assemble it manually here, # but I import the former anyway # -- OrIdow6 (buildLuarocksPackage { pname = "utf8"; version = "0.2.0-1"; knownRockspec = (fetchurl { url = "mirror://luarocks/utf8-1.3-0.rockspec"; sha256 = "sha256-V4otUR+uDIHTIBgfdgmdgMG4Y3knZ+w5ztv7EhbP+us="; }).outPath; src = fetchFromGitHub { owner = "dannote"; repo = "luautf8"; rev = "f36cc914ae9015cd3045987abadd83bbcfae98f0"; sha256 = "sha256-xLWqglAzqcxY+R8GOC+D3uzL2+9ZriEx8Kj41LkI5vU="; }; disabled = luaOlder "5.1"; meta = { homepage = "https://github.com/dannote/luautf8"; description = "A UTF-8 support module for Lua"; license = lib.licenses.mit; }; }) luautf8 luabitop bit32 luaossl zlib basex ] ); in stdenv.mkDerivation { pname = "wget-at"; version = "1.21.3-at.20260319.01"; src = fetchFromGitHub { owner = "archiveteam"; repo = "wget-lua"; rev = "e8cfe0a4ddb8a152971e5d0e22dc3f15f0080109"; hash = "sha256-zE8hA8RI9q2JBDvzIYWP56uNV7rXwvTOCggdh7I+5Fg="; }; preConfigure = '' patchShebangs doc ''; nativeBuildInputs = [ gettext pkg-config perlPackages.perl lzip nukeReferences autoreconfHook autoconf-archive flex gperf texinfo makeBinaryWrapper ]; buildInputs = [ libidn2 zlib pcre2 libuuid libiconv libintl luaEnv c-ares zstd brotli gnutls libpsl gnulib ]; # Taken from the wget2.nix in nixpkgs autoreconfPhase = '' # copy gnulib into build dir and make writable. # Otherwise ./bootstrap copies the non-writable files from nix store and fails to modify them rmdir gnulib cp -r ${gnulib} gnulib chmod -R u+w gnulib/{build-aux,lib} ./bootstrap --no-git --gnulib-srcdir=gnulib --skip-po ''; strictDeps = true; configureFlags = [ "--with-cares" ]; preBuild = '' # avoid runtime references to build-only depends make -C src version.c nuke-refs src/version.c ''; patches = [ (writeText "lua-search-for-cmake-package.patch" '' diff --git a/configure.ac b/configure.ac index 8e0a8a9b..63dd1d22 100644 --- a/configure.ac +++ b/configure.ac @@ -1053,6 +1053,11 @@ AS_IF( AS_IF( [test "X$enable_luajit" != "Xyes"], + [PKG_CHECK_MODULES([LUA], lua5.1, [ + CFLAGS="$LUA_CFLAGS $CFLAGS" + LIBS="$LUA_LIBS $LIBS" + AC_DEFINE([ENABLE_LUA], 1, [Define if Lua is available.]) + ], [ AC_CHECK_HEADER( lua5.1/lua.h, @@ -1072,6 +1077,8 @@ AS_IF( AC_MSG_ERROR([lua not found]) ) ] + ) + ] ) AS_IF( '') # I cannot figure out why it tries to "make" something in this directory *after* the main wget binary is built, which then crashes for reasons I also don't understand. So just ignoring it for now. This also happens if I try to run the vanilla wget build here from Git instead of from the release tarball. (writeText "do-not-make-gnulib-po.patch" '' diff --git a/Makefile.am b/Makefile.am index 5e3f1d18..d9f64bd4 100644 --- a/Makefile.am +++ b/Makefile.am @@ -40,7 +40,7 @@ distuninstallcheck_listfiles = find . -type f | \ ACLOCAL_AMFLAGS = -I m4 # subdirectories in the distribution -SUBDIRS = lib src doc po gnulib_po util fuzz tests testenv +SUBDIRS = lib src doc po util fuzz tests testenv EXTRA_DIST = MAILING-LIST \ msdos/config.h msdos/Makefile.DJ \ '') ]; postInstall = '' wrapProgram $out/bin/wget \ --prefix LUA_CPATH ';' "${luaEnv}/lib/lua/${luaEnv.luaversion}/?.so" \ --prefix LUA_PATH ';' "${luaEnv}/share/lua/${luaEnv.luaversion}/?.lua" \ --prefix PATH ':' ${lib.makeBinPath [ coreutils ]} # For sleep, but bring in the other programs too in case something uses them ''; enableParallelBuilding = true; meta = { description = "Tool for retrieving files using HTTP, HTTPS, and FTP AT version"; homepage = "https://www.gnu.org/software/wget/"; license = lib.licenses.gpl3Plus; mainProgram = "wget"; platforms = lib.platforms.all; }; }