stdenv/cygwin: add cross bootstrap tools

This commit is contained in:
David McFarland
2026-01-01 15:25:44 -04:00
parent be8c8ea769
commit 13cf3827d0
3 changed files with 130 additions and 1 deletions

View File

@@ -0,0 +1,30 @@
{
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-pc-cygwin = x86_64-cygwin;
}
)

View File

@@ -0,0 +1,92 @@
{
pkgs ? import ../../.. { },
}:
let
inherit (pkgs) runCommand;
# splicing doesn't seem to work right here
inherit (pkgs.buildPackages) dumpnar rsync nukeReferences;
unpacked =
let
inherit (pkgs)
bashNonInteractive
binutils-unwrapped
bzip2
coreutils
curl
diffutils
file
findutils
gawk
gcc-unwrapped
gitMinimal # for fetchgit (newlib-cygwin)
gnugrep
gnumake
gnused
gnutar
gzip
patch
xz
;
inherit (pkgs.cygwin)
newlib-cygwin
w32api
;
in
runCommand "unpacked"
{
nativeBuildInputs = [ nukeReferences ];
# The result should not contain any references (store paths) so
# that we can safely copy them out of the store and to other
# locations in the store.
allowedReferences = [ ];
strictDeps = true;
}
''
mkdir -p "$out"/{bin,include,lib,libexec}
cp -d "${bashNonInteractive}"/bin/* "$out"/bin/
cp -d "${binutils-unwrapped}"/bin/* "$out"/bin/
cp -d "${bzip2}"/bin/* "$out"/bin/
cp -d "${coreutils}"/bin/* "$out"/bin/
cp -d "${curl}"/bin/* "$out"/bin/
cp -d "${diffutils}"/bin/* "$out"/bin/
cp -d "${file}"/bin/* "$out"/bin/
cp -d "${findutils}"/bin/* "$out"/bin/
cp -d "${gawk}"/bin/* "$out"/bin/
cp -d "${gcc-unwrapped}"/bin/* "$out"/bin/
cp -rd ${gcc-unwrapped}/include/* $out/include/
cp -rd ${gcc-unwrapped}/lib/* $out/lib/
cp -rd ${gcc-unwrapped}/libexec/* $out/libexec/
cp -frd ${gcc-unwrapped.lib}/bin/* $out/bin/
cp -rd ${gcc-unwrapped.lib}/lib/* $out/lib/
cp -d "${gitMinimal}"/bin/* "$out"/bin/
cp -d "${gnugrep}"/bin/* "$out"/bin/
cp -d "${gnumake}"/bin/* "$out"/bin/
cp -d "${gnused}"/bin/* "$out"/bin/
cp -d "${gnutar}"/bin/* "$out"/bin/
(shopt -s dotglob; cp -d "${gzip}"/bin/* "$out"/bin/)
cp -rd ${newlib-cygwin.dev}/include/* $out/include/
cp -rd ${newlib-cygwin}/lib/* "$out"/lib/
cp -d "${patch}"/bin/* "$out"/bin/
cp -d "${w32api}"/lib/w32api/lib{advapi,shell,user,kernel}32.a "$out"/lib/
cp -d "${xz}"/bin/* "$out"/bin/
chmod -R +w "$out"
find "$out" -type l -print0 | while read -d $'\0' link; do
[[ -L "$link" && -e "$link" ]] || continue
[[ $(realpath "$link") != "$out"* ]] || continue
cp "$link" "$link"~
mv "$link"~ "$link"
done
find "$out" -print0 | xargs -0 nuke-refs -e "$out"
'';
in
{
unpack = runCommand "unpack.nar.xz" {
nativeBuildInputs = [ dumpnar ];
} "dumpnar ${unpacked} | xz -9 -e -T $NIX_BUILD_CORES >$out";
}

View File

@@ -299,12 +299,16 @@ in
let
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"; };
cygwinTools = import ../stdenv/cygwin/make-bootstrap-tools-cross.nix { system = "x86_64-linux"; };
linuxMeta = {
maintainers = [ maintainers.dezgeg ];
};
freebsdMeta = {
maintainers = [ maintainers.rhelmot ];
};
cygwinMeta = {
maintainers = [ maintainers.corngood ];
};
mkBootstrapToolsJob =
meta: drv:
assert elem drv.system supportedSystems;
@@ -330,8 +334,11 @@ in
freebsd = mapAttrsRecursiveCond (as: !isDerivation as) (
name: mkBootstrapToolsJob freebsdMeta
) freebsdTools;
cygwin = mapAttrsRecursiveCond (as: !isDerivation as) (
name: mkBootstrapToolsJob cygwinMeta
) cygwinTools;
in
linux // freebsd;
linux // freebsd // cygwin;
# Cross-built nixStatic for platforms for enabled-but-unsupported platforms
mips64el-nixCrossStatic = mapTestOnCross systems.examples.mips64el-linux-gnuabi64 nixCrossStatic;