2024-07-27 06:49:29 +00:00
{ pkgs ? import ../../.. { } }:
let
2024-09-19 14:19:46 +00:00
inherit ( pkgs ) runCommand closureInfo ;
2024-07-27 06:49:29 +00:00
# splicing doesn't seem to work right here
2024-09-19 14:19:46 +00:00
inherit ( pkgs . buildPackages ) dumpnar rsync ;
2024-07-27 06:49:29 +00:00
pack-all =
packCmd : name : pkgs : fixups :
( runCommand name {
2024-09-19 14:19:46 +00:00
nativeBuildInputs = [ rsync dumpnar ] ;
2024-07-27 06:49:29 +00:00
} ''
base = $ PWD
2024-09-19 14:19:46 +00:00
requisites = " $ ( c a t ${ closureInfo { rootPaths = pkgs ; } } / s t o r e - p a t h s ) "
2024-07-27 06:49:29 +00:00
for f in $ requisites ; do
cd $ f
2024-09-19 14:19:46 +00:00
rsync - - safe-links - - chmod = " + w " - av . $ base
2024-07-27 06:49:29 +00:00
done
cd $ base
rm - rf nix nix-support
mkdir nix-support
for dir in $ requisites ; do
cd " $ d i r / n i x - s u p p o r t " 2 > /dev/null || continue
for f in $ ( find . - type f ) ; do
mkdir - p " $ b a s e / n i x - s u p p o r t / $ ( d i r n a m e $ f ) "
cat $ f > > " $ b a s e / n i x - s u p p o r t / $ f "
done
done
2024-09-19 14:19:46 +00:00
rm - f $ base/nix-support/propagated-build-inputs
2024-07-27 06:49:29 +00:00
cd $ base
$ { fixups }
$ { packCmd }
'' ) ;
2024-09-19 14:19:46 +00:00
nar-all = pack-all " d u m p n a r . | x z - 9 - e - T $ N I X _ B U I L D _ C O R E S > $ o u t " ;
2024-07-27 06:49:29 +00:00
tar-all = pack-all " X Z _ O P T = \" - 9 - e - T $ N I X _ B U I L D _ C O R E S \" t a r c J f $ o u t - - h a r d - d e r e f e r e n c e - - s o r t = n a m e - - n u m e r i c - o w n e r - - o w n e r = 0 - - g r o u p = 0 - - m t i m e = @ 1 . " ;
coreutils-big = pkgs . coreutils . override { singleBinary = false ; } ;
mkdir = runCommand " m k d i r " { coreutils = coreutils-big ; } ''
mkdir - p $ out/bin
cp $ coreutils/bin/mkdir $ out/bin
'' ;
in rec {
unpack = nar-all " u n p a c k . n a r . x z " ( with pkgs ; [ bash mkdir xz gnutar ] ) ''
rm - rf include lib /* . a l i b / i 1 8 n l i b / b a s h s h a r e
'' ;
bootstrap-tools = tar-all " b o o t s t r a p - t o o l s . t a r . x z " (
with pkgs ;
2024-07-31 10:19:44 +00:00
# SYNCME: this version number must be synced with the one in default.nix
let llvmPackages = llvmPackages_18 ; in
2024-07-27 06:49:29 +00:00
[
( runCommand " b s d c p " { } " m k d i r - p $ o u t / b i n ; c p ${ freebsd . cp } / b i n / c p $ o u t / b i n / b s d c p " )
coreutils
gnutar
findutils
gnumake
gnused
patchelf
gnugrep
gawk
diffutils
patch
bash
xz
xz . dev
gzip
bzip2
bzip2 . dev
curl
expand-response-params
binutils-unwrapped
freebsd . libc
llvmPackages . libcxx
llvmPackages . libcxx . dev
llvmPackages . compiler-rt
llvmPackages . compiler-rt . dev
llvmPackages . clang-unwrapped
( freebsd . locales . override { locales = [ " C . U T F - 8 " ] ; } )
]
# INSTRUCTIONS FOR GENERATING THE SPURIOUS LIST
# - empty this list
# - rebuild bootstrap files and update their urls and hashes
# - turn on atime on your FreeBSD nix store filesystem
# - run nix-collect-garbage on FreeBSD to make it so we rebuild FODs
# - build the nixpkgs __bootstrapArchive attribute on FreeBSD
# - reboot your FreeBSD system. Otherwise the atimes will simply be wrong because of kernel caching
# - run a full build of stdenv on FreeBSD. with -j3, this takes 1h40 on my 20 cpu VM (AMD host)
# - use the following to generate a list with access times and filenames
# find /nix/store/###-bootstrap-archive -type f | xargs stat | grep -E 'Access: 2|File:' | paste -d ' ' - - | awk '{ print $4 " " $5 " " $6 " " $2 }' | sort -n > atimes
# - manually identify the point where files have no longer been accessed after the patching phase
# - use your favorite text editor to snip out the time column, the /nix/store/###-bootstrap-archive/ prefix, and the files that have not been used during bootstrap
# - turn off atime if it was off before since it will degrade performance
# - manually remove bin/strings from the list, since it will be used only during bootstrap
# - manually remove all files under include and lib/clang/*/include from the list in order to improve forward compatibility (and since they are very small)
# - plop it here
) " x a r g s r m - f < ${ ./bootstrap-tools-spurious.txt } " ;
build = runCommand " b u i l d " { } ''
mkdir - p $ out/on-server
ln - s $ { unpack } $ out/on-server/unpack.nar.xz
ln - s $ { bootstrap-tools } $ out/on-server/bootstrap-tools.tar.xz
'' ;
}