diff --git a/pkgs/os-specific/windows/default.nix b/pkgs/os-specific/windows/default.nix index 3cfdb8c7e85da..3a8813b15aaa8 100644 --- a/pkgs/os-specific/windows/default.nix +++ b/pkgs/os-specific/windows/default.nix @@ -1,5 +1,6 @@ { lib, + config, stdenv, buildPackages, pkgs, @@ -9,7 +10,9 @@ }: lib.makeScope newScope ( - self: with self; { + self: + with self; + { dlfcn = callPackage ./dlfcn { }; mingw_w64 = callPackage ./mingw-w64 { @@ -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 { }; @@ -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; + } ) diff --git a/pkgs/os-specific/windows/msvcSdk/default.nix b/pkgs/os-specific/windows/msvcSdk/default.nix index 17e0cce656a6d..f57d2bf90de96 100644 --- a/pkgs/os-specific/windows/msvcSdk/default.nix +++ b/pkgs/os-specific/windows/msvcSdk/default.nix @@ -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 - - 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 + + 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 ]; + }; +})