[squashme] do the requested changes

This commit is contained in:
Audrey Dutcher 2024-07-17 02:08:06 -07:00
parent 1e2071847d
commit 9dbd5a9a9d
11 changed files with 95 additions and 1374 deletions

View File

@ -6,9 +6,9 @@ binaries (without the reliance on external inputs):
- `bootstrap-tools`: an archive with the compiler toolchain and other
helper tools enough to build the rest of the `nixpkgs`.
- initial binaries needed to unpack `bootstrap-tools.*`. On `linux`
it's just `busybox`, on `darwin` it is unpack.nar.xz which contains
the binaries and script needed to unpack the tools. These binaries
can be executed directly from the store.
it's just `busybox`, on `darwin` and `freebsd` it is unpack.nar.xz
which contains the binaries and script needed to unpack the tools.
These binaries can be executed directly from the store.
These are called "bootstrap files".

View File

@ -95,6 +95,7 @@ CROSS_TARGETS=(
powerpc64-unknown-linux-gnuabielfv2
powerpc64le-unknown-linux-gnu
riscv64-unknown-linux-gnu
x86_64-unknown-freebsd
)
is_cross() {
@ -163,6 +164,7 @@ for target in "${targets[@]}"; do
case "$target" in
*linux*) nixpkgs_prefix="pkgs/stdenv/linux" ;;
*darwin*) nixpkgs_prefix="pkgs/stdenv/darwin" ;;
*freebsd*) nixpkgs_prefix="pkgs/stdenv/freebsd" ;;
*) die "don't know where to put '$target'" ;;
esac

View File

@ -0,0 +1,13 @@
{
unpack = import <nix/fetchurl.nix> {
url = "http://192.168.122.1:8000/result/on-server/unpack.nar.xz";
hash = "sha256-y6quCU9JKnKBdHDcUkdkM0ypWDT2cdSiqR1WqA+8ozE=";
name = "boostrapUnpacked";
unpack = true;
};
bootstrapTools = import <nix/fetchurl.nix> {
url = "http://192.168.122.1:8000/result/on-server/bootstrap-tools.tar.xz";
hash = "sha256-ypIOxsB8a/RPupki0ZTjb+vuE+ibtmS8e3DazeolHj8=";
name = "bootstrapTools.tar.xz";
};
}

View File

@ -7,28 +7,17 @@
config,
overlays,
crossOverlays ? [ ],
bootstrapFiles ?
let table = {
x86_64-freebsd = import ./bootstrap-files/x86_64-unknown-freebsd.nix;
};
files = table.${localSystem.system} or (throw "unsupported platform ${localSystem.system} for the pure FreeBSD stdenv");
in files
}:
assert crossSystem == localSystem;
let
inherit (localSystem) system;
bootstrap-urls-table = {
x86_64-freebsd = {
stage0 = {
url = "http://192.168.122.1:8000/stage0.nar.xz";
hash = "sha256-iGPBcwzDLJFroXwE/ADW+aUevywZCOher4mg9Ysx2j4=";
name = "bootstrap-files0";
unpack = true;
};
stage1 = {
url = "http://192.168.122.1:8000/stage1.tar.xz";
hash = "sha256-i0VBzbMPnSSmPjh5CYOQXTYCbSBbfa5omA0xZ2fjDlU=";
name = "bootstrap-files1.tar.xz";
};
};
};
fetchurlBoot = import <nix/fetchurl.nix>;
bootstrap-files = builtins.mapAttrs (k: fetchurlBoot) bootstrap-urls-table.${localSystem.system};
mkExtraBuildCommands0 = cc: ''
rsrc="$out/resource-root"
mkdir "$rsrc"
@ -49,11 +38,11 @@ let
name = "bootstrap-archive";
pname = "bootstrap-archive";
version = "9.9.9";
builder = "${bootstrap-files.stage0}/libexec/ld-elf.so.1";
args = [ "${bootstrap-files.stage0}/bin/bash" ./unpack-bootstrap-files.sh ];
LD_LIBRARY_PATH = "${bootstrap-files.stage0}/lib";
src = bootstrap-files.stage0;
inherit (bootstrap-files) stage1;
builder = "${bootstrapFiles.unpack}/libexec/ld-elf.so.1";
args = [ "${bootstrapFiles.unpack}/bin/bash" ./unpack-bootstrap-files.sh ];
LD_LIBRARY_PATH = "${bootstrapFiles.unpack}/lib";
src = bootstrapFiles.unpack;
inherit (bootstrapFiles) bootstrapTools;
}
);

