Files
Dark Steveneq 646b892680
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
push sheeet
2025-10-09 14:15:47 +02:00

128 lines
3.0 KiB
Nix

{
lib,
config,
stdenvNoCC,
xwin,
testers,
llvmPackages,
}:
let
version = (builtins.fromJSON (builtins.readFile ./manifest.json)).info.buildVersion;
hashes = (builtins.fromJSON (builtins.readFile ./hashes.json));
host = stdenvNoCC.hostPlatform;
arch =
if host.isx86_64 then
"x86_64"
else if host.isAarch64 then
"aarch64"
else if host.isx86_32 then
"x86"
else if host.isAarch32 then
"aarch"
else
throw "Unsupported system";
in
stdenvNoCC.mkDerivation (finalAttrs: {
inherit version;
pname = "msvc-sdk";
dontUnpack = true;
strictDeps = true;
nativeBuildInputs = [ xwin ];
outputHashAlgo = "sha256";
outputHashMode = "recursive";
outputHash =
if !config.microsoftVisualStudioLicenseAccepted then
throw ''
Microsoft Software License Terms are not accepted with config.microsoftVisualStudioLicenseAccepted.
Please read https://visualstudio.microsoft.com/license-terms/mt644918/ and if you agree, change your
config to indicate so.
''
else
hashes.${arch};
__structuredAttrs = true;
xwinArgs = [
"--accept-license"
"--cache-dir=xwin-out"
"--manifest=${./manifest.json}"
"--arch=${arch}"
"splat"
"--preserve-ms-arch-notation"
];
buildPhase = ''
runHook preBuild
xwin "''${xwinArgs[@]}"
mkdir "$out"
mv xwin-out/splat/* "$out"
runHook postBuild
'';
dontFixup = true;
dontInstall = true;
passthru = {
updateScript = ./update.nu;
tests = {
hello-world = testers.runCommand {
name = "hello-msvc";
nativeBuildInputs = [
llvmPackages.clang-unwrapped
llvmPackages.bintools-unwrapped
];
script = ''
set -euo pipefail
cat > hello.c <<- EOF
#include <stdio.h>
int main(int argc, char* argv[]) {
printf("Hello world!\n");
return 0;
}
EOF
clang-cl --target=x86_64-pc-windows-msvc -fuse-ld=lld \
/vctoolsdir ${finalAttrs.finalPackage}/crt \
/winsdkdir ${finalAttrs.finalPackage}/sdk \
./hello.c -v
if test ! -f hello.exe; then
echo "hello.exe not found!"
exit 1
else
touch $out
fi
'';
};
};
};
meta = {
description = "MSVC SDK and Windows CRT for cross compiling";
homepage = "https://developer.microsoft.com/en-us/windows/downloads/windows-sdk/";
maintainers = [ lib.maintainers.RossSmyth ];
license = {
deprecated = false;
fullName = "Microsoft Software License Terms";
shortName = "msvc";
spdxId = "unknown";
free = false;
url = "https://www.visualstudio.com/license-terms/mt644918/";
};
platforms = lib.platforms.all;
# The arm32 manifest is missing critical pieces.
broken = stdenvNoCC.hostPlatform.isAarch32;
sourceProvenance = [ lib.sourceTypes.binaryNativeCode ];
teams = [ lib.teams.windows ];
};
})