Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 7 additions & 3 deletions pkgs/os-specific/windows/default.nix
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
{
lib,
config,
stdenv,
buildPackages,
pkgs,
Expand All @@ -9,7 +10,9 @@
}:

lib.makeScope newScope (
self: with self; {
self:
with self;
{
dlfcn = callPackage ./dlfcn { };

mingw_w64 = callPackage ./mingw-w64 {
Expand All @@ -31,8 +34,6 @@ lib.makeScope newScope (

mingw_w64_headers = callPackage ./mingw-w64/headers.nix { };

mingw_w64_pthreads = lib.warn "windows.mingw_w64_pthreads is deprecated, windows.pthreads should be preferred" self.pthreads;

mcfgthreads = callPackage ./mcfgthreads { stdenv = crossThreadsStdenv; };

npiperelay = callPackage ./npiperelay { };
Expand All @@ -43,4 +44,7 @@ lib.makeScope newScope (

sdk = callPackage ./msvcSdk { };
}
// lib.optionalAttrs config.allowAliases {
mingw_w64_pthreads = lib.warn "windows.mingw_w64_pthreads is deprecated, windows.pthreads should be preferred" self.pthreads;
}
)
194 changes: 98 additions & 96 deletions pkgs/os-specific/windows/msvcSdk/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -24,102 +24,104 @@ let
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
'';
};
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";
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 ];
};

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 ];
};
})
Loading