1 { lib, stdenv, fetchurl
4 # TODO: links -lsigsegv but loses the reference for some reason
5 , withSigsegv ? (false && stdenv.hostPlatform.system != "x86_64-cygwin"), libsigsegv
6 , interactive ? false, readline
7 , autoreconfHook # no-pma fix
9 /* Test suite broke on:
10 stdenv.hostPlatform.isCygwin # XXX: `test-dup2' segfaults on Cygwin 6.1
11 || stdenv.hostPlatform.isDarwin # XXX: `locale' segfaults
12 || stdenv.hostPlatform.isSunOS # XXX: `_backsmalls1' fails, locale stuff?
13 || stdenv.hostPlatform.isFreeBSD
15 , doCheck ? (interactive && stdenv.hostPlatform.isLinux), glibcLocales ? null
19 assert (doCheck && stdenv.hostPlatform.isLinux) -> glibcLocales != null;
21 stdenv.mkDerivation rec {
22 pname = "gawk" + lib.optionalString interactive "-interactive";
26 url = "mirror://gnu/gawk/gawk-${version}.tar.xz";
27 hash = "sha256-PB/OFEa0y+4c0nO9fsZLyH2J9hU3RxzT4F4zqWWiUOk=";
30 # PIE is incompatible with the "persistent malloc" ("pma") feature.
31 # While build system attempts to pass -no-pie to gcc. nixpkgs' `ld`
32 # wrapped still passes `-pie` flag to linker and breaks linkage.
33 # Let's disable "pie" until `ld` is fixed to do the right thing.
34 hardeningDisable = [ "pie" ];
36 # When we do build separate interactive version, it makes sense to always include man.
37 outputs = [ "out" "info" ]
38 ++ lib.optional (!interactive) "man";
45 ] ++ lib.optionals interactive [
47 ] ++ lib.optionals (doCheck && stdenv.hostPlatform.isLinux) [
51 buildInputs = lib.optionals interactive [
54 ] ++ lib.optionals withSigsegv [
56 ] ++ lib.optionals stdenv.hostPlatform.isDarwin [
61 (if withSigsegv then "--with-libsigsegv-prefix=${libsigsegv}" else "--without-libsigsegv")
62 (if interactive then "--with-readline=${readline.dev}" else "--without-readline")
66 "AR=${stdenv.cc.targetPrefix}ar"
71 postInstall = (if interactive then ''
72 remove-references-to -t "$NIX_CC" "$out"/bin/gawkbug
73 patchShebangs --host "$out"/bin/gawkbug
78 ln -s gawk.1 "''${!outputMan}"/share/man/man1/awk.1
82 libsigsegv = if withSigsegv then libsigsegv else null; # for stdenv bootstrap
86 homepage = "https://www.gnu.org/software/gawk/";
87 description = "GNU implementation of the Awk programming language";
89 Many computer users need to manipulate text files: extract and then
90 operate on data from parts of certain lines while discarding the rest,
91 make changes in various text files wherever certain patterns appear,
92 and so on. To write a program to do these things in a language such as
93 C or Pascal is a time-consuming inconvenience that may take many lines
94 of code. The job is easy with awk, especially the GNU implementation:
97 The awk utility interprets a special-purpose programming language that
98 makes it possible to handle many data-reformatting jobs with just a few
101 license = licenses.gpl3Plus;
102 platforms = platforms.unix ++ platforms.windows;
104 mainProgram = "gawk";