dotnet: fix web test on darwin

This commit is contained in:
David McFarland 2024-04-22 23:56:32 +00:00
parent 4d00d19cd0
commit 6f7eccf450

View file

@ -50,13 +50,17 @@
runtime ? finalAttrs.finalPackage, runtime ? finalAttrs.finalPackage,
runInputs ? [], runInputs ? [],
run ? null, run ? null,
runAllowNetworking ? false,
}: }:
let let
sdk = finalAttrs.finalPackage; sdk = finalAttrs.finalPackage;
built = runCommand "dotnet-test-${name}" { built = runCommand "dotnet-test-${name}" {
buildInputs = [ sdk ]; buildInputs = [ sdk ];
# make sure ICU works in a sandbox # make sure ICU works in a sandbox
propagatedSandboxProfile = toString sdk.__propagatedSandboxProfile; propagatedSandboxProfile = toString sdk.__propagatedSandboxProfile + ''
(allow network-inbound (local ip))
(allow mach-lookup (global-name "com.apple.FSEvents"))
'';
} ('' } (''
HOME=$PWD/.home HOME=$PWD/.home
dotnet new nugetconfig dotnet new nugetconfig
@ -70,10 +74,16 @@
if run == null if run == null
then built then built
else else
runCommand "${built.name}-run" { runCommand "${built.name}-run" ({
src = built; src = built;
nativeBuildInputs = [ built ] ++ runInputs; nativeBuildInputs = [ built ] ++ runInputs;
} (lib.optionalString (runtime != null) '' } // lib.optionalAttrs (stdenv.isDarwin && runAllowNetworking) {
sandboxProfile = ''
(allow network-inbound (local ip))
(allow mach-lookup (global-name "com.apple.FSEvents"))
'';
__darwinAllowLocalNetworking = true;
}) (lib.optionalString (runtime != null) ''
# TODO: use runtime here # TODO: use runtime here
export DOTNET_ROOT=${runtime} export DOTNET_ROOT=${runtime}
'' + run); '' + run);
@ -153,6 +163,7 @@
EOF EOF
touch $out touch $out
''; '';
runAllowNetworking = true;
}; };
} // args.passthru.tests or {}; } // args.passthru.tests or {};
} // args.passthru or {}; } // args.passthru or {};