View File

@ -0,0 +1,22 @@
{system ? builtins.currentSystem}:
let
inherit (releaseLib) lib;
releaseLib = import ../../top-level/release-lib.nix {
# We're not using any functions from release-lib.nix that look at
# supportedSystems.
supportedSystems = [];
};
make = crossSystem: import ./make-bootstrap-tools.nix {
pkgs = releaseLib.pkgsForCross crossSystem system;
};
in lib.mapAttrs (n: make) (with lib.systems.examples; {
# NOTE: Only add platforms for which there are files in `./bootstrap-files`
# or for which you plan to request the tarball upload soon. See the
# maintainers/scripts/bootstrap-files/README.md
# on how to request an upload.
# Sort following the sorting in `./default.nix` `bootstrapFiles` argument.
x86_64-unknown-freebsd = x86_64-freebsd;
})

View File

@ -1,28 +1,21 @@
{ system }:
((import <nixpkgs> { }).callPackage (
{
stdenv,
pkgsCross,
runCommand,
lib,
buildPackages,
}:
{ pkgs ? import ../../.. {} }:
let
pkgs = pkgsCross.${system};
inherit (pkgs) runCommand lib;
# splicing doesn't seem to work right here
inherit (pkgs.buildPackages) nix rsync;
pack-all =
packCmd: name: pkgs: fixups:
(runCommand name {
requiredSystemFeatures = [ "recursive-nix" ];
nativeBuildInputs = [ nix rsync ];
} ''
nix_store=${lib.getBin buildPackages.nix}/bin/nix-store
rsync=${lib.getExe buildPackages.rsync}
base=$PWD
requisites="$($nix_store --query --requisites ${lib.concatStringsSep " " pkgs} | tac)"
requisites="$(nix-store --query --requisites ${lib.concatStringsSep " " pkgs} | tac)"
rm -f $base/nix-support/propagated-build-inputs
for f in $requisites; do
cd $f
$rsync --chmod="+w" -av . $base
rsync --chmod="+w" -av . $base
done
cd $base
@ -42,18 +35,18 @@
rm .nix-socket
${packCmd}
'');
nar-all = pack-all "$nix_store --dump . | xz -9 -T $NIX_BUILD_CORES >$out";
tar-all = pack-all "XZ_OPT=\"-9 -T $NIX_BUILD_CORES\" tar cJf $out .";
nar-all = pack-all "nix-store --dump . | xz -9 -e -T $NIX_BUILD_CORES >$out";
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 .";
coreutils-big = pkgs.coreutils.override { singleBinary = false; };
mkdir = runCommand "mkdir" { coreutils = coreutils-big; } ''
mkdir -p $out/bin
cp $coreutils/bin/mkdir $out/bin
'';
in {
bootstrap-files0 = nar-all "${system}-bootstrap-files0.nar.xz" (with pkgs; [bash mkdir xz gnutar]) ''
in rec {
unpack = nar-all "unpack.nar.xz" (with pkgs; [bash mkdir xz gnutar]) ''
rm -rf include lib/*.a lib/i18n lib/bash share
'';
bootstrap-files1 = tar-all "${system}-bootstrap-files1.tar.xz" (
bootstrap-tools = tar-all "bootstrap-tools.tar.xz" (
with pkgs;
[
(runCommand "bsdcp" { } "mkdir -p $out/bin; cp ${freebsd.cp}/bin/cp $out/bin/bsdcp")
@ -97,9 +90,13 @@
# - 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 from the list the following; they are not marked as atime'd even though they are used
# - bin/strings # used only during bootstrap
# - 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
) "xargs rm -f <${./bootstrap-files-spurious.txt}";
) "xargs rm -f <${./bootstrap-tools-spurious.txt}";
build = runCommand "build" { } ''
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
'';
}
) { })

View File

@ -1,5 +1,5 @@
$src/libexec/ld-elf.so.1 $src/bin/mkdir $out
$src/libexec/ld-elf.so.1 $src/bin/tar -I "$src/libexec/ld-elf.so.1 $src/bin/xz" -C $out -xf $stage1
$src/libexec/ld-elf.so.1 $src/bin/tar -I "$src/libexec/ld-elf.so.1 $src/bin/xz" -C $out -xf $bootstrapTools
export LD_LIBRARY_PATH=$out/lib
BADLIST=ld-elf.so.1

View File

@ -3353,6 +3353,8 @@ with pkgs;
}
else if stdenv.hostPlatform.isLinux then
callPackage ../stdenv/linux/make-bootstrap-tools.nix {}
else if stdenv.hostPlatform.isFreeBSD then
callPackage ../stdenv/freebsd/make-bootstrap-tools.nix {}
else throw "freshBootstrapTools: unknown hostPlatform ${stdenv.hostPlatform.config}";
boxes = callPackage ../tools/text/boxes { };

View File

@ -266,14 +266,18 @@ in
/* Cross-built bootstrap tools for every supported platform */
bootstrapTools = let
tools = import ../stdenv/linux/make-bootstrap-tools-cross.nix { system = "x86_64-linux"; };
meta = {
linuxTools = import ../stdenv/linux/make-bootstrap-tools-cross.nix { system = "x86_64-linux"; };
freebsdTools = import ../stdenv/freebsd/make-bootstrap-tools-cross.nix { system = "x86_64-linux"; };
linuxMeta = {
maintainers = [ maintainers.dezgeg ];
};
mkBootstrapToolsJob = drv:
freebsdMeta = {
maintainers = [ maintainers.rhelmot ];
};
mkBootstrapToolsJob = meta: drv:
assert elem drv.system supportedSystems;
hydraJob' (addMetaAttrs meta drv);
in mapAttrsRecursiveCond (as: !isDerivation as) (name: mkBootstrapToolsJob)
linux = mapAttrsRecursiveCond (as: !isDerivation as) (name: mkBootstrapToolsJob linuxMeta)
# The `bootstrapTools.${platform}.bootstrapTools` derivation
# *unpacks* the bootstrap-files using their own `busybox` binary,
# so it will fail unless buildPlatform.canExecute hostPlatform.
@ -281,7 +285,10 @@ in
# attribute, so there is no way to detect this -- we must add it
# as a special case. We filter the "test" attribute (only from
# *cross*-built bootstrapTools) for the same reason.
(mapAttrs (_: v: removeAttrs v ["bootstrapTools" "test"]) tools);
(mapAttrs (_: v: removeAttrs v ["bootstrapTools" "test"]) linuxTools);
freebsd = mapAttrsRecursiveCond (as: !isDerivation as) (name: mkBootstrapToolsJob freebsdMeta)
freebsdTools;
in linux // freebsd;
# Cross-built nixStatic for platforms for enabled-but-unsupported platforms
mips64el-nixCrossStatic = mapTestOnCross systems.examples.mips64el-linux-gnuabi64 nixCrossStatic;

View File

@ -22,6 +22,7 @@
"x86_64-apple-darwin"
"x86_64-unknown-linux-gnu"
"x86_64-unknown-linux-musl"
"x86_64-unknown-freebsd"
]
# Strip most of attributes when evaluating to spare memory usage
, scrubJobs ? true
@ -249,6 +250,14 @@ let
# TODO: Re-enable once the new bootstrap-tools are in place.
#inherit (bootstrap.test-pkgs) stdenv;
}
else if hasSuffix "-freebsd" config then
let
bootstrap = import ../stdenv/freebsd/make-bootstrap-tools.nix {
localSystem = { inherit config; };
};
in {
inherit (bootstrap) build; # test does't exist yet
}
else
abort "No bootstrap implementation for system: ${config}"
);