From f1f6424b6775459ae8a22b277c56e9a842f66a8c Mon Sep 17 00:00:00 2001 From: Artturin Date: Wed, 4 Dec 2024 22:31:18 +0200 Subject: [PATCH] DONTDROP swift: Fix `error: expected a string but found null: null` MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Not ideal ``` $ nix repl --file . --system aarch64-darwin nix-repl> pkgsCross.aarch64-multiplatform.swift «derivation /nix/store/kqbaqwdfc9g0yvkq4ffrlqspranprlmy-swift-wrapper-aarch64-unknown-linux-gnu-5.8.drv» nix-repl> pkgsCross.aarch64-multiplatform.buildPackages.swift error: … while calling the 'derivationStrict' builtin at :9:12: 8| 9| strict = derivationStrict drvAttrs; | ^ 10| … while evaluating derivation 'swift-wrapper-5.8' whose name attribute is located at /home/artturin/nixgits/my-nixpkgs/.worktree/2/pkgs/stdenv/generic/make-derivation.nix:336:7 … while evaluating attribute 'buildCommand' of derivation 'swift-wrapper-5.8' at /home/artturin/nixgits/my-nixpkgs/.worktree/2/pkgs/development/compilers/swift/wrapper/default.nix:26:3: 25| passAsFile = [ "buildCommand" ]; 26| buildCommand = '' | ^ 27| mkdir -p $out/bin $out/nix-support (stack trace truncated; use '--show-trace' to show the full, detailed trace) error: expected a string but found null: null at /home/artturin/nixgits/my-nixpkgs/.worktree/2/pkgs/development/compilers/swift/compiler/default.nix:586:11: 585| #WATCHOS_SIMULATOR 586| }.${targetPlatform.darwinPlatform}} | ^ 587| ``` --- pkgs/development/compilers/swift/compiler/default.nix | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/pkgs/development/compilers/swift/compiler/default.nix b/pkgs/development/compilers/swift/compiler/default.nix index 8e8cf798db4f24..8bd570b6450a6b 100644 --- a/pkgs/development/compilers/swift/compiler/default.nix +++ b/pkgs/development/compilers/swift/compiler/default.nix @@ -47,6 +47,8 @@ let else targetPlatform.darwinMinVersion; + targetDarwinPlatform = if (targetPlatform.darwinPlatform != null) then targetPlatform.darwinPlatform else "null"; + python3 = python3Packages.python.withPackages (p: [ p.setuptools ]); # python 3.12 compat. inherit (stdenv) hostPlatform targetPlatform; @@ -64,8 +66,8 @@ let #appletvsimulator #watchos #watchsimulator - }.${targetPlatform.darwinPlatform} - or (throw "Cannot build Swift for target Darwin platform '${targetPlatform.darwinPlatform}'") + }.${targetDarwinPlatform} + or (throw "Cannot build Swift for target Darwin platform '${targetDarwinPlatform}'") else targetPlatform.parsed.kernel.name; # Apple Silicon uses a different CPU name in the target triple. @@ -504,7 +506,7 @@ in stdenv.mkDerivation { " buildProject swift - '' + lib.optionalString stdenv.hostPlatform.isDarwin '' + '' + lib.optionalString stdenv.targetPlatform.isDarwin '' # Restore search paths to remove appleSwiftCore. export NIX_SWIFTFLAGS_COMPILE="$OLD_NIX_SWIFTFLAGS_COMPILE" export NIX_LDFLAGS="$OLD_NIX_LDFLAGS" @@ -583,7 +585,7 @@ in stdenv.mkDerivation { #TVOS_SIMULATOR #WATCHOS #WATCHOS_SIMULATOR - }.${targetPlatform.darwinPlatform}} + }.${targetDarwinPlatform} or (throw "Cannot build Swift for target Darwin platform '${targetDarwinPlatform}'")} -DLLVM_DIR=$SWIFT_BUILD_ROOT/llvm/lib/cmake/llvm