nixpkgs mirror (for testing) github.com/NixOS/nixpkgs
nix
at devShellTools-shell 120 lines 3.8 kB view raw
1{ 2 lib, 3 fetchurl, 4 kaem, 5 tinycc, 6 gnumake, 7 gnupatch, 8}: 9let 10 pname = "bootstrap-coreutils"; 11 version = "5.0"; 12 13 src = fetchurl { 14 url = "mirror://gnu/coreutils/coreutils-${version}.tar.gz"; 15 sha256 = "10wq6k66i8adr4k08p0xmg87ff4ypiazvwzlmi7myib27xgffz62"; 16 }; 17 18 # Thanks to the live-bootstrap project! 19 # See https://github.com/fosslinux/live-bootstrap/blob/a8752029f60217a5c41c548b16f5cdd2a1a0e0db/sysa/coreutils-5.0/coreutils-5.0.kaem 20 liveBootstrap = "https://github.com/fosslinux/live-bootstrap/raw/a8752029f60217a5c41c548b16f5cdd2a1a0e0db/sysa/coreutils-5.0"; 21 22 makefile = fetchurl { 23 url = "${liveBootstrap}/mk/main.mk"; 24 sha256 = "0njg4xccxfqrslrmlb8ls7h6hlnfmdx42nvxwmca8flvczwrplfd"; 25 }; 26 27 patches = [ 28 # modechange.h uses functions defined in sys/stat.h, so we need to move it to 29 # after sys/stat.h include. 30 (fetchurl { 31 url = "${liveBootstrap}/patches/modechange.patch"; 32 sha256 = "04xa4a5w2syjs3xs6qhh8kdzqavxnrxpxwyhc3qqykpk699p3ms5"; 33 }) 34 # mbstate_t is a struct that is required. However, it is not defined by mes libc. 35 (fetchurl { 36 url = "${liveBootstrap}/patches/mbstate.patch"; 37 sha256 = "0rz3c0sflgxjv445xs87b83i7gmjpl2l78jzp6nm3khdbpcc53vy"; 38 }) 39 # strcoll() does not exist in mes libc, change it to strcmp. 40 (fetchurl { 41 url = "${liveBootstrap}/patches/ls-strcmp.patch"; 42 sha256 = "0lx8rz4sxq3bvncbbr6jf0kyn5bqwlfv9gxyafp0541dld6l55p6"; 43 }) 44 # getdate.c is pre-compiled from getdate.y 45 # At this point we don't have bison yet and in any case getdate.y does not 46 # compile when generated with modern bison. 47 (fetchurl { 48 url = "${liveBootstrap}/patches/touch-getdate.patch"; 49 sha256 = "1xd3z57lvkj7r8vs5n0hb9cxzlyp58pji7d335snajbxzwy144ma"; 50 }) 51 # touch: add -h to change symlink timestamps, where supported 52 (fetchurl { 53 url = "${liveBootstrap}/patches/touch-dereference.patch"; 54 sha256 = "0wky5r3k028xwyf6g6ycwqxzc7cscgmbymncjg948vv4qxsxlfda"; 55 }) 56 # strcoll() does not exist in mes libc, change it to strcmp. 57 (fetchurl { 58 url = "${liveBootstrap}/patches/expr-strcmp.patch"; 59 sha256 = "19f31lfsm1iwqzvp2fyv97lmqg4730prfygz9zip58651jf739a9"; 60 }) 61 # strcoll() does not exist in mes libc, change it to strcmp. 62 # hard_LC_COLLATE is used but not declared when HAVE_SETLOCALE is unset. 63 (fetchurl { 64 url = "${liveBootstrap}/patches/sort-locale.patch"; 65 sha256 = "0bdch18mpyyxyl6gyqfs0wb4pap9flr11izqdyxccx1hhz0a2i6c"; 66 }) 67 # don't assume fopen cannot return stdin or stdout. 68 (fetchurl { 69 url = "${liveBootstrap}/patches/uniq-fopen.patch"; 70 sha256 = "0qs6shyxl9j4h34v5j5sgpxrr4gjfljd2hxzw416ghwc3xzv63fp"; 71 }) 72 ]; 73in 74kaem.runCommand "${pname}-${version}" 75 { 76 inherit pname version; 77 78 nativeBuildInputs = [ 79 tinycc.compiler 80 gnumake 81 gnupatch 82 ]; 83 84 meta = with lib; { 85 description = "GNU Core Utilities"; 86 homepage = "https://www.gnu.org/software/coreutils"; 87 license = licenses.gpl3Plus; 88 teams = [ teams.minimal-bootstrap ]; 89 platforms = platforms.unix; 90 }; 91 } 92 '' 93 # Unpack 94 ungz --file ${src} --output coreutils.tar 95 untar --file coreutils.tar 96 rm coreutils.tar 97 cd coreutils-${version} 98 99 # Patch 100 ${lib.concatMapStringsSep "\n" (f: "patch -Np0 -i ${f}") patches} 101 102 # Configure 103 catm config.h 104 cp lib/fnmatch_.h lib/fnmatch.h 105 cp lib/ftw_.h lib/ftw.h 106 cp lib/search_.h lib/search.h 107 rm src/dircolors.h 108 109 # Build 110 make -f ${makefile} \ 111 CC="tcc -B ${tinycc.libs}/lib" \ 112 PREFIX=''${out} 113 114 # Check 115 ./src/echo "Hello coreutils!" 116 117 # Install 118 ./src/mkdir -p ''${out}/bin 119 make -f ${makefile} install PREFIX=''${out} 120 ''