push sheeet
Some checks failed
Periodic Merges (6h) / master → staging-nixos (push) Failing after 12m50s
Periodic Merges (6h) / master → staging-next (push) Failing after 12m54s
Periodic Merges (24h) / merge-base(master,staging) → haskell-updates (push) Failing after 11m54s
Periodic Merges (6h) / staging-next → staging (push) Failing after 12m13s
Periodic Merges (24h) / staging-next-25.05 → staging-25.05 (push) Failing after 13m24s
Periodic Merges (24h) / release-25.05 → staging-next-25.05 (push) Failing after 14m28s

This commit is contained in:
Dark Steveneq
2025-10-09 14:15:47 +02:00
commit 646b892680
49168 changed files with 5897842 additions and 0 deletions

View File

@@ -0,0 +1,106 @@
{
lib,
stdenv,
swift,
useSwiftDriver ? true,
swift-driver,
clang,
}:
stdenv.mkDerivation (
swift._wrapperParams
// {
pname = "swift-wrapper";
inherit (swift) version meta;
outputs = [
"out"
"man"
];
# Wrapper and setup hook variables.
inherit swift;
inherit (swift)
swiftOs
swiftArch
swiftModuleSubdir
swiftLibSubdir
swiftStaticModuleSubdir
swiftStaticLibSubdir
;
swiftDriver = lib.optionalString useSwiftDriver "${swift-driver}/bin/swift-driver";
cc_wrapper = clang.override (prev: {
extraBuildCommands =
prev.extraBuildCommands
# We need to use the resource directory corresponding to Swifts
# version of Clang instead of passing along the one from the
# `cc-wrapper` flags.
+ ''
rm -r $out/resource-root
substituteInPlace $out/nix-support/cc-cflags \
--replace-fail \
"-resource-dir=$out/resource-root" \
"-resource-dir=${lib.getLib swift}/lib/swift/clang"
''
# We need the libc++ headers corresponding to the LLVM version of
# Swifts Clang.
+ lib.optionalString (clang.libcxx != null) ''
include -isystem "${lib.getDev swift}/include/c++/v1" > $out/nix-support/libcxx-cxxflags
'';
});
env.darwinMinVersion = lib.optionalString stdenv.targetPlatform.isDarwin (
stdenv.targetPlatform.darwinMinVersion
);
passAsFile = [ "buildCommand" ];
buildCommand = ''
mkdir -p $out/bin $out/nix-support
# Symlink all Swift binaries first.
# NOTE: This specifically omits clang binaries. We want to hide these for
# private use by Swift only.
ln -s -t $out/bin/ $swift/bin/swift*
# Replace specific binaries with wrappers.
for executable in swift swiftc swift-frontend; do
export prog=$swift/bin/$executable
rm $out/bin/$executable
substituteAll '${./wrapper.sh}' $out/bin/$executable
chmod a+x $out/bin/$executable
done
${lib.optionalString useSwiftDriver ''
# Symlink swift-driver executables.
ln -s -t $out/bin/ ${swift-driver}/bin/*
''}
ln -s ${swift.man} $man
# This link is here because various tools (swiftpm) check for stdlib
# relative to the swift compiler. It's fine if this is for build-time
# stuff, but we should patch all cases were it would end up in an output.
ln -s ${swift.lib}/lib $out/lib
substituteAll ${./setup-hook.sh} $out/nix-support/setup-hook
# Propagate any propagated inputs from the unwrapped Swift compiler, if any.
if [ -e "$swift/nix-support" ]; then
for input in "$swift/nix-support/"*propagated*; do
cp "$input" "$out/nix-support/$(basename "$input")"
done
fi
'';
passthru = {
inherit swift;
inherit (swift)
swiftOs
swiftArch
swiftModuleSubdir
swiftLibSubdir
tests
;
};
}
)