1{ lib
2, buildPlatform
3, hostPlatform
4, fetchurl
5, bash
6, tinycc
7, gnumake
8, gnugrep
9, gnused
10, gnutar
11, gzip
12, bootGawk
13}:
14let
15 inherit (import ./common.nix { inherit lib; }) meta;
16 pname = "gawk";
17 version = "5.2.2";
18
19 src = fetchurl {
20 url = "mirror://gnu/gawk/gawk-${version}.tar.gz";
21 hash = "sha256-lFrvfM/xAfILIqEIArwAXplKsrjqPnJMwaGXxi9B9lA=";
22 };
23in
24bash.runCommand "${pname}-${version}" {
25 inherit pname version meta;
26
27 nativeBuildInputs = [
28 tinycc.compiler
29 gnumake
30 gnused
31 gnugrep
32 gnutar
33 gzip
34 bootGawk
35 ];
36
37 passthru.tests.get-version = result:
38 bash.runCommand "${pname}-get-version-${version}" {} ''
39 ${result}/bin/awk --version
40 mkdir $out
41 '';
42} ''
43 # Unpack
44 tar xzf ${src}
45 cd gawk-${version}
46
47 # Configure
48 export CC="tcc -B ${tinycc.libs}/lib"
49 export AR="tcc -ar"
50 export LD=tcc
51 bash ./configure \
52 --prefix=$out \
53 --build=${buildPlatform.config} \
54 --host=${hostPlatform.config}
55
56 # Build
57 make -j $NIX_BUILD_CORES
58
59 # Install
60 make -j $NIX_BUILD_CORES install
61''