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 gawk,
12 gnutar,
13 gzip,
14}:
15let
16 pname = "bootstrap-coreutils-musl";
17 version = "9.4";
18
19 src = fetchurl {
20 url = "mirror://gnu/coreutils/coreutils-${version}.tar.gz";
21 hash = "sha256-X2ANkJOXOwr+JTk9m8GMRPIjJlf0yg2V6jHHAutmtzk=";
22 };
23
24 configureFlags = [
25 "--prefix=${placeholder "out"}"
26 "--build=${buildPlatform.config}"
27 "--host=${hostPlatform.config}"
28 # musl 1.1.x doesn't use 64bit time_t
29 "--disable-year2038"
30 # libstdbuf.so fails in static builds
31 "--enable-no-install-program=stdbuf"
32 ];
33in
34bash.runCommand "${pname}-${version}"
35 {
36 inherit pname version;
37
38 nativeBuildInputs = [
39 tinycc.compiler
40 gnumake
41 gnused
42 gnugrep
43 gawk
44 gnutar
45 gzip
46 ];
47
48 passthru.tests.get-version =
49 result:
50 bash.runCommand "${pname}-get-version-${version}" { } ''
51 ${result}/bin/cat --version
52 mkdir $out
53 '';
54
55 meta = with lib; {
56 description = "GNU Core Utilities";
57 homepage = "https://www.gnu.org/software/coreutils";
58 license = licenses.gpl3Plus;
59 teams = [ teams.minimal-bootstrap ];
60 platforms = platforms.unix;
61 };
62 }
63 ''
64 # Unpack
65 tar xzf ${src}
66 cd coreutils-${version}
67
68 # Configure
69 export CC="tcc -B ${tinycc.libs}/lib"
70 export LD=tcc
71 bash ./configure ${lib.concatStringsSep " " configureFlags}
72
73 # Build
74 make -j $NIX_BUILD_CORES AR="tcc -ar" MAKEINFO="true"
75
76 # Install
77 make -j $NIX_BUILD_CORES install MAKEINFO="true"
78 ''