nixpkgs mirror (for testing)
github.com/NixOS/nixpkgs
nix
1{
2 lib,
3 buildPlatform,
4 hostPlatform,
5 fetchurl,
6 bash,
7 tinycc,
8 gnumake,
9 gnupatch,
10 gnused,
11 gnugrep,
12}:
13let
14 inherit (import ./common.nix { inherit lib; }) meta;
15 pname = "gawk-mes";
16 # >=3.1.x is incompatible with mes-libc
17 version = "3.0.6";
18
19 src = fetchurl {
20 url = "mirror://gnu/gawk/gawk-${version}.tar.gz";
21 sha256 = "1z4bibjm7ldvjwq3hmyifyb429rs2d9bdwkvs0r171vv1khpdwmb";
22 };
23
24 patches = [
25 # for reproducibility don't generate date stamp
26 ./no-stamp.patch
27 ];
28in
29bash.runCommand "${pname}-${version}"
30 {
31 inherit pname version meta;
32
33 nativeBuildInputs = [
34 tinycc.compiler
35 gnumake
36 gnupatch
37 gnused
38 gnugrep
39 ];
40
41 passthru.tests.get-version =
42 result:
43 bash.runCommand "${pname}-get-version-${version}" { } ''
44 ${result}/bin/awk --version
45 mkdir $out
46 '';
47 }
48 ''
49 # Unpack
50 ungz --file ${src} --output gawk.tar
51 untar --file gawk.tar
52 rm gawk.tar
53 cd gawk-${version}
54
55 # Patch
56 ${lib.concatMapStringsSep "\n" (f: "patch -Np0 -i ${f}") patches}
57
58 # Configure
59 export CC="tcc -B ${tinycc.libs}/lib"
60 export ac_cv_func_getpgrp_void=yes
61 export ac_cv_func_tzset=yes
62 bash ./configure \
63 --build=${buildPlatform.config} \
64 --host=${hostPlatform.config} \
65 --disable-nls \
66 --prefix=$out
67
68 # Build
69 make gawk
70
71 # Install
72 install -D gawk $out/bin/gawk
73 ln -s gawk $out/bin/awk
74 ''