nixpkgs mirror (for testing)
github.com/NixOS/nixpkgs
nix
1{
2 pkgs ? import ../../.. { },
3}:
4let
5 inherit (pkgs) runCommand closureInfo;
6 # splicing doesn't seem to work right here
7 inherit (pkgs.buildPackages) dumpnar rsync;
8 pack-all =
9 packCmd: name: pkgs: fixups:
10 (runCommand name
11 {
12 nativeBuildInputs = [
13 rsync
14 dumpnar
15 ];
16 }
17 ''
18 base=$PWD
19 requisites="$(cat ${closureInfo { rootPaths = pkgs; }}/store-paths)"
20 for f in $requisites; do
21 cd $f
22 rsync --safe-links --chmod="+w" -av . $base
23 done
24 cd $base
25
26 rm -rf nix nix-support
27 mkdir nix-support
28 for dir in $requisites; do
29 cd "$dir/nix-support" 2>/dev/null || continue
30 for f in $(find . -type f); do
31 mkdir -p "$base/nix-support/$(dirname $f)"
32 cat $f >>"$base/nix-support/$f"
33 done
34 done
35 rm -f $base/nix-support/propagated-build-inputs
36 cd $base
37
38 ${fixups}
39
40 ${packCmd}
41 ''
42 );
43 nar-all = pack-all "dumpnar . | xz -9 -e -T $NIX_BUILD_CORES >$out";
44 tar-all = pack-all "XZ_OPT=\"-9 -e -T $NIX_BUILD_CORES\" tar cJf $out --hard-dereference --sort=name --numeric-owner --owner=0 --group=0 --mtime=@1 .";
45 coreutils-big = pkgs.coreutils.override { singleBinary = false; };
46 mkdir = runCommand "mkdir" { coreutils = coreutils-big; } ''
47 mkdir -p $out/bin
48 cp $coreutils/bin/mkdir $out/bin
49 '';
50in
51rec {
52 unpack =
53 nar-all "unpack.nar.xz"
54 (with pkgs; [
55 bash
56 mkdir
57 xz
58 gnutar
59 ])
60 ''
61 rm -rf include lib/*.a lib/i18n lib/bash share
62 '';
63 bootstrap-tools = tar-all "bootstrap-tools.tar.xz" (
64 with pkgs;
65 # SYNCME: this version number must be synced with the one in default.nix
66 let
67 llvmPackages = llvmPackages_18;
68 in
69 [
70 (runCommand "bsdcp" { } "mkdir -p $out/bin; cp ${freebsd.cp}/bin/cp $out/bin/bsdcp")
71 coreutils
72 gnutar
73 findutils
74 gnumake
75 gnused
76 patchelf
77 gnugrep
78 gawk
79 diffutils
80 patch
81 bash
82 xz
83 xz.dev
84 gzip
85 bzip2
86 bzip2.dev
87 curl
88 expand-response-params
89 binutils-unwrapped
90 freebsd.libc
91 llvmPackages.libcxx
92 llvmPackages.libcxx.dev
93 llvmPackages.compiler-rt
94 llvmPackages.compiler-rt.dev
95 llvmPackages.clang-unwrapped
96 (freebsd.locales.override { locales = [ "C.UTF-8" ]; })
97 ]
98 # INSTRUCTIONS FOR GENERATING THE SPURIOUS LIST
99 # - empty this list
100 # - rebuild bootstrap files and update their urls and hashes
101 # - turn on atime on your FreeBSD nix store filesystem
102 # - run nix-collect-garbage on FreeBSD to make it so we rebuild FODs
103 # - build the nixpkgs __bootstrapArchive attribute on FreeBSD
104 # - reboot your FreeBSD system. Otherwise the atimes will simply be wrong because of kernel caching
105 # - run a full build of stdenv on FreeBSD. with -j3, this takes 1h40 on my 20 cpu VM (AMD host)
106 # - use the following to generate a list with access times and filenames
107 # 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
108 # - manually identify the point where files have no longer been accessed after the patching phase
109 # - 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
110 # - turn off atime if it was off before since it will degrade performance
111 # - manually remove bin/strings from the list, since it will be used only during bootstrap
112 # - 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)
113 # - plop it here
114 ) "xargs rm -f <${./bootstrap-tools-spurious.txt}";
115 build = runCommand "build" { } ''
116 mkdir -p $out/on-server
117 ln -s ${unpack} $out/on-server/unpack.nar.xz
118 ln -s ${bootstrap-tools} $out/on-server/bootstrap-tools.tar.xz
119 '';
120}