Clone of https://github.com/NixOS/nixpkgs.git (to stress-test knotserver)
1{ lib, stdenv, fetchurl 2# TODO: links -lsigsegv but loses the reference for some reason 3, withSigsegv ? (false && stdenv.hostPlatform.system != "x86_64-cygwin"), libsigsegv 4, interactive ? false, readline 5, autoreconfHook # no-pma fix 6 7/* Test suite broke on: 8 stdenv.isCygwin # XXX: `test-dup2' segfaults on Cygwin 6.1 9 || stdenv.isDarwin # XXX: `locale' segfaults 10 || stdenv.isSunOS # XXX: `_backsmalls1' fails, locale stuff? 11 || stdenv.isFreeBSD 12*/ 13, doCheck ? (interactive && stdenv.isLinux), glibcLocales ? null 14, locale ? null 15}: 16 17assert (doCheck && stdenv.isLinux) -> glibcLocales != null; 18 19stdenv.mkDerivation rec { 20 pname = "gawk" + lib.optionalString interactive "-interactive"; 21 version = "5.2.1"; 22 23 src = fetchurl { 24 url = "mirror://gnu/gawk/gawk-${version}.tar.xz"; 25 hash = "sha256-ZzVTuR+eGMxXku1RB1341RDJBA9VCm904Jya3SQ6fk8="; 26 }; 27 28 patches = [ 29 # Pull upstream fix for aarch64-darwin where pma does not work. 30 # Can be removed after next gawk release. 31 ./darwin-no-pma.patch 32 ]; 33 34 # PIE is incompatible with the "persistent malloc" ("pma") feature. 35 # While build system attempts to pass -no-pie to gcc. nixpkgs' `ld` 36 # wrapped still passes `-pie` flag to linker and breaks linkage. 37 # Let's disable "pie" until `ld` is fixed to do the right thing. 38 hardeningDisable = [ "pie" ]; 39 40 # When we do build separate interactive version, it makes sense to always include man. 41 outputs = [ "out" "info" ] 42 ++ lib.optional (!interactive) "man"; 43 44 # no-pma fix 45 nativeBuildInputs = [ autoreconfHook ] 46 ++ lib.optional (doCheck && stdenv.isLinux) glibcLocales; 47 48 buildInputs = lib.optional withSigsegv libsigsegv 49 ++ lib.optional interactive readline 50 ++ lib.optional stdenv.isDarwin locale; 51 52 configureFlags = [ 53 (if withSigsegv then "--with-libsigsegv-prefix=${libsigsegv}" else "--without-libsigsegv") 54 (if interactive then "--with-readline=${readline.dev}" else "--without-readline") 55 ]; 56 57 makeFlags = [ 58 "AR=${stdenv.cc.targetPrefix}ar" 59 ]; 60 61 inherit doCheck; 62 63 postInstall = '' 64 rm "$out"/bin/gawk-* 65 ln -s gawk.1 "''${!outputMan}"/share/man/man1/awk.1 66 ''; 67 68 passthru = { 69 libsigsegv = if withSigsegv then libsigsegv else null; # for stdenv bootstrap 70 }; 71 72 meta = with lib; { 73 homepage = "https://www.gnu.org/software/gawk/"; 74 description = "GNU implementation of the Awk programming language"; 75 longDescription = '' 76 Many computer users need to manipulate text files: extract and then 77 operate on data from parts of certain lines while discarding the rest, 78 make changes in various text files wherever certain patterns appear, 79 and so on. To write a program to do these things in a language such as 80 C or Pascal is a time-consuming inconvenience that may take many lines 81 of code. The job is easy with awk, especially the GNU implementation: 82 Gawk. 83 84 The awk utility interprets a special-purpose programming language that 85 makes it possible to handle many data-reformatting jobs with just a few 86 lines of code. 87 ''; 88 license = licenses.gpl3Plus; 89 platforms = platforms.unix ++ platforms.windows; 90 maintainers = [ ]; 91 }; 92}