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 gnugrep,
10 gnused,
11}:
12let
13 # gnutar with musl preserves modify times, allowing make to not try
14 # rebuilding pregenerated files
15 pname = "gnutar-musl";
16 version = "1.12";
17
18 src = fetchurl {
19 url = "mirror://gnu/tar/tar-${version}.tar.gz";
20 hash = "sha256-xsN+iIsTbM76uQPFEUn0t71lnWnUrqISRfYQU6V6pgo=";
21 };
22in
23bash.runCommand "${pname}-${version}"
24 {
25 inherit pname version;
26
27 nativeBuildInputs = [
28 tinycc.compiler
29 gnumake
30 gnused
31 gnugrep
32 ];
33
34 passthru.tests.get-version =
35 result:
36 bash.runCommand "${pname}-get-version-${version}" { } ''
37 ${result}/bin/tar --version
38 mkdir $out
39 '';
40
41 meta = with lib; {
42 description = "GNU implementation of the `tar' archiver";
43 homepage = "https://www.gnu.org/software/tar";
44 license = licenses.gpl3Plus;
45 teams = [ teams.minimal-bootstrap ];
46 mainProgram = "tar";
47 platforms = platforms.unix;
48 };
49 }
50 ''
51 # Unpack
52 ungz --file ${src} --output tar.tar
53 untar --file tar.tar
54 rm tar.tar
55 cd tar-${version}
56
57 # Configure
58 export CC="tcc -B ${tinycc.libs}/lib"
59 export LD=tcc
60 export ac_cv_sizeof_unsigned_long=4
61 export ac_cv_sizeof_long_long=8
62 export ac_cv_header_netdb_h=no
63 bash ./configure \
64 --prefix=$out \
65 --build=${buildPlatform.config} \
66 --host=${hostPlatform.config} \
67 --disable-nls
68
69 # Build
70 make AR="tcc -ar"
71
72 # Install
73 make install
74 ''