windows.sdk: init at 17.14.9+36310.24.-july.2025-

This commit is contained in:
Ross Smyth
2025-07-28 00:19:15 -04:00
parent aa4a380548
commit 4e93287c0e
5 changed files with 1423 additions and 0 deletions
+2
View File
@@ -48,5 +48,7 @@ lib.makeScope newScope (
pthreads = callPackage ./pthread-w32 { };
libgnurx = callPackage ./libgnurx { };
sdk = callPackage ./msvcSdk { };
}
)
@@ -0,0 +1,123 @@
{
lib,
config,
stdenvNoCC,
xwin,
testers,
llvmPackages,
}:
let
version = (builtins.fromJSON (builtins.readFile ./manifest.json)).info.productSemanticVersion;
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
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
stdenvNoCC.mkDerivation (finalAttrs: {
inherit version;
pname = "msvc-sdk";
dontUnpack = true;
strictDeps = true;
nativeBuildInputs = [ xwin ];
outputHashAlgo = "sha256";
outputHashMode = "recursive";
outputHash = 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";
url = "https://www.visualstudio.com/license-terms/mt644918/";
};
platforms = lib.platforms.all;
# The arm manifest is missing critical pieces.
broken = stdenvNoCC.hostPlatform.isAarch;
};
})
@@ -0,0 +1,4 @@
{
"x86_64": "sha256-s3iaz9SkV8H1j3rQ1ZWKe9I1o/42+buqxCnGAoA17j8=",
"x86": "sha256-ZiFms3GWhTrEcE6/nf3pUjpdux5PRI3AtOzxofk93pk="
}
File diff suppressed because one or more lines are too long
+48
View File
@@ -0,0 +1,48 @@
#!/usr/bin/env nix-shell
#!nix-shell -i nu -p nushell xwin
use std/log
use std/dirs
const MANIFEST_URL = "https://aka.ms/vs/17/release/channel"
const PATH = "pkgs/os-specific/windows/msvcSdk"
def replace_hash [ p: path old: string new: string ] {
open $p
| str replace $old $new
| save -f $p
}
def main [] {
# Ensure the version is actually new
let current_version = nix eval -f "" windows.sdk.version --json | from json
let new_manifest = http get $MANIFEST_URL | decode | from json
let new_version = $new_manifest.info.productSemanticVersion
if $current_version == $new_version {
log info "Current Windows SDK manifest matches the newest version, exiting..."
exit 0
} else {
log info $"Previous version (current_version)\nNew version (new_version)"
}
$new_manifest | to json | append "\n" | str join | save -f ($PATH | path join manifest.json)
# TODO: Add arm once it isn't broken
let hashes = ["x86_64", "x86"] | par-each {
|arch|
let dir = mktemp -d
xwin --accept-license --cache-dir $dir --manifest $"($PATH | path join manifest.json)" --arch $arch splat --preserve-ms-arch-notation
let hash = nix hash path ($dir | path join splat)
{arch: $arch, hash: $hash}
} | transpose -r -d
log info $"New hashes:\n ($hashes)"
$hashes | to json | append "\n" | str join | save -f ($PATH | path join hashes.json)
}