dotnet: use unpacked nuget packages

Changed files
+590 -512
doc
languages-frameworks
pkgs
build-support
by-name
to
torrentstream
development
servers
nosql
eventstore
top-level
+4 -4
doc/languages-frameworks/dotnet.section.md
···
For more detail about managing the `deps.nix` file, see [Generating and updating NuGet dependencies](#generating-and-updating-nuget-dependencies)
:::
-
* `packNupkg` is used to pack project as a `nupkg`, and installs it to `$out/share`. If set to `true`, the derivation can be used as a dependency for another dotnet project by adding it to `projectReferences`.
-
* `projectReferences` can be used to resolve `ProjectReference` project items. Referenced projects can be packed with `buildDotnetModule` by setting the `packNupkg = true` attribute and passing a list of derivations to `projectReferences`. Since we are sharing referenced projects as NuGets they must be added to csproj/fsproj files as `PackageReference` as well.
For example, your project has a local dependency:
```xml
<ProjectReference Include="../foo/bar.fsproj" />
```
-
To enable discovery through `projectReferences` you would need to add:
```xml
<ProjectReference Include="../foo/bar.fsproj" />
<PackageReference Include="bar" Version="*" Condition=" '$(ContinuousIntegrationBuild)'=='true' "/>
···
projectFile = "src/project.sln";
nugetDeps = ./deps.nix; # see "Generating and updating NuGet dependencies" section for details
-
projectReferences = [ referencedProject ]; # `referencedProject` must contain `nupkg` in the folder structure.
dotnet-sdk = dotnetCorePackages.sdk_6_0;
dotnet-runtime = dotnetCorePackages.runtime_6_0;
···
For more detail about managing the `deps.nix` file, see [Generating and updating NuGet dependencies](#generating-and-updating-nuget-dependencies)
:::
+
* `packNupkg` is used to pack project as a `nupkg`, and installs it to `$out/share`. If set to `true`, the derivation can be used as a dependency for another dotnet project by adding it to `buildInputs`.
+
* `buildInputs` can be used to resolve `ProjectReference` project items. Referenced projects can be packed with `buildDotnetModule` by setting the `packNupkg = true` attribute and passing a list of derivations to `buildInputs`. Since we are sharing referenced projects as NuGets they must be added to csproj/fsproj files as `PackageReference` as well.
For example, your project has a local dependency:
```xml
<ProjectReference Include="../foo/bar.fsproj" />
```
+
To enable discovery through `buildInputs` you would need to add:
```xml
<ProjectReference Include="../foo/bar.fsproj" />
<PackageReference Include="bar" Version="*" Condition=" '$(ContinuousIntegrationBuild)'=='true' "/>
···
projectFile = "src/project.sln";
nugetDeps = ./deps.nix; # see "Generating and updating NuGet dependencies" section for details
+
buildInputs = [ referencedProject ]; # `referencedProject` must contain `nupkg` in the folder structure.
dotnet-sdk = dotnetCorePackages.sdk_6_0;
dotnet-runtime = dotnetCorePackages.runtime_6_0;
+1
pkgs/build-support/dotnet/build-dotnet-global-tool/default.nix
···
nugetDeps = { fetchNuGet }: [
(fetchNuGet { pname = nugetName; inherit version; sha256 = nugetSha256; hash = nugetHash; })
] ++ (nugetDeps fetchNuGet);
};
dotnetGlobalTool = true;
···
nugetDeps = { fetchNuGet }: [
(fetchNuGet { pname = nugetName; inherit version; sha256 = nugetSha256; hash = nugetHash; })
] ++ (nugetDeps fetchNuGet);
+
installable = true;
};
dotnetGlobalTool = true;
+48 -80
pkgs/build-support/dotnet/build-dotnet-module/default.nix
···
, callPackage
, substituteAll
, writeShellScript
-
, srcOnly
-
, linkFarmFromDrvs
-
, symlinkJoin
, makeWrapper
, dotnetCorePackages
-
, mkNugetSource
, mkNugetDeps
, nuget-to-nix
, cacert
-
, coreutils
-
, runtimeShellPackage
}:
{ name ? "${_args.pname}-${_args.version}"
···
inherit dotnet-sdk dotnet-runtime;
}) dotnetConfigureHook dotnetBuildHook dotnetCheckHook dotnetInstallHook dotnetFixupHook;
-
localDeps =
-
if (projectReferences != [ ])
-
then linkFarmFromDrvs "${name}-project-references" projectReferences
-
else null;
-
_nugetDeps =
if (nugetDeps != null) then
if lib.isDerivation nugetDeps
···
}
else throw "Defining the `nugetDeps` attribute is required, as to lock the NuGet dependencies. This file can be generated by running the `passthru.fetch-deps` script.";
-
# contains the actual package dependencies
-
dependenciesSource = mkNugetSource {
-
name = "${name}-dependencies-source";
-
description = "Nuget source with the dependencies for ${name}";
-
deps = [ _nugetDeps ] ++ lib.optional (localDeps != null) localDeps;
-
};
-
-
# this contains all the nuget packages that are implicitly referenced by the dotnet
-
# build system. having them as separate deps allows us to avoid having to regenerate
-
# a packages dependencies when the dotnet-sdk version changes
-
sdkDeps = lib.lists.flatten [ dotnet-sdk.packages ];
-
-
sdkSource = let
-
version = dotnet-sdk.version or (lib.concatStringsSep "-" dotnet-sdk.versions);
-
in mkNugetSource {
-
name = "dotnet-sdk-${version}-source";
-
deps = sdkDeps;
-
};
-
-
nuget-source = symlinkJoin {
-
name = "${name}-nuget-source";
-
paths = [ dependenciesSource sdkSource ];
-
};
-
nugetDepsFile = _nugetDeps.sourceFile;
in
-
stdenvNoCC.mkDerivation (args // {
dotnetInstallPath = installPath;
dotnetExecutables = executables;
dotnetBuildType = buildType;
dotnetProjectFiles = projectFiles;
dotnetTestProjectFiles = testProjectFiles;
dotnetDisabledTests = disabledTests;
-
dotnetRuntimeId = runtimeId;
-
nugetSource = nuget-source;
dotnetRuntimeDeps = map lib.getLib runtimeDeps;
dotnetSelfContainedBuild = selfContainedBuild;
dotnetUseAppHost = useAppHost;
···
cacert
makeWrapper
dotnet-sdk
];
# Parse the version attr into a format acceptable for the Version msbuild property
# The actual version attr is saved in InformationalVersion, which accepts an arbitrary string
···
propagatedSandboxProfile = toString dotnet-runtime.__propagatedSandboxProfile;
passthru = {
-
inherit nuget-source;
} // lib.optionalAttrs (!lib.isDerivation nugetDeps) {
fetch-deps = let
-
flagsList = dotnetFlags ++ dotnetRestoreFlags;
-
flags = lib.concatStringsSep " " (map lib.escapeShellArg flagsList);
-
disableParallel =
-
lib.optionalString (!enableParallelBuilding) "--disable-parallel";
-
runtimeIdsList = if runtimeId != null then
-
[ runtimeId ]
-
else
-
map (system: dotnetCorePackages.systemToDotnetRid system) platforms;
-
runtimeIds =
-
lib.concatStringsSep " " (map lib.escapeShellArg runtimeIdsList);
-
defaultDepsFile =
-
# Wire in the nugetDeps file such that running the script with no args
-
# runs it agains the correct deps file by default.
-
# Note that toString is necessary here as it results in the path at
-
# eval time (i.e. to the file in your local Nixpkgs checkout) rather
-
# than the Nix store path of the path after it's been imported.
-
if lib.isPath nugetDepsFile
-
&& !lib.hasPrefix "${builtins.storeDir}/" (toString nugetDepsFile) then
-
toString nugetDepsFile
-
else
-
''$(mktemp -t "${pname}-deps-XXXXXX.nix")'';
-
storeSrc = srcOnly args;
-
projectFileStr = lib.escapeShellArgs projectFiles;
-
testProjectFileStr = lib.escapeShellArgs testProjectFiles;
-
path = lib.makeBinPath [
-
coreutils
-
runtimeShellPackage
-
dotnet-sdk
-
(nuget-to-nix.override { inherit dotnet-sdk; })
-
];
-
dotnetSdkPath = toString dotnet-sdk;
-
excludedSources =
-
lib.concatStringsSep " " (map lib.escapeShellArg sdkDeps);
-
in substituteAll {
-
name = "fetch-deps";
-
src = ./fetch-deps.sh;
-
isExecutable = true;
-
inherit pname defaultDepsFile runtimeIds storeSrc flags disableParallel
-
projectFileStr testProjectFileStr path dotnetSdkPath excludedSources
-
runtimeShell;
-
};
} // args.passthru or { };
meta = (args.meta or { }) // { inherit platforms; };
···
, callPackage
, substituteAll
, writeShellScript
, makeWrapper
, dotnetCorePackages
, mkNugetDeps
, nuget-to-nix
, cacert
+
, unzip
+
, yq
+
, nix
}:
{ name ? "${_args.pname}-${_args.version}"
···
inherit dotnet-sdk dotnet-runtime;
}) dotnetConfigureHook dotnetBuildHook dotnetCheckHook dotnetInstallHook dotnetFixupHook;
_nugetDeps =
if (nugetDeps != null) then
if lib.isDerivation nugetDeps
···
}
else throw "Defining the `nugetDeps` attribute is required, as to lock the NuGet dependencies. This file can be generated by running the `passthru.fetch-deps` script.";
nugetDepsFile = _nugetDeps.sourceFile;
+
+
inherit (dotnetCorePackages) systemToDotnetRid;
in
+
stdenvNoCC.mkDerivation (finalAttrs: args // {
dotnetInstallPath = installPath;
dotnetExecutables = executables;
dotnetBuildType = buildType;
dotnetProjectFiles = projectFiles;
dotnetTestProjectFiles = testProjectFiles;
dotnetDisabledTests = disabledTests;
+
dotnetRuntimeIds = lib.singleton (
+
if runtimeId != null
+
then runtimeId
+
else systemToDotnetRid stdenvNoCC.hostPlatform.system);
dotnetRuntimeDeps = map lib.getLib runtimeDeps;
dotnetSelfContainedBuild = selfContainedBuild;
dotnetUseAppHost = useAppHost;
···
cacert
makeWrapper
dotnet-sdk
+
unzip
+
yq
];
+
+
buildInputs = args.buildInputs or [] ++ [
+
dotnet-sdk.packages
+
_nugetDeps
+
] ++ projectReferences;
# Parse the version attr into a format acceptable for the Version msbuild property
# The actual version attr is saved in InformationalVersion, which accepts an arbitrary string
···
propagatedSandboxProfile = toString dotnet-runtime.__propagatedSandboxProfile;
passthru = {
+
nugetDeps = _nugetDeps;
} // lib.optionalAttrs (!lib.isDerivation nugetDeps) {
fetch-deps = let
+
pkg = finalAttrs.finalPackage.overrideAttrs (old: {
+
buildInputs = lib.remove _nugetDeps old.buildInputs;
+
keepNugetConfig = true;
+
} // lib.optionalAttrs (runtimeId == null) {
+
dotnetRuntimeIds = map (system: systemToDotnetRid system) platforms;
+
});
+
+
drv = builtins.unsafeDiscardOutputDependency pkg.drvPath;
+
+
innerScript = substituteAll {
+
src = ./fetch-deps.sh;
+
isExecutable = true;
+
defaultDepsFile =
+
# Wire in the nugetDeps file such that running the script with no args
+
# runs it agains the correct deps file by default.
+
# Note that toString is necessary here as it results in the path at
+
# eval time (i.e. to the file in your local Nixpkgs checkout) rather
+
# than the Nix store path of the path after it's been imported.
+
if lib.isPath nugetDepsFile
+
&& !lib.hasPrefix "${builtins.storeDir}/" (toString nugetDepsFile) then
+
toString nugetDepsFile
+
else
+
''$(mktemp -t "${pname}-deps-XXXXXX.nix")'';
+
nugetToNix = (nuget-to-nix.override { inherit dotnet-sdk; });
+
};
+
+
in writeShellScript "${name}-fetch-deps" ''
+
NIX_BUILD_SHELL="${runtimeShell}" exec ${nix}/bin/nix-shell \
+
--pure --run 'source "${innerScript}"' "${drv}"
+
'';
} // args.passthru or { };
meta = (args.meta or { }) // { inherit platforms; };
+13 -102
pkgs/build-support/dotnet/build-dotnet-module/fetch-deps.sh
···
-
#! @runtimeShell@
-
# shellcheck shell=bash
-
set -euo pipefail
-
-
export PATH="@path@"
-
-
for arg in "$@"; do
-
case "$arg" in
-
--keep-sources|-k)
-
keepSources=1
-
shift
-
;;
-
--help|-h)
-
echo "usage: $0 [--keep-sources] [--help] <output path>"
-
echo " <output path> The path to write the lockfile to. A temporary file is used if this is not set"
-
echo " --keep-sources Dont remove temporary directories upon exit, useful for debugging"
-
echo " --help Show this help message"
-
exit
-
;;
-
esac
-
done
-
-
if [[ ${TMPDIR:-} == /run/user/* ]]; then
-
# /run/user is usually a tmpfs in RAM, which may be too small
-
# to store all downloaded dotnet packages
-
unset TMPDIR
-
fi
-
-
export tmp=$(mktemp -td "deps-@pname@-XXXXXX")
-
HOME=$tmp/home
-
exitTrap() {
-
test -n "${ranTrap-}" && return
-
ranTrap=1
-
if test -n "${keepSources-}"; then
-
echo -e "Path to the source: $tmp/src\nPath to the fake home: $tmp/home"
-
else
-
rm -rf "$tmp"
-
fi
-
# Since mktemp is used this will be empty if the script didnt succesfully complete
-
if ! test -s "$depsFile"; then
-
rm -rf "$depsFile"
-
fi
-
}
-
-
trap exitTrap EXIT INT TERM
-
-
dotnetRestore() {
-
local -r project="${1-}"
-
local -r rid="$2"
-
-
dotnet restore ${project-} \
-
-p:ContinuousIntegrationBuild=true \
-
-p:Deterministic=true \
-
--packages "$tmp/nuget_pkgs" \
-
--runtime "$rid" \
-
--no-cache \
-
--force \
-
@disableParallel@ \
-
@flags@
-
}
-
-
declare -a projectFiles=( @projectFileStr@ )
-
declare -a testProjectFiles=( @testProjectFileStr@ )
-
-
export DOTNET_NOLOGO=1
-
export DOTNET_CLI_TELEMETRY_OPTOUT=1
depsFile=$(realpath "${1:-@defaultDepsFile@}")
-
echo Will write lockfile to "$depsFile"
-
mkdir -p "$tmp/nuget_pkgs"
-
-
storeSrc="@storeSrc@"
-
src=$tmp/src
-
cp -rT "$storeSrc" "$src"
-
chmod -R +w "$src"
-
-
cd "$src"
-
echo "Restoring project..."
-
-
"@dotnetSdkPath@/bin/dotnet" tool restore
-
cp -r $HOME/.nuget/packages/* $tmp/nuget_pkgs || true
-
-
runtimeIds=(@runtimeIds@)
-
-
for rid in "${runtimeIds[@]}"; do
-
(( ${#projectFiles[@]} == 0 )) && dotnetRestore "" "$rid"
-
-
for project in ${projectFiles[@]-} ${testProjectFiles[@]-}; do
-
dotnetRestore "$project" "$rid"
-
done
-
done
-
# Second copy, makes sure packages restored by ie. paket are included
-
cp -r $HOME/.nuget/packages/* $tmp/nuget_pkgs || true
-
-
echo "Succesfully restored project"
-
-
echo "Writing lockfile..."
-
-
excluded_sources=( @excludedSources@ )
-
for excluded_source in ${excluded_sources[@]}; do
-
ls "$excluded_source" >> "$tmp/excluded_list"
-
done
tmpFile="$tmp"/deps.nix
echo -e "# This file was automatically generated by passthru.fetch-deps.\n# Please dont edit it manually, your changes might get overwritten!\n" > "$tmpFile"
-
nuget-to-nix "$tmp/nuget_pkgs" "$tmp/excluded_list" >> "$tmpFile"
mv "$tmpFile" "$depsFile"
echo "Succesfully wrote lockfile to $depsFile"
-
···
+
set -e
+
tmp=$(mktemp -d)
+
trap 'chmod -R +w "$tmp" && rm -fr "$tmp"' EXIT
+
HOME=$tmp/.home
+
cd "$tmp"
+
phases="
+
${prePhases[*]:-}
+
unpackPhase
+
patchPhase
+
${preConfigurePhases[*]:-}
+
configurePhase
+
" genericBuild
depsFile=$(realpath "${1:-@defaultDepsFile@}")
tmpFile="$tmp"/deps.nix
echo -e "# This file was automatically generated by passthru.fetch-deps.\n# Please dont edit it manually, your changes might get overwritten!\n" > "$tmpFile"
+
@nugetToNix@/bin/nuget-to-nix "$NUGET_PACKAGES" >> "$tmpFile"
mv "$tmpFile" "$depsFile"
echo "Succesfully wrote lockfile to $depsFile"
+2 -12
pkgs/build-support/dotnet/build-dotnet-module/hooks/default.nix
···
, zlib
, openssl
, makeSetupHook
-
, dotnetCorePackages
# Passed from ../default.nix
, dotnet-sdk
, dotnet-runtime
}:
-
let
-
runtimeId = dotnetCorePackages.systemToDotnetRid stdenv.hostPlatform.system;
-
in
{
dotnetConfigureHook = makeSetupHook
{
name = "dotnet-configure-hook";
substitutions = {
-
runtimeId = lib.escapeShellArg runtimeId;
dynamicLinker = "${stdenv.cc}/nix-support/dynamic-linker";
libPath = lib.makeLibraryPath [
stdenv.cc.cc.lib
···
dotnetBuildHook = makeSetupHook
{
name = "dotnet-build-hook";
-
substitutions = {
-
runtimeId = lib.escapeShellArg runtimeId;
-
};
}
./dotnet-build-hook.sh;
dotnetCheckHook = makeSetupHook
{
name = "dotnet-check-hook";
-
substitutions = {
-
runtimeId = lib.escapeShellArg runtimeId;
-
};
}
./dotnet-check-hook.sh;
···
{
name = "dotnet-install-hook";
substitutions = {
-
runtimeId = lib.escapeShellArg runtimeId;
};
}
./dotnet-install-hook.sh;
···
, zlib
, openssl
, makeSetupHook
+
, zip
# Passed from ../default.nix
, dotnet-sdk
, dotnet-runtime
}:
{
dotnetConfigureHook = makeSetupHook
{
name = "dotnet-configure-hook";
substitutions = {
dynamicLinker = "${stdenv.cc}/nix-support/dynamic-linker";
libPath = lib.makeLibraryPath [
stdenv.cc.cc.lib
···
dotnetBuildHook = makeSetupHook
{
name = "dotnet-build-hook";
}
./dotnet-build-hook.sh;
dotnetCheckHook = makeSetupHook
{
name = "dotnet-check-hook";
}
./dotnet-check-hook.sh;
···
{
name = "dotnet-install-hook";
substitutions = {
+
inherit zip;
};
}
./dotnet-install-hook.sh;
+20 -17
pkgs/build-support/dotnet/build-dotnet-module/hooks/dotnet-build-hook.sh
···
runHook preBuild
-
local -r hostRuntimeId=@runtimeId@
local -r dotnetBuildType="${dotnetBuildType-Release}"
-
local -r dotnetRuntimeId="${dotnetRuntimeId-$hostRuntimeId}"
if [[ -n $__structuredAttrs ]]; then
local dotnetProjectFilesArray=( "${dotnetProjectFiles[@]}" )
local dotnetTestProjectFilesArray=( "${dotnetTestProjectFiles[@]}" )
local dotnetFlagsArray=( "${dotnetFlags[@]}" )
local dotnetBuildFlagsArray=( "${dotnetBuildFlags[@]}" )
else
local dotnetProjectFilesArray=($dotnetProjectFiles)
local dotnetTestProjectFilesArray=($dotnetTestProjectFiles)
local dotnetFlagsArray=($dotnetFlags)
local dotnetBuildFlagsArray=($dotnetBuildFlags)
fi
if [[ -n "${enableParallelBuilding-}" ]]; then
···
dotnetBuild() {
local -r projectFile="${1-}"
-
local runtimeIdFlagsArray=()
-
if [[ $projectFile == *.csproj || -n ${dotnetSelfContainedBuild-} ]]; then
-
runtimeIdFlagsArray+=("--runtime" "$dotnetRuntimeId")
-
fi
-
dotnet build ${1+"$projectFile"} \
-
-maxcpucount:"$maxCpuFlag" \
-
-p:BuildInParallel="$parallelBuildFlag" \
-
-p:ContinuousIntegrationBuild=true \
-
-p:Deterministic=true \
-
--configuration "$dotnetBuildType" \
-
--no-restore \
-
"${versionFlagsArray[@]}" \
-
"${runtimeIdFlagsArray[@]}" \
-
"${dotnetBuildFlagsArray[@]}" \
-
"${dotnetFlagsArray[@]}"
}
if (( ${#dotnetProjectFilesArray[@]} == 0 )); then
···
runHook preBuild
local -r dotnetBuildType="${dotnetBuildType-Release}"
if [[ -n $__structuredAttrs ]]; then
local dotnetProjectFilesArray=( "${dotnetProjectFiles[@]}" )
local dotnetTestProjectFilesArray=( "${dotnetTestProjectFiles[@]}" )
local dotnetFlagsArray=( "${dotnetFlags[@]}" )
local dotnetBuildFlagsArray=( "${dotnetBuildFlags[@]}" )
+
local dotnetRuntimeIdsArray=( "${dotnetRuntimeIds[@]}" )
else
local dotnetProjectFilesArray=($dotnetProjectFiles)
local dotnetTestProjectFilesArray=($dotnetTestProjectFiles)
local dotnetFlagsArray=($dotnetFlags)
local dotnetBuildFlagsArray=($dotnetBuildFlags)
+
local dotnetRuntimeIdsArray=($dotnetRuntimeIds)
fi
if [[ -n "${enableParallelBuilding-}" ]]; then
···
dotnetBuild() {
local -r projectFile="${1-}"
+
for runtimeId in "${dotnetRuntimeIdsArray[@]}"; do
+
local runtimeIdFlagsArray=()
+
if [[ $projectFile == *.csproj || -n ${dotnetSelfContainedBuild-} ]]; then
+
runtimeIdFlagsArray+=("--runtime" "$runtimeId")
+
fi
+
dotnet build ${1+"$projectFile"} \
+
-maxcpucount:"$maxCpuFlag" \
+
-p:BuildInParallel="$parallelBuildFlag" \
+
-p:ContinuousIntegrationBuild=true \
+
-p:Deterministic=true \
+
-p:OverwriteReadOnlyFiles=true \
+
--configuration "$dotnetBuildType" \
+
--no-restore \
+
"${versionFlagsArray[@]}" \
+
"${runtimeIdFlagsArray[@]}" \
+
"${dotnetBuildFlagsArray[@]}" \
+
"${dotnetFlagsArray[@]}"
+
done
}
if (( ${#dotnetProjectFilesArray[@]} == 0 )); then
+20 -18
pkgs/build-support/dotnet/build-dotnet-module/hooks/dotnet-check-hook.sh
···
runHook preCheck
-
local -r hostRuntimeId=@runtimeId@
local -r dotnetBuildType="${dotnetBuildType-Release}"
-
local -r dotnetRuntimeId="${dotnetRuntimeId-$hostRuntimeId}"
if [[ -n $__structuredAttrs ]]; then
local dotnetProjectFilesArray=( "${dotnetProjectFiles[@]}" )
···
local dotnetTestFlagsArray=( "${dotnetTestFlags[@]}" )
local dotnetDisabledTestsArray=( "${dotnetDisabledTests[@]}" )
local dotnetRuntimeDepsArray=( "${dotnetRuntimeDeps[@]}" )
else
local dotnetProjectFilesArray=($dotnetProjectFiles)
local dotnetTestProjectFilesArray=($dotnetTestProjectFiles)
local dotnetTestFlagsArray=($dotnetTestFlags)
local dotnetDisabledTestsArray=($dotnetDisabledTests)
local dotnetRuntimeDepsArray=($dotnetRuntimeDeps)
fi
if (( ${#dotnetDisabledTestsArray[@]} > 0 )); then
···
local -r maxCpuFlag="1"
fi
-
local projectFile
for projectFile in "${dotnetTestProjectFilesArray[@]-${dotnetProjectFilesArray[@]}}"; do
-
local runtimeIdFlagsArray=()
-
if [[ $projectFile == *.csproj ]]; then
-
runtimeIdFlagsArray=("--runtime" "$dotnetRuntimeId")
-
fi
-
LD_LIBRARY_PATH=$libraryPath \
-
dotnet test "$projectFile" \
-
-maxcpucount:"$maxCpuFlag" \
-
-p:ContinuousIntegrationBuild=true \
-
-p:Deterministic=true \
-
--configuration "$dotnetBuildType" \
-
--no-build \
-
--logger "console;verbosity=normal" \
-
"${runtimeIdFlagsArray[@]}" \
-
"${dotnetTestFlagsArray[@]}" \
-
"${dotnetFlagsArray[@]}"
done
runHook postCheck
···
runHook preCheck
local -r dotnetBuildType="${dotnetBuildType-Release}"
if [[ -n $__structuredAttrs ]]; then
local dotnetProjectFilesArray=( "${dotnetProjectFiles[@]}" )
···
local dotnetTestFlagsArray=( "${dotnetTestFlags[@]}" )
local dotnetDisabledTestsArray=( "${dotnetDisabledTests[@]}" )
local dotnetRuntimeDepsArray=( "${dotnetRuntimeDeps[@]}" )
+
local dotnetRuntimeIdsArray=( "${dotnetRuntimeIds[@]}" )
else
local dotnetProjectFilesArray=($dotnetProjectFiles)
local dotnetTestProjectFilesArray=($dotnetTestProjectFiles)
local dotnetTestFlagsArray=($dotnetTestFlags)
local dotnetDisabledTestsArray=($dotnetDisabledTests)
local dotnetRuntimeDepsArray=($dotnetRuntimeDeps)
+
local dotnetRuntimeIdsArray=($dotnetRuntimeIds)
fi
if (( ${#dotnetDisabledTestsArray[@]} > 0 )); then
···
local -r maxCpuFlag="1"
fi
+
local projectFile runtimeId
for projectFile in "${dotnetTestProjectFilesArray[@]-${dotnetProjectFilesArray[@]}}"; do
+
for runtimeId in "${dotnetRuntimeIdsArray[@]}"; do
+
local runtimeIdFlagsArray=()
+
if [[ $projectFile == *.csproj ]]; then
+
runtimeIdFlagsArray=("--runtime" "$runtimeId")
+
fi
+
LD_LIBRARY_PATH=$libraryPath \
+
dotnet test "$projectFile" \
+
-maxcpucount:"$maxCpuFlag" \
+
-p:ContinuousIntegrationBuild=true \
+
-p:Deterministic=true \
+
--configuration "$dotnetBuildType" \
+
--no-build \
+
--logger "console;verbosity=normal" \
+
"${runtimeIdFlagsArray[@]}" \
+
"${dotnetTestFlagsArray[@]}" \
+
"${dotnetFlagsArray[@]}"
+
done
done
runHook postCheck
+26 -66
pkgs/build-support/dotnet/build-dotnet-module/hooks/dotnet-configure-hook.sh
···
runHook preConfigure
-
if [[ -z ${nugetSource-} ]]; then
-
echo
-
echo "ERROR: no dependencies were specified"
-
echo 'Hint: set `nugetSource` if using these hooks individually. If this is happening with `buildDotnetModule`, please open an issue.'
-
echo
-
-
exit 1
-
fi
-
-
local nugetSourceSedQuoted="${nugetSource//[\/\\&$'\n']/\\&}"
-
local nugetSourceXMLQuoted="$nugetSource"
-
nugetSourceXMLQuoted="${nugetSource//&/\&amp;}"
-
nugetSourceXMLQuoted="${nugetSourceXMLQuoted//\"/\&quot;}"
-
-
local -r hostRuntimeId=@runtimeId@
local -r dynamicLinker=@dynamicLinker@
local -r libPath=@libPath@
-
local -r dotnetRuntimeId="${dotnetRuntimeId-$hostRuntimeId}"
if [[ -n $__structuredAttrs ]]; then
local dotnetProjectFilesArray=( "${dotnetProjectFiles[@]}" )
local dotnetTestProjectFilesArray=( "${dotnetTestProjectFiles[@]}" )
local dotnetFlagsArray=( "${dotnetFlags[@]}" )
local dotnetRestoreFlagsArray=( "${dotnetRestoreFlags[@]}" )
else
local dotnetProjectFilesArray=($dotnetProjectFiles)
local dotnetTestProjectFilesArray=($dotnetTestProjectFiles)
local dotnetFlagsArray=($dotnetFlags)
local dotnetRestoreFlagsArray=($dotnetRestoreFlags)
fi
if [[ -z ${enableParallelBuilding-} ]]; then
···
dotnetRestore() {
local -r projectFile="${1-}"
-
dotnet restore ${1+"$projectFile"} \
-
-p:ContinuousIntegrationBuild=true \
-
-p:Deterministic=true \
-
--runtime "$dotnetRuntimeId" \
-
--source "$nugetSource/lib" \
-
${parallelFlag-} \
-
"${dotnetRestoreFlagsArray[@]}" \
-
"${dotnetFlagsArray[@]}"
}
-
# Generate a NuGet.config file to make sure everything,
-
# including things like <Sdk /> dependencies, is restored from the proper source
-
cat >NuGet.config <<EOF
-
<?xml version="1.0" encoding="utf-8"?>
-
<configuration>
-
<packageSources>
-
<clear />
-
<add key="nugetSource" value="$nugetSourceXMLQuoted/lib" />
-
</packageSources>
-
</configuration>
-
EOF
-
# Patch paket.dependencies and paket.lock (if found) to use the proper
-
# source. This ensures paket restore works correctly. Note that the
-
# nugetSourceSedQuoted abomination below safely escapes nugetSource string
-
# for use as a sed replacement string to avoid issues with slashes and other
-
# special characters ('&', '\\' and '\n').
-
find -name paket.dependencies -exec sed -i "s/source .*/source $nugetSourceSedQuoted\/lib/g" {} \;
-
find -name paket.lock -exec sed -i "s/remote:.*/remote: $nugetSourceSedQuoted\/lib/g" {} \;
-
-
dotnet tool restore --add-source "$nugetSource/lib"
# dotnetGlobalTool is set in buildDotnetGlobalTool to patch dependencies but
# avoid other project-specific logic. This is a hack, but the old behavior
···
dotnetRestore "$projectFile"
done
fi
-
-
echo "Fixing up native binaries..."
-
# Find all native binaries and nuget libraries, and fix them up,
-
# by setting the proper interpreter and rpath to some commonly used libraries
-
local binary
-
for binary in $(find "$HOME/.nuget/packages/" -type f -executable); do
-
if patchelf --print-interpreter "$binary" >/dev/null 2>/dev/null; then
-
echo "Found binary: $binary, fixing it up..."
-
patchelf --set-interpreter "$(cat "$dynamicLinker")" "$binary"
-
-
# This makes sure that if the binary requires some specific runtime dependencies, it can find it.
-
# This fixes dotnet-built binaries like crossgen2
-
patchelf \
-
--add-needed libicui18n.so \
-
--add-needed libicuuc.so \
-
--add-needed libz.so \
-
--add-needed libssl.so \
-
"$binary"
-
-
patchelf --set-rpath "$libPath" "$binary"
-
fi
-
done
runHook postConfigure
···
runHook preConfigure
local -r dynamicLinker=@dynamicLinker@
local -r libPath=@libPath@
if [[ -n $__structuredAttrs ]]; then
local dotnetProjectFilesArray=( "${dotnetProjectFiles[@]}" )
local dotnetTestProjectFilesArray=( "${dotnetTestProjectFiles[@]}" )
local dotnetFlagsArray=( "${dotnetFlags[@]}" )
local dotnetRestoreFlagsArray=( "${dotnetRestoreFlags[@]}" )
+
local dotnetRuntimeIdsArray=( "${dotnetRuntimeIds[@]}" )
else
local dotnetProjectFilesArray=($dotnetProjectFiles)
local dotnetTestProjectFilesArray=($dotnetTestProjectFiles)
local dotnetFlagsArray=($dotnetFlags)
local dotnetRestoreFlagsArray=($dotnetRestoreFlags)
+
local dotnetRuntimeIdsArray=($dotnetRuntimeIds)
fi
if [[ -z ${enableParallelBuilding-} ]]; then
···
dotnetRestore() {
local -r projectFile="${1-}"
+
for runtimeId in "${dotnetRuntimeIdsArray[@]}"; do
+
dotnet restore ${1+"$projectFile"} \
+
-p:ContinuousIntegrationBuild=true \
+
-p:Deterministic=true \
+
-p:NuGetAudit=false \
+
--runtime "$runtimeId" \
+
${parallelFlag-} \
+
"${dotnetRestoreFlagsArray[@]}" \
+
"${dotnetFlagsArray[@]}"
+
done
}
+
find -iname nuget.config -print0 | while IFS= read -rd "" config; do
+
if [[ -n "${keepNugetConfig-}" ]]; then
+
# If we're keeping the existing configs, we'll add _nix everywhere,
+
# in case sources are cleared.
+
dotnet nuget add source "$nugetSource" -n _nix --configfile "$config"
+
else
+
# This will allow everything to fall through to our config in the
+
# build root. Deleting them causes some build failures.
+
xq -xi '.configuration={}' "$config"
+
fi
+
done
+
if [[ -f .config/dotnet-tools.json || -f .dotnet-tools.json ]]; then
+
dotnet tool restore
+
fi
# dotnetGlobalTool is set in buildDotnetGlobalTool to patch dependencies but
# avoid other project-specific logic. This is a hack, but the old behavior
···
dotnetRestore "$projectFile"
done
fi
runHook postConfigure
+55 -24
pkgs/build-support/dotnet/build-dotnet-module/hooks/dotnet-install-hook.sh
···
runHook preInstall
-
local -r hostRuntimeId=@runtimeId@
local -r dotnetInstallPath="${dotnetInstallPath-$out/lib/$pname}"
local -r dotnetBuildType="${dotnetBuildType-Release}"
-
local -r dotnetRuntimeId="${dotnetRuntimeId-$hostRuntimeId}"
if [[ -n $__structuredAttrs ]]; then
local dotnetProjectFilesArray=( "${dotnetProjectFiles[@]}" )
local dotnetFlagsArray=( "${dotnetFlags[@]}" )
local dotnetInstallFlagsArray=( "${dotnetInstallFlags[@]}" )
local dotnetPackFlagsArray=( "${dotnetPackFlags[@]}" )
else
local dotnetProjectFilesArray=($dotnetProjectFiles)
local dotnetFlagsArray=($dotnetFlags)
local dotnetInstallFlagsArray=($dotnetInstallFlags)
local dotnetPackFlagsArray=($dotnetPackFlags)
fi
if [[ -n ${dotnetSelfContainedBuild-} ]]; then
···
if [[ -n ${dotnetUseAppHost-} ]]; then
dotnetInstallFlagsArray+=("-p:UseAppHost=true")
fi
dotnetPublish() {
local -r projectFile="${1-}"
-
runtimeIdFlagsArray=()
-
if [[ $projectFile == *.csproj || -n ${dotnetSelfContainedBuild-} ]]; then
-
runtimeIdFlagsArray+=("--runtime" "$dotnetRuntimeId")
-
fi
-
dotnet publish ${1+"$projectFile"} \
-
-p:ContinuousIntegrationBuild=true \
-
-p:Deterministic=true \
-
--output "$dotnetInstallPath" \
-
--configuration "$dotnetBuildType" \
-
--no-build \
-
"${runtimeIdFlagsArray[@]}" \
-
"${dotnetInstallFlagsArray[@]}" \
-
"${dotnetFlagsArray[@]}"
}
dotnetPack() {
local -r projectFile="${1-}"
-
dotnet pack ${1+"$projectFile"} \
-
-p:ContinuousIntegrationBuild=true \
-
-p:Deterministic=true \
-
--output "$out/share" \
-
--configuration "$dotnetBuildType" \
-
--no-build \
-
--runtime "$dotnetRuntimeId" \
-
"${dotnetPackFlagsArray[@]}" \
-
"${dotnetFlagsArray[@]}"
}
if (( ${#dotnetProjectFilesArray[@]} == 0 )); then
···
done
fi
fi
runHook postInstall
···
runHook preInstall
local -r dotnetInstallPath="${dotnetInstallPath-$out/lib/$pname}"
local -r dotnetBuildType="${dotnetBuildType-Release}"
if [[ -n $__structuredAttrs ]]; then
local dotnetProjectFilesArray=( "${dotnetProjectFiles[@]}" )
local dotnetFlagsArray=( "${dotnetFlags[@]}" )
local dotnetInstallFlagsArray=( "${dotnetInstallFlags[@]}" )
local dotnetPackFlagsArray=( "${dotnetPackFlags[@]}" )
+
local dotnetRuntimeIdsArray=( "${dotnetRuntimeIds[@]}" )
else
local dotnetProjectFilesArray=($dotnetProjectFiles)
local dotnetFlagsArray=($dotnetFlags)
local dotnetInstallFlagsArray=($dotnetInstallFlags)
local dotnetPackFlagsArray=($dotnetPackFlags)
+
local dotnetRuntimeIdsArray=($dotnetRuntimeIds)
fi
if [[ -n ${dotnetSelfContainedBuild-} ]]; then
···
if [[ -n ${dotnetUseAppHost-} ]]; then
dotnetInstallFlagsArray+=("-p:UseAppHost=true")
+
fi
+
+
if [[ -n ${enableParallelBuilding-} ]]; then
+
local -r maxCpuFlag="$NIX_BUILD_CORES"
+
else
+
local -r maxCpuFlag="1"
fi
dotnetPublish() {
local -r projectFile="${1-}"
+
for runtimeId in "${dotnetRuntimeIdsArray[@]}"; do
+
runtimeIdFlagsArray=()
+
if [[ $projectFile == *.csproj || -n ${dotnetSelfContainedBuild-} ]]; then
+
runtimeIdFlagsArray+=("--runtime" "$runtimeId")
+
fi
+
dotnet publish ${1+"$projectFile"} \
+
-maxcpucount:"$maxCpuFlag" \
+
-p:ContinuousIntegrationBuild=true \
+
-p:Deterministic=true \
+
-p:OverwriteReadOnlyFiles=true \
+
--output "$dotnetInstallPath" \
+
--configuration "$dotnetBuildType" \
+
--no-build \
+
"${runtimeIdFlagsArray[@]}" \
+
"${dotnetInstallFlagsArray[@]}" \
+
"${dotnetFlagsArray[@]}"
+
done
}
+
local -r pkgs=$PWD/.nuget-pack
+
dotnetPack() {
local -r projectFile="${1-}"
+
+
for runtimeId in "${dotnetRuntimeIdsArray[@]}"; do
+
dotnet pack ${1+"$projectFile"} \
+
-maxcpucount:"$maxCpuFlag" \
+
-p:ContinuousIntegrationBuild=true \
+
-p:Deterministic=true \
+
-p:OverwriteReadOnlyFiles=true \
+
--output "$pkgs" \
+
--configuration "$dotnetBuildType" \
+
--no-build \
+
--runtime "$runtimeId" \
+
"${dotnetPackFlagsArray[@]}" \
+
"${dotnetFlagsArray[@]}"
+
done
}
if (( ${#dotnetProjectFilesArray[@]} == 0 )); then
···
done
fi
fi
+
+
local -r unpacked="$pkgs/.unpacked"
+
for nupkg in "$pkgs"/*.nupkg; do
+
rm -rf "$unpacked"
+
unzip -qd "$unpacked" "$nupkg"
+
chmod -R +rw "$unpacked"
+
echo {} > "$unpacked"/.nupkg.metadata
+
local id version
+
id=$(xq -r '.package.metadata.id|ascii_downcase' "$unpacked"/*.nuspec)
+
version=$(xq -r '.package.metadata.version|ascii_downcase' "$unpacked"/*.nuspec)
+
mkdir -p "$out/share/nuget/packages/$id"
+
mv "$unpacked" "$out/share/nuget/packages/$id/$version"
+
# TODO: should we fix executable flags here?
+
done
runHook postInstall
+71 -35
pkgs/build-support/dotnet/make-nuget-deps/default.nix
···
-
{ linkFarmFromDrvs, fetchurl, runCommand, zip }:
-
{ name, nugetDeps ? import sourceFile, sourceFile ? null }:
-
linkFarmFromDrvs "${name}-nuget-deps" (nugetDeps {
-
fetchNuGet = { pname, version, sha256 ? "", hash ? ""
-
, url ? "https://www.nuget.org/api/v2/package/${pname}/${version}" }:
-
let
-
src = fetchurl {
-
name = "${pname}.${version}.nupkg";
-
# There is no need to verify whether both sha256 and hash are
-
# valid here, because nuget-to-nix does not generate a deps.nix
-
# containing both.
-
inherit url sha256 hash;
-
};
-
in
-
# NuGet.org edits packages by signing them during upload, which makes
-
# those packages nondeterministic depending on which source you
-
# get them from. We fix this by stripping out the signature file.
-
# Signing logic is https://github.com/NuGet/NuGet.Client/blob/128a5066b1438627ac69a2ffe9de564b2c09ee4d/src/NuGet.Core/NuGet.Packaging/Signing/Archive/SignedPackageArchiveIOUtility.cs#L518
-
# Non-NuGet.org sources might not have a signature file; in that case, zip
-
# exits with code 12 ("zip has nothing to do", per `man zip`).
-
runCommand src.name
-
{
-
inherit src;
-
nativeBuildInputs = [ zip ];
-
}
-
''
-
zip "$src" --temp-path "$TMPDIR" --output-file "$out" --delete .signature.p7s || {
-
(( $? == 12 ))
-
install -Dm644 "$src" "$out"
-
}
-
'';
-
})
-
// {
-
inherit sourceFile;
-
}
···
+
{ symlinkJoin
+
, fetchurl
+
, stdenvNoCC
+
, lib
+
, unzip
+
, patchNupkgs
+
, nugetPackageHook
+
}:
+
lib.makeOverridable(
+
{ name
+
, nugetDeps ? import sourceFile
+
, sourceFile ? null
+
, installable ? false
+
}:
+
(symlinkJoin {
+
name = "${name}-nuget-deps";
+
paths = nugetDeps {
+
fetchNuGet =
+
{ pname
+
, version
+
, sha256 ? ""
+
, hash ? ""
+
, url ? "https://www.nuget.org/api/v2/package/${pname}/${version}" }:
+
stdenvNoCC.mkDerivation rec {
+
inherit pname version;
+
+
src = fetchurl {
+
name = "${pname}.${version}.nupkg";
+
# There is no need to verify whether both sha256 and hash are
+
# valid here, because nuget-to-nix does not generate a deps.nix
+
# containing both.
+
inherit url sha256 hash version;
+
};
+
+
nativeBuildInputs = [
+
unzip
+
patchNupkgs
+
nugetPackageHook
+
];
+
+
unpackPhase = ''
+
unzip -nq $src
+
chmod -R +rw .
+
'';
+
+
prePatch = ''
+
shopt -s nullglob
+
local dir
+
for dir in tools runtimes/*/native; do
+
[[ ! -d "$dir" ]] || chmod -R +x "$dir"
+
done
+
rm -rf .signature.p7s
+
'';
+
+
installPhase = ''
+
dir=$out/share/nuget/packages/${lib.toLower pname}/${lib.toLower version}
+
mkdir -p $dir
+
cp -r . $dir
+
echo {} > "$dir"/.nupkg.metadata
+
'';
+
+
preFixup = ''
+
patch-nupkgs $out/share/nuget/packages
+
'';
+
+
createInstallableNugetSource = installable;
+
};
+
};
+
}) // {
+
inherit sourceFile;
+
})
+4 -3
pkgs/build-support/dotnet/nuget-to-nix/nuget-to-nix.sh
···
continue
fi
-
used_source="$(jq -r '.source' "$version"/.nupkg.metadata)"
found=false
-
if [[ -d "$used_source" ]]; then
-
continue
fi
for source in "${remote_sources[@]}"; do
···
continue
fi
+
# packages in the nix store should have an empty metadata file
+
used_source="$(jq -r 'if has("source") then .source else "" end' "$version"/.nupkg.metadata)"
found=false
+
if [[ -z "$used_source" || -d "$used_source" ]]; then
+
continue
fi
for source in "${remote_sources[@]}"; do
-2
pkgs/by-name/to/torrentstream/package.nix
···
./0001-display-the-message-of-caught-exceptions.patch
];
-
postInstall = "rm $out/lib/torrentstream/NuGet.config"; # reduce closure size
-
meta = {
homepage = "https://github.com/trueromanus/TorrentStream";
description = "Simple web server for streaming torrent files in video players";
···
./0001-display-the-message-of-caught-exceptions.patch
];
meta = {
homepage = "https://github.com/trueromanus/TorrentStream";
description = "Simple web server for streaming torrent files in video players";
+5 -2
pkgs/development/compilers/dotnet/combine-packages.nix
···
dotnetPackages:
-
{ buildEnv, makeWrapper, lib }:
# TODO: Rethink how we determine and/or get the CLI.
# Possible options raised in #187118:
# 1. A separate argument for the CLI (as suggested by IvarWithoutBones
···
inherit (cli) icu;
versions = lib.catAttrs "version" dotnetPackages;
-
packages = lib.remove null (lib.catAttrs "packages" dotnetPackages);
};
inherit (cli) meta;
···
dotnetPackages:
+
{ buildEnv, makeWrapper, lib, symlinkJoin }:
# TODO: Rethink how we determine and/or get the CLI.
# Possible options raised in #187118:
# 1. A separate argument for the CLI (as suggested by IvarWithoutBones
···
inherit (cli) icu;
versions = lib.catAttrs "version" dotnetPackages;
+
packages = symlinkJoin {
+
name = "combined-packages";
+
paths = lib.remove null (lib.catAttrs "packages" dotnetPackages);
+
};
};
inherit (cli) meta;
+29 -32
pkgs/development/compilers/dotnet/common.nix
···
, swiftPackages
, darwin
, icu
}: type: args: stdenv.mkDerivation (finalAttrs: args // {
doInstallCheck = true;
···
$out/bin/dotnet --info
'';
-
# TODO: move this to sdk section?
-
setupHook = writeText "dotnet-setup-hook" (''
-
if [ ! -w "$HOME" ]; then
-
export HOME=$(mktemp -d) # Dotnet expects a writable home directory for its configuration files
-
fi
-
export DOTNET_SKIP_FIRST_TIME_EXPERIENCE=1 # Dont try to expand NuGetFallbackFolder to disk
-
export DOTNET_NOLOGO=1 # Disables the welcome message
-
export DOTNET_CLI_TELEMETRY_OPTOUT=1
-
export DOTNET_SKIP_WORKLOAD_INTEGRITY_CHECK=1 # Skip integrity check on first run, which fails due to read-only directory
-
'' + args.setupHook or "");
nativeBuildInputs = (args.nativeBuildInputs or []) ++ [ installShellFiles ];
···
}:
let
sdk = finalAttrs.finalPackage;
-
built = runCommandWith {
name = "dotnet-test-${name}";
-
inherit stdenv;
-
derivationArgs = {
-
buildInputs = [ sdk ] ++ buildInputs;
-
# make sure ICU works in a sandbox
-
propagatedSandboxProfile = toString sdk.__propagatedSandboxProfile;
-
};
-
} (''
-
HOME=$PWD/.home
-
dotnet new nugetconfig
-
dotnet nuget disable source nuget
-
'' + lib.optionalString usePackageSource ''
-
dotnet nuget add source ${sdk.packages}
-
'' + ''
-
dotnet new ${template} -n test -o .
-
'' + build);
in
if run == null
then built
···
runCommand "${built.name}-run" ({
src = built;
nativeBuildInputs = [ built ] ++ runInputs;
} // lib.optionalAttrs (stdenv.isDarwin && runAllowNetworking) {
sandboxProfile = ''
(allow network-inbound (local ip))
···
# yes, older SDKs omit the comma
[[ "$output" =~ Hello,?\ World! ]] && touch "$out"
'';
-
-
patchNupkgs = callPackage ./patch-nupkgs.nix {};
-
in {
version = testers.testVersion ({
package = finalAttrs.finalPackage;
···
template = "console";
usePackageSource = true;
buildInputs =
-
[ patchNupkgs
-
zlib
] ++ lib.optional stdenv.isDarwin (with darwin; with apple_sdk.frameworks; [
swiftPackages.swift
Foundation
···
]);
build = ''
dotnet restore -p:PublishAot=true
-
patch-nupkgs .home/.nuget/packages
dotnet publish -p:PublishAot=true -o $out/bin
'';
runtime = null;
···
, swiftPackages
, darwin
, icu
+
, lndir
+
, substituteAll
+
, nugetPackageHook
}: type: args: stdenv.mkDerivation (finalAttrs: args // {
doInstallCheck = true;
···
$out/bin/dotnet --info
'';
+
setupHooks = args.setupHooks or [] ++ [
+
./dotnet-setup-hook.sh
+
] ++ lib.optional (type == "sdk") (substituteAll {
+
src = ./dotnet-sdk-setup-hook.sh;
+
inherit lndir;
+
});
+
propagatedBuildInputs =
+
(args.propagatedBuildInputs or [])
+
++ [ nugetPackageHook ];
nativeBuildInputs = (args.nativeBuildInputs or []) ++ [ installShellFiles ];
···
}:
let
sdk = finalAttrs.finalPackage;
+
built = stdenv.mkDerivation {
name = "dotnet-test-${name}";
+
buildInputs =
+
[ sdk ]
+
++ buildInputs
+
++ lib.optional (usePackageSource) sdk.packages;
+
# make sure ICU works in a sandbox
+
propagatedSandboxProfile = toString sdk.__propagatedSandboxProfile;
+
unpackPhase = ''
+
mkdir test
+
cd test
+
dotnet new ${template} -o .
+
'';
+
buildPhase = build;
+
dontPatchELF = true;
+
};
in
if run == null
then built
···
runCommand "${built.name}-run" ({
src = built;
nativeBuildInputs = [ built ] ++ runInputs;
+
passthru = { inherit built; };
} // lib.optionalAttrs (stdenv.isDarwin && runAllowNetworking) {
sandboxProfile = ''
(allow network-inbound (local ip))
···
# yes, older SDKs omit the comma
[[ "$output" =~ Hello,?\ World! ]] && touch "$out"
'';
in {
version = testers.testVersion ({
package = finalAttrs.finalPackage;
···
template = "console";
usePackageSource = true;
buildInputs =
+
[ zlib
] ++ lib.optional stdenv.isDarwin (with darwin; with apple_sdk.frameworks; [
swiftPackages.swift
Foundation
···
]);
build = ''
dotnet restore -p:PublishAot=true
dotnet publish -p:PublishAot=true -o $out/bin
'';
runtime = null;
+52 -37
pkgs/development/compilers/dotnet/default.nix
···
Hashes and urls are retrieved from:
https://dotnet.microsoft.com/download/dotnet
*/
-
{ lib, config, callPackage, recurseIntoAttrs }:
-
let
-
buildDotnet = attrs: callPackage (import ./build-dotnet.nix attrs) {};
-
buildAttrs = {
-
buildAspNetCore = attrs: buildDotnet (attrs // { type = "aspnetcore"; });
-
buildNetRuntime = attrs: buildDotnet (attrs // { type = "runtime"; });
-
buildNetSdk = attrs: buildDotnet (attrs // { type = "sdk"; });
-
};
-
## Files in versions/ are generated automatically by update.sh ##
-
dotnet_6_0 = import ./versions/6.0.nix buildAttrs;
-
dotnet_7_0 = import ./versions/7.0.nix buildAttrs;
-
dotnet_8_0 = import ./versions/8.0.nix buildAttrs;
-
dotnet_9_0 = import ./versions/9.0.nix buildAttrs;
-
runtimeIdentifierMap = {
-
"x86_64-linux" = "linux-x64";
-
"aarch64-linux" = "linux-arm64";
-
"x86_64-darwin" = "osx-x64";
-
"aarch64-darwin" = "osx-arm64";
-
"x86_64-windows" = "win-x64";
-
"i686-windows" = "win-x86";
-
};
-
# Convert a "stdenv.hostPlatform.system" to a dotnet RID
-
systemToDotnetRid = system: runtimeIdentifierMap.${system} or (throw "unsupported platform ${system}");
-
in
-
{
-
inherit systemToDotnetRid;
-
combinePackages = attrs: callPackage (import ./combine-packages.nix attrs) {};
-
dotnet_8 = recurseIntoAttrs (callPackage ./8 { bootstrapSdk = dotnet_8_0.sdk_8_0_1xx; });
-
dotnet_9 = recurseIntoAttrs (callPackage ./9 {});
-
} // lib.optionalAttrs config.allowAliases {
-
# EOL
-
sdk_2_1 = throw "Dotnet SDK 2.1 is EOL, please use 6.0 (LTS) or 7.0 (Current)";
-
sdk_2_2 = throw "Dotnet SDK 2.2 is EOL, please use 6.0 (LTS) or 7.0 (Current)";
-
sdk_3_0 = throw "Dotnet SDK 3.0 is EOL, please use 6.0 (LTS) or 7.0 (Current)";
-
sdk_3_1 = throw "Dotnet SDK 3.1 is EOL, please use 6.0 (LTS) or 7.0 (Current)";
-
sdk_5_0 = throw "Dotnet SDK 5.0 is EOL, please use 6.0 (LTS) or 7.0 (Current)";
-
} // dotnet_6_0 // dotnet_7_0 // dotnet_8_0 // dotnet_9_0
···
Hashes and urls are retrieved from:
https://dotnet.microsoft.com/download/dotnet
*/
+
{ lib
+
, config
+
, recurseIntoAttrs
+
, generateSplicesForMkScope
+
, makeScopeWithSplicing'
+
}:
+
+
makeScopeWithSplicing' {
+
otherSplices = generateSplicesForMkScope "dotnetCorePackages";
+
f = (self:
+
let
+
callPackage = self.callPackage;
+
+
buildDotnet = attrs: callPackage (import ./build-dotnet.nix attrs) {};
+
buildAttrs = {
+
buildAspNetCore = attrs: buildDotnet (attrs // { type = "aspnetcore"; });
+
buildNetRuntime = attrs: buildDotnet (attrs // { type = "runtime"; });
+
buildNetSdk = attrs: buildDotnet (attrs // { type = "sdk"; });
+
};
+
+
## Files in versions/ are generated automatically by update.sh ##
+
dotnet_6_0 = import ./versions/6.0.nix buildAttrs;
+
dotnet_7_0 = import ./versions/7.0.nix buildAttrs;
+
dotnet_8_0 = import ./versions/8.0.nix buildAttrs;
+
dotnet_9_0 = import ./versions/9.0.nix buildAttrs;
+
runtimeIdentifierMap = {
+
"x86_64-linux" = "linux-x64";
+
"aarch64-linux" = "linux-arm64";
+
"x86_64-darwin" = "osx-x64";
+
"aarch64-darwin" = "osx-arm64";
+
"x86_64-windows" = "win-x64";
+
"i686-windows" = "win-x86";
+
};
+
+
in {
+
inherit callPackage;
+
# Convert a "stdenv.hostPlatform.system" to a dotnet RID
+
systemToDotnetRid = system: runtimeIdentifierMap.${system} or (throw "unsupported platform ${system}");
+
combinePackages = attrs: callPackage (import ./combine-packages.nix attrs) {};
+
patchNupkgs = callPackage ./patch-nupkgs.nix {};
+
nugetPackageHook = callPackage ./nuget-package-hook.nix {};
+
dotnet_8 = recurseIntoAttrs (callPackage ./8 { bootstrapSdk = dotnet_8_0.sdk_8_0_1xx; });
+
dotnet_9 = recurseIntoAttrs (callPackage ./9 {});
+
} // lib.optionalAttrs config.allowAliases {
+
# EOL
+
sdk_2_1 = throw "Dotnet SDK 2.1 is EOL, please use 6.0 (LTS) or 7.0 (Current)";
+
sdk_2_2 = throw "Dotnet SDK 2.2 is EOL, please use 6.0 (LTS) or 7.0 (Current)";
+
sdk_3_0 = throw "Dotnet SDK 3.0 is EOL, please use 6.0 (LTS) or 7.0 (Current)";
+
sdk_3_1 = throw "Dotnet SDK 3.1 is EOL, please use 6.0 (LTS) or 7.0 (Current)";
+
sdk_5_0 = throw "Dotnet SDK 5.0 is EOL, please use 6.0 (LTS) or 7.0 (Current)";
+
} // dotnet_6_0 // dotnet_7_0 // dotnet_8_0 // dotnet_9_0);
+
}
+77
pkgs/development/compilers/dotnet/dotnet-sdk-setup-hook.sh
···
···
+
# shellcheck shell=bash disable=SC2154
+
export MSBUILDALWAYSOVERWRITEREADONLYFILES=1
+
+
declare -Ag _nugetInputs
+
+
addNugetInputs() {
+
if [[ -d "$1/share/nuget" ]]; then
+
_nugetInputs[$1]=1
+
fi
+
}
+
+
addEnvHooks "$targetOffset" addNugetInputs
+
+
_linkPackages() {
+
local -r src="$1"
+
local -r dest="$2"
+
local dir
+
+
for x in "$src"/*/*; do
+
dir=$dest/$(basename "$(dirname "$x")")
+
mkdir -p "$dir"
+
ln -s "$x" "$dir"/
+
done
+
}
+
+
createNugetDirs() {
+
nugetTemp=$PWD/.nuget-temp
+
export NUGET_PACKAGES=$nugetTemp/packages
+
nugetSource=$nugetTemp/source
+
mkdir -p "$NUGET_PACKAGES" "$nugetSource"
+
+
dotnet new nugetconfig
+
if [[ -z ${keepNugetConfig-} ]]; then
+
dotnet nuget disable source nuget
+
fi
+
+
dotnet nuget add source "$nugetSource" -n _nix
+
}
+
+
configureNuget() {
+
for x in "${!_nugetInputs[@]}"; do
+
if [[ -d $x/share/nuget/packages ]]; then
+
addToSearchPathWithCustomDelimiter ";" NUGET_FALLBACK_PACKAGES "$x/share/nuget/packages"
+
fi
+
+
if [[ -d $x/share/nuget/source ]]; then
+
_linkPackages "$x/share/nuget/source" "$nugetSource"
+
fi
+
done
+
+
if [[ -n "${linkNugetPackages-}"
+
|| -f .config/dotnet-tools.json
+
|| -f dotnet-tools.json
+
|| -f paket.dependencies ]]; then
+
for x in "${!_nugetInputs[@]}"; do
+
if [[ -d $x/share/nuget/packages ]]; then
+
@lndir@/bin/lndir -silent "$x/share/nuget/packages" "$NUGET_PACKAGES"
+
fi
+
done
+
fi
+
+
if [[ -f paket.dependencies ]]; then
+
sed -i "s:source .*:source $nugetSource:" paket.dependencies
+
sed -i "s:remote\:.*:remote\: $nugetSource:" paket.lock
+
+
for x in "${!_nugetInputs[@]}"; do
+
if [[ -d $x/share/nuget/source ]]; then
+
@lndir@/bin/lndir -silent "$x/share/nuget/source" "$NUGET_PACKAGES"
+
fi
+
done
+
fi
+
}
+
+
if [[ -z ${dontConfigureNuget-} ]]; then
+
prePhases+=(createNugetDirs)
+
preConfigurePhases+=(configureNuget)
+
fi
+8
pkgs/development/compilers/dotnet/dotnet-setup-hook.sh
···
···
+
if [ ! -w "$HOME" ]; then
+
export HOME=$(mktemp -d) # Dotnet expects a writable home directory for its configuration files
+
fi
+
+
export DOTNET_SKIP_FIRST_TIME_EXPERIENCE=1 # Dont try to expand NuGetFallbackFolder to disk
+
export DOTNET_NOLOGO=1 # Disables the welcome message
+
export DOTNET_CLI_TELEMETRY_OPTOUT=1
+
export DOTNET_SKIP_WORKLOAD_INTEGRITY_CHECK=1 # Skip integrity check on first run, which fails due to read-only directory
-1
pkgs/development/compilers/dotnet/dotnet.nix
···
installPhase = ''
mkdir -p $out
cp -r * $out/
-
ln -fs ${old.passthru.packages}/* $out/
'';
};
};
···
installPhase = ''
mkdir -p $out
cp -r * $out/
'';
};
};
+12
pkgs/development/compilers/dotnet/nuget-package-hook.nix
···
···
+
{
+
makeSetupHook,
+
zip,
+
strip-nondeterminism,
+
}:
+
makeSetupHook {
+
name = "nuget-package-hook";
+
substitutions = {
+
inherit zip;
+
stripNondeterminism = strip-nondeterminism;
+
};
+
} ./nuget-package-hook.sh
+38
pkgs/development/compilers/dotnet/nuget-package-hook.sh
···
···
+
# shellcheck shell=bash disable=SC2154
+
+
_createNugetSourceInOutput() {
+
local package version id dir nupkg content
+
local -a nuspec
+
shopt -s nullglob
+
+
for package in "$prefix"/share/nuget/packages/*/*; do
+
version=$(basename "$package")
+
id=$(basename "$(dirname "$package")")
+
dir="$prefix/share/nuget/source/$id/$version"
+
nupkg=$dir/$id.$version.nupkg
+
nuspec=("$package"/*.nuspec)
+
+
if [[ -n ${createInstallableNugetSource-} ]]; then
+
content=.
+
else
+
content=$(basename "${nuspec[0]}")
+
fi
+
+
mkdir -p "$dir"
+
cp "${nuspec[0]}" "$dir/$id.nuspec"
+
(cd "$package" && @zip@/bin/zip -rq0 "$nupkg" "$content")
+
@stripNondeterminism@/bin/strip-nondeterminism --type zip "$nupkg"
+
touch "$nupkg".sha512
+
done
+
}
+
+
createNugetSource() {
+
local output
+
for output in $(getAllOutputNames); do
+
prefix="${!output}" _createNugetSourceInOutput
+
done
+
}
+
+
if [[ -z ${dontCreateNugetSource-} ]]; then
+
postFixupHooks+=(createNugetSource)
+
fi
+49 -4
pkgs/development/compilers/dotnet/packages.nix
···
{ stdenv
, callPackage
, vmr
}:
let
···
src = vmr;
dontUnpack = true;
outputs = [ "out" "packages" "artifacts" ];
installPhase = ''
···
mkdir "$out"/bin
ln -s "$out"/dotnet "$out"/bin/dotnet
-
mkdir "$packages"
-
# this roughly corresponds to the {sdk,aspnetcore}_packages in ../update.sh
-
cp -r "$src"/Private.SourceBuilt.Artifacts.*.${targetRid}/*Microsoft.{NET.ILLink.Tasks,NETCore,DotNet,AspNetCore}.*.nupkg "$packages"
-
cp -r "$src"/Private.SourceBuilt.Artifacts.*.${targetRid} "$artifacts"
runHook postInstall
'';
···
{ stdenv
, callPackage
, vmr
+
, xmlstarlet
+
, strip-nondeterminism
+
, zip
}:
let
···
src = vmr;
dontUnpack = true;
+
nativeBuildInputs = [
+
xmlstarlet
+
strip-nondeterminism
+
zip
+
];
+
outputs = [ "out" "packages" "artifacts" ];
installPhase = ''
···
mkdir "$out"/bin
ln -s "$out"/dotnet "$out"/bin/dotnet
+
mkdir -p "$packages" "$artifacts"
+
cp -r "$src"/Private.SourceBuilt.Artifacts.*.${targetRid}/* "$artifacts"/
+
chmod +w -R "$artifacts"
+
+
local package
+
+
for package in "$artifacts"/*.nupkg; do
+
local copy
+
case "$(basename "$package")" in
+
*Microsoft.NET.* | \
+
*Microsoft.ILLink.* | \
+
*Microsoft.Tasks.* | \
+
*Microsoft.NETCore.* | \
+
*Microsoft.DotNet.* | \
+
*Microsoft.AspNetCore.*) copy=1 ;;
+
*) copy= ;;
+
esac
+
if [[ -n $copy ]]; then
+
echo copying "$package" to packages
+
xmlstarlet \
+
sel -t \
+
-m /_:package/_:metadata \
+
-v _:id -nl \
+
-v _:version -nl \
+
"$package"/*.nuspec \
+
| tr A-Z a-z | (
+
read id
+
read version
+
mkdir -p "$packages"/share/nuget/packages/"$id"
+
cp -r "$package" "$packages"/share/nuget/packages/"$id"/"$version"
+
)
+
fi
+
done
+
for package in "$artifacts"/{,SourceBuildReferencePackages/}*.nupkg; do
+
echo packing "$package" to artifacts
+
(cd "$package" && zip -rq0 "$package.tmp" .)
+
strip-nondeterminism --type zip "$package.tmp"
+
rm -r "$package"
+
mv "$package.tmp" "$package"
+
done
runHook postInstall
'';
+5 -10
pkgs/development/compilers/dotnet/patch-nupkgs.nix
···
{ stdenv
, lib
-
, dotnetCorePackages
, zlib
, curl
, icu
···
}:
let
-
buildRid = dotnetCorePackages.systemToDotnetRid stdenv.buildPlatform.system;
-
binaryRPath = lib.makeLibraryPath ([
stdenv.cc.cc
zlib
···
if [ "$magic" = $'\177ELF' ]; then return 0; else return 1; fi
}
cd "$1"
-
for x in *.${buildRid}/* *.${buildRid}.*/*; do
# .nupkg.metadata is written last, so we know the packages is complete
[[ -d "$x" ]] && [[ -f "$x"/.nupkg.metadata ]] \
&& [[ ! -f "$x"/.nix-patched ]] || continue
echo "Patching package $x"
-
pushd "$x"
-
for p in $(find -type f); do
if [[ "$p" != *.nix-patched ]] \
&& isELF "$p" \
&& patchelf --print-interpreter "$p" &>/dev/null; then
···
mv "$tmp" "$p"
fi
done
-
touch .nix-patched
-
popd
done
'' + lib.optionalString stdenv.isDarwin ''
for x in microsoft.dotnet.ilcompiler/*; do
# .nupkg.metadata is written last, so we know the packages is complete
[[ -d "$x" ]] && [[ -f "$x"/.nupkg.metadata ]] \
-
&& [[ ! -f "$x"/.nix-patched ]] || continue
echo "Patching package $x"
pushd "$x"
sed -i 's: -no_code_signature_warning::g' build/Microsoft.NETCore.Native.targets
sed -i 's:Include="-ld_classic"::g' build/Microsoft.NETCore.Native.Unix.targets
-
touch .nix-patched
popd
done
'')
···
{ stdenv
, lib
, zlib
, curl
, icu
···
}:
let
binaryRPath = lib.makeLibraryPath ([
stdenv.cc.cc
zlib
···
if [ "$magic" = $'\177ELF' ]; then return 0; else return 1; fi
}
cd "$1"
+
for x in */* */*; do
# .nupkg.metadata is written last, so we know the packages is complete
[[ -d "$x" ]] && [[ -f "$x"/.nupkg.metadata ]] \
&& [[ ! -f "$x"/.nix-patched ]] || continue
echo "Patching package $x"
+
find "$x" -type f -print0 | while IFS= read -rd "" p; do
if [[ "$p" != *.nix-patched ]] \
&& isELF "$p" \
&& patchelf --print-interpreter "$p" &>/dev/null; then
···
mv "$tmp" "$p"
fi
done
+
touch "$x"/.nix-patched
done
'' + lib.optionalString stdenv.isDarwin ''
for x in microsoft.dotnet.ilcompiler/*; do
# .nupkg.metadata is written last, so we know the packages is complete
[[ -d "$x" ]] && [[ -f "$x"/.nupkg.metadata ]] \
+
&& [[ ! -f "$x"/.nix-patched-ilcompiler ]] || continue
echo "Patching package $x"
pushd "$x"
sed -i 's: -no_code_signature_warning::g' build/Microsoft.NETCore.Native.targets
sed -i 's:Include="-ld_classic"::g' build/Microsoft.NETCore.Native.Unix.targets
+
touch .nix-patched-ilcompiler
popd
done
'')
+10 -5
pkgs/development/compilers/dotnet/stage0.nix
···
, callPackage
, lib
, writeShellScript
-
, pkgsBuildHost
, mkNugetDeps
, nix
, cacert
, nuget-to-nix
, dotnetCorePackages
, xmlstarlet
, releaseManifestFile
, tarballHash
···
mkPackages = callPackage ./packages.nix;
mkVMR = callPackage ./vmr.nix;
-
dotnetSdk = pkgsBuildHost.callPackage bootstrapSdk {};
-
-
patchNupkgs = pkgsBuildHost.callPackage ./patch-nupkgs.nix {};
deps = mkNugetDeps {
name = "dotnet-vmr-deps";
sourceFile = depsFile;
};
vmr = (mkVMR {
inherit releaseManifestFile tarballHash dotnetSdk;
}).overrideAttrs (old: rec {
prebuiltPackages = mkNugetDeps {
name = "dotnet-vmr-deps";
sourceFile = depsFile;
};
nativeBuildInputs =
···
'';
postConfigure = old.postConfigure or "" + ''
-
[[ ! -v prebuiltPackages ]] || ln -sf "$prebuiltPackages"/* prereqs/packages/prebuilt/
'';
buildFlags =
···
, callPackage
, lib
, writeShellScript
, mkNugetDeps
, nix
, cacert
, nuget-to-nix
, dotnetCorePackages
, xmlstarlet
+
, patchNupkgs
, releaseManifestFile
, tarballHash
···
mkPackages = callPackage ./packages.nix;
mkVMR = callPackage ./vmr.nix;
+
dotnetSdk = callPackage bootstrapSdk {};
deps = mkNugetDeps {
name = "dotnet-vmr-deps";
sourceFile = depsFile;
};
+
sdkPackages = dotnetSdk.packages.override {
+
installable = true;
+
};
+
vmr = (mkVMR {
inherit releaseManifestFile tarballHash dotnetSdk;
}).overrideAttrs (old: rec {
prebuiltPackages = mkNugetDeps {
name = "dotnet-vmr-deps";
sourceFile = depsFile;
+
installable = true;
};
nativeBuildInputs =
···
'';
postConfigure = old.postConfigure or "" + ''
+
[[ ! -v prebuiltPackages ]] || \
+
ln -sf "$prebuiltPackages"/share/nuget/source/*/*/*.nupkg prereqs/packages/prebuilt/
+
ln -sf "${sdkPackages}"/share/nuget/source/*/*/*.nupkg prereqs/packages/prebuilt/
'';
buildFlags =
+1 -2
pkgs/development/compilers/dotnet/stage1.nix
···
{ stdenv
, lib
, callPackage
-
, pkgsBuildHost
, releaseManifestFile
, tarballHash
···
mkPackages = callPackage ./packages.nix;
mkVMR = callPackage ./vmr.nix;
-
stage0 = pkgsBuildHost.callPackage ./stage0.nix args;
vmr = (mkVMR {
inherit releaseManifestFile tarballHash;
···
{ stdenv
, lib
, callPackage
, releaseManifestFile
, tarballHash
···
mkPackages = callPackage ./packages.nix;
mkVMR = callPackage ./vmr.nix;
+
stage0 = callPackage ./stage0.nix args;
vmr = (mkVMR {
inherit releaseManifestFile tarballHash;
+21 -1
pkgs/development/compilers/dotnet/vmr.nix
···
, xmlstarlet
, nodejs
, callPackage
, dotnetSdk
, releaseManifestFile
···
pkg-config
python3
xmlstarlet
]
++ lib.optionals (lib.versionAtLeast version "9") [
nodejs
···
typeset -f isScript patchShebangs > src/aspnetcore/patch-shebangs.sh
'';
dontUseCmakeConfigure = true;
# https://github.com/NixOS/nixpkgs/issues/38991
···
done
popd
runHook postInstall
'';
···
stripDebugList = [ "." ];
# stripping dlls results in:
# Failed to load System.Private.CoreLib.dll (error code 0x8007000B)
-
stripExclude = [ "*.dll" ];
passthru = {
inherit releaseManifest buildRid targetRid;
···
, xmlstarlet
, nodejs
, callPackage
+
, unzip
+
, yq
, dotnetSdk
, releaseManifestFile
···
pkg-config
python3
xmlstarlet
+
unzip
+
yq
]
++ lib.optionals (lib.versionAtLeast version "9") [
nodejs
···
typeset -f isScript patchShebangs > src/aspnetcore/patch-shebangs.sh
'';
+
dontConfigureNuget = true; # NUGET_PACKAGES breaks the build
dontUseCmakeConfigure = true;
# https://github.com/NixOS/nixpkgs/issues/38991
···
done
popd
+
local -r unpacked="$PWD/.unpacked"
+
for nupkg in $out/Private.SourceBuilt.Artifacts.*.${targetRid}/{,SourceBuildReferencePackages/}*.nupkg; do
+
rm -rf "$unpacked"
+
unzip -qd "$unpacked" "$nupkg"
+
chmod -R +rw "$unpacked"
+
rm "$nupkg"
+
mv "$unpacked" "$nupkg"
+
# TODO: should we fix executable flags here? see dotnetInstallHook
+
done
+
runHook postInstall
'';
···
stripDebugList = [ "." ];
# stripping dlls results in:
# Failed to load System.Private.CoreLib.dll (error code 0x8007000B)
+
# stripped crossgen2 results in:
+
# Failure processing application bundle; possible file corruption.
+
# this needs to be a bash array
+
preFixup = ''
+
stripExclude=(\*.dll crossgen2)
+
'';
passthru = {
inherit releaseManifest buildRid targetRid;
+7 -4
pkgs/development/python-modules/clr-loader/default.nix
···
format = "pyproject";
nativeBuildInputs = [
setuptools
setuptools-scm
···
preConfigure = ''
dotnet restore "netfx_loader/ClrLoader.csproj" \
-p:ContinuousIntegrationBuild=true \
-
-p:Deterministic=true \
-
--source "${dotnet-build.nuget-source}"
dotnet restore "example/example.csproj" \
-p:ContinuousIntegrationBuild=true \
-
-p:Deterministic=true \
-
--source "${dotnet-build.nuget-source}"
'';
passthru.fetch-deps = dotnet-build.fetch-deps;
···
format = "pyproject";
+
buildInputs = [
+
dotnetCorePackages.sdk_6_0.packages
+
dotnet-build.nugetDeps
+
];
+
nativeBuildInputs = [
setuptools
setuptools-scm
···
preConfigure = ''
dotnet restore "netfx_loader/ClrLoader.csproj" \
-p:ContinuousIntegrationBuild=true \
+
-p:Deterministic=true
dotnet restore "example/example.csproj" \
-p:ContinuousIntegrationBuild=true \
+
-p:Deterministic=true
'';
passthru.fetch-deps = dotnet-build.fetch-deps;
+3 -1
pkgs/development/python-modules/pythonnet/default.nix
···
--replace 'dynamic = ["version"]' 'version = "${version}"'
'';
nativeBuildInputs = [
setuptools
dotnet-sdk
···
dotnet restore \
-p:ContinuousIntegrationBuild=true \
-p:Deterministic=true \
-
--source ${dotnet-build.nuget-source}
'';
# Rerun this when updating to refresh Nuget dependencies
···
--replace 'dynamic = ["version"]' 'version = "${version}"'
'';
+
buildInputs = [ dotnet-build.nugetDeps ];
+
nativeBuildInputs = [
setuptools
dotnet-sdk
···
dotnet restore \
-p:ContinuousIntegrationBuild=true \
-p:Deterministic=true \
+
--source "$nugetSource"
'';
# Rerun this when updating to refresh Nuget dependencies
+1
pkgs/development/tools/build-managers/msbuild/default.nix
···
'';
buildPhase = ''
# nuget would otherwise try to base itself in /homeless-shelter
export HOME=$(pwd)/fake-home
···
'';
buildPhase = ''
+
unset NUGET_PACKAGES
# nuget would otherwise try to base itself in /homeless-shelter
export HOME=$(pwd)/fake-home
-14
pkgs/development/tools/fsautocomplete/deps.nix
···
(fetchNuGet { pname = "McMaster.NETCore.Plugins"; version = "1.4.0"; hash = "sha256-PtpD8S74UXyoA80YRDlrp8qR/I7Ws7+4m2EJZzH4WMw="; })
(fetchNuGet { pname = "MessagePack"; version = "2.5.108"; hash = "sha256-+vMXyEbfutY5WOFuFnNF24uLcKJTTdntVrVlSJH4yjI="; })
(fetchNuGet { pname = "MessagePack.Annotations"; version = "2.5.108"; hash = "sha256-u3Qu8UftNIz3oIzQUMa7Z0G6VzmDLcAnAeNQ3lB3YVk="; })
-
(fetchNuGet { pname = "Microsoft.AspNetCore.App.Ref"; version = "6.0.32"; hash = "sha256-1mQTxwruzhm20YdlZefrYuy7xrBs17pH4Vo0K3Tl7Fc="; })
-
(fetchNuGet { pname = "Microsoft.AspNetCore.App.Runtime.linux-arm64"; version = "6.0.32"; hash = "sha256-cIe0F+7rgwYSmh0VuFuQsUI9iEW5hn2KCD2H8Cs/k2g="; })
-
(fetchNuGet { pname = "Microsoft.AspNetCore.App.Runtime.linux-x64"; version = "6.0.32"; hash = "sha256-TkYv7h9NBr3I+FIaXeLU4MawJtgT2RWhs35ewGRDKx8="; })
-
(fetchNuGet { pname = "Microsoft.AspNetCore.App.Runtime.osx-arm64"; version = "6.0.32"; hash = "sha256-RaC37ZQcJn7ykXJrtV7ibxh0GcalRyPKncxlqOLou+I="; })
-
(fetchNuGet { pname = "Microsoft.AspNetCore.App.Runtime.osx-x64"; version = "6.0.32"; hash = "sha256-vh/e46xM/HbhbBvL5eP5/DCHwCP2Bg7WoMS28nBXWV0="; })
(fetchNuGet { pname = "Microsoft.Bcl.AsyncInterfaces"; version = "7.0.0"; hash = "sha256-1e031E26iraIqun84ad0fCIR4MJZ1hcQo4yFN+B7UfE="; })
(fetchNuGet { pname = "Microsoft.Bcl.HashCode"; version = "1.1.0"; hash = "sha256-IFvXCMV2joahytylQ2BGSpZd2tdX0Rss++ZcClVT+r0="; })
(fetchNuGet { pname = "Microsoft.Build"; version = "17.2.0"; hash = "sha256-JzPqbxFyotNhSr5tokVevdqB9+nJKx4YH2hPkC05GiY="; })
···
(fetchNuGet { pname = "Microsoft.Extensions.Primitives"; version = "6.0.0"; hash = "sha256-AgvysszpQ11AiTBJFkvSy8JnwIWTj15Pfek7T7ThUc4="; })
(fetchNuGet { pname = "Microsoft.NET.StringTools"; version = "17.4.0"; hash = "sha256-+9uBaUDZ3roUJwyYJUL30Mz+3C6LE16FzfQKgS0Yveo="; })
(fetchNuGet { pname = "Microsoft.NET.Test.Sdk"; version = "17.4.1"; hash = "sha256-Kl8ZAWCMFZcYEfPDr/YG4zfQEuEzlOuhWI40Zl2S4Qo="; })
-
(fetchNuGet { pname = "Microsoft.NETCore.App.Host.linux-arm64"; version = "6.0.32"; hash = "sha256-yDOkSHEGuGG6u+rB5u+IC3rc2tQwvbjdqmgHcl7Gkn4="; })
-
(fetchNuGet { pname = "Microsoft.NETCore.App.Host.linux-x64"; version = "6.0.32"; hash = "sha256-2aDGkn0QqXXHUUSAwtQQbjKl5I6S0fcQWPciqPnOiM4="; })
-
(fetchNuGet { pname = "Microsoft.NETCore.App.Host.osx-arm64"; version = "6.0.32"; hash = "sha256-n6hks4j88TRelq1O6SCeUH5GmxoSm5BWXGwnpnYJibI="; })
-
(fetchNuGet { pname = "Microsoft.NETCore.App.Host.osx-x64"; version = "6.0.32"; hash = "sha256-nBBq4RYAgimBYOn/bN6JTFvJFYaqYXMHae2pmCzRaS8="; })
-
(fetchNuGet { pname = "Microsoft.NETCore.App.Ref"; version = "6.0.32"; hash = "sha256-Fm3RUZNcro434rIu3c7unGviGeGBjXj2dGnr2mmrM2g="; })
-
(fetchNuGet { pname = "Microsoft.NETCore.App.Runtime.linux-arm64"; version = "6.0.32"; hash = "sha256-kdj8ia/2du2oKGg4MJdO2XytpT3gQ9UOiHVCyfiX2V8="; })
-
(fetchNuGet { pname = "Microsoft.NETCore.App.Runtime.linux-x64"; version = "6.0.32"; hash = "sha256-/Hti30Ba12NDJQcG8pFTg6REVUDIrxZ/hRtEZNDlgxE="; })
-
(fetchNuGet { pname = "Microsoft.NETCore.App.Runtime.osx-arm64"; version = "6.0.32"; hash = "sha256-A8MFGOMXFROH1QGUE7xzq5b5EskDyIQCQt7SLfGdSbU="; })
-
(fetchNuGet { pname = "Microsoft.NETCore.App.Runtime.osx-x64"; version = "6.0.32"; hash = "sha256-y5YB62WlMrK10bR/+nNpI8luVRlD9W9ZG3GsX7AXzUM="; })
(fetchNuGet { pname = "Microsoft.NETCore.Platforms"; version = "1.1.1"; hash = "sha256-8hLiUKvy/YirCWlFwzdejD2Db3DaXhHxT7GSZx/znJg="; })
(fetchNuGet { pname = "Microsoft.NETCore.Targets"; version = "1.1.3"; hash = "sha256-WLsf1NuUfRWyr7C7Rl9jiua9jximnVvzy6nk2D2bVRc="; })
(fetchNuGet { pname = "Microsoft.NETFramework.ReferenceAssemblies"; version = "1.0.3"; hash = "sha256-FBoJP5DHZF0QHM0xLm9yd4HJZVQOuSpSKA+VQRpphEE="; })
···
(fetchNuGet { pname = "McMaster.NETCore.Plugins"; version = "1.4.0"; hash = "sha256-PtpD8S74UXyoA80YRDlrp8qR/I7Ws7+4m2EJZzH4WMw="; })
(fetchNuGet { pname = "MessagePack"; version = "2.5.108"; hash = "sha256-+vMXyEbfutY5WOFuFnNF24uLcKJTTdntVrVlSJH4yjI="; })
(fetchNuGet { pname = "MessagePack.Annotations"; version = "2.5.108"; hash = "sha256-u3Qu8UftNIz3oIzQUMa7Z0G6VzmDLcAnAeNQ3lB3YVk="; })
(fetchNuGet { pname = "Microsoft.Bcl.AsyncInterfaces"; version = "7.0.0"; hash = "sha256-1e031E26iraIqun84ad0fCIR4MJZ1hcQo4yFN+B7UfE="; })
(fetchNuGet { pname = "Microsoft.Bcl.HashCode"; version = "1.1.0"; hash = "sha256-IFvXCMV2joahytylQ2BGSpZd2tdX0Rss++ZcClVT+r0="; })
(fetchNuGet { pname = "Microsoft.Build"; version = "17.2.0"; hash = "sha256-JzPqbxFyotNhSr5tokVevdqB9+nJKx4YH2hPkC05GiY="; })
···
(fetchNuGet { pname = "Microsoft.Extensions.Primitives"; version = "6.0.0"; hash = "sha256-AgvysszpQ11AiTBJFkvSy8JnwIWTj15Pfek7T7ThUc4="; })
(fetchNuGet { pname = "Microsoft.NET.StringTools"; version = "17.4.0"; hash = "sha256-+9uBaUDZ3roUJwyYJUL30Mz+3C6LE16FzfQKgS0Yveo="; })
(fetchNuGet { pname = "Microsoft.NET.Test.Sdk"; version = "17.4.1"; hash = "sha256-Kl8ZAWCMFZcYEfPDr/YG4zfQEuEzlOuhWI40Zl2S4Qo="; })
(fetchNuGet { pname = "Microsoft.NETCore.Platforms"; version = "1.1.1"; hash = "sha256-8hLiUKvy/YirCWlFwzdejD2Db3DaXhHxT7GSZx/znJg="; })
(fetchNuGet { pname = "Microsoft.NETCore.Targets"; version = "1.1.3"; hash = "sha256-WLsf1NuUfRWyr7C7Rl9jiua9jximnVvzy6nk2D2bVRc="; })
(fetchNuGet { pname = "Microsoft.NETFramework.ReferenceAssemblies"; version = "1.0.3"; hash = "sha256-FBoJP5DHZF0QHM0xLm9yd4HJZVQOuSpSKA+VQRpphEE="; })
+3 -27
pkgs/development/tools/godot/3/mono/default.nix
···
{ godot3
, callPackage
, mkNugetDeps
-
, mkNugetSource
, mono
, dotnet-sdk
-
, writeText
, scons
, python311Packages
}:
···
glue = callPackage ./glue.nix {};
-
nugetDeps = mkNugetDeps { name = "deps"; nugetDeps = import ./deps.nix; };
-
-
nugetSource =
-
mkNugetSource {
-
name = "${self.pname}-nuget-source";
-
description = "Nuget source with dependencies for ${self.pname}";
-
deps = [ self.nugetDeps ];
-
};
-
-
nugetConfig = writeText "NuGet.Config" ''
-
<?xml version="1.0" encoding="utf-8"?>
-
<configuration>
-
<packageSources>
-
<add key="${self.pname}-deps" value="${self.nugetSource}/lib" />
-
</packageSources>
-
</configuration>
-
'';
sconsFlags = base.sconsFlags ++ [
"module_mono_enabled=true"
"mono_prefix=${mono}"
];
-
shouldConfigureNuget = true;
-
postConfigure = ''
echo "Setting up buildhome."
mkdir buildhome
···
echo "Overlaying godot glue."
cp -R --no-preserve=mode "$glue"/. .
-
-
if [ -n "$shouldConfigureNuget" ]; then
-
echo "Configuring NuGet."
-
mkdir -p ~/.nuget/NuGet
-
ln -s "$nugetConfig" ~/.nuget/NuGet/NuGet.Config
-
fi
'';
installedGodotShortcutFileName = "org.godotengine.GodotMono3.desktop";
···
{ godot3
, callPackage
, mkNugetDeps
, mono
, dotnet-sdk
, scons
, python311Packages
}:
···
glue = callPackage ./glue.nix {};
+
buildInputs = base.buildInputs ++ [
+
(mkNugetDeps { name = "deps"; nugetDeps = import ./deps.nix; })
+
];
sconsFlags = base.sconsFlags ++ [
"module_mono_enabled=true"
"mono_prefix=${mono}"
];
postConfigure = ''
echo "Setting up buildhome."
mkdir buildhome
···
echo "Overlaying godot glue."
cp -R --no-preserve=mode "$glue"/. .
'';
installedGodotShortcutFileName = "org.godotengine.GodotMono3.desktop";
+1 -1
pkgs/development/tools/godot/3/mono/make-deps.nix
···
nugetSource = null;
nugetConfig = null;
-
shouldConfigureNuget = false;
outputs = [ "out" ];
buildPhase = " ";
···
nugetSource = null;
nugetConfig = null;
+
keepNugetConfig = true;
outputs = [ "out" ];
buildPhase = " ";
+3
pkgs/development/tools/ilspycmd/default.nix
···
projectFile = "ICSharpCode.ILSpyCmd/ICSharpCode.ILSpyCmd.csproj";
nugetDeps = ./deps.nix;
meta = with lib; {
description = "Tool for decompiling .NET assemblies and generating portable PDBs";
mainProgram = "ilspycmd";
···
projectFile = "ICSharpCode.ILSpyCmd/ICSharpCode.ILSpyCmd.csproj";
nugetDeps = ./deps.nix;
+
# see: https://github.com/tunnelvisionlabs/ReferenceAssemblyAnnotator/issues/94
+
linkNugetPackages = true;
+
meta = with lib; {
description = "Tool for decompiling .NET assemblies and generating portable PDBs";
mainProgram = "ilspycmd";
-7
pkgs/servers/nosql/eventstore/default.nix
···
"EventStore.Projections.Core.Tests.Services.grpc_service.ServerFeaturesTests<LogFormat+V3,UInt32>.should_receive_expected_endpoints"
];
-
postConfigure = ''
-
# Fixes git execution by GitInfo on mac os
-
substituteInPlace "$HOME/.nuget/packages/gitinfo/2.0.26/build/GitInfo.targets" \
-
--replace "<GitExe Condition=\"Exists('/usr/bin/git')\">/usr/bin/git</GitExe>" " " \
-
--replace "<GitExe Condition=\"Exists('/usr/local/bin/git')\">/usr/local/bin/git</GitExe>" ""
-
'';
-
nugetDeps = ./deps.nix;
projectFile = "src/EventStore.ClusterNode/EventStore.ClusterNode.csproj";
···
"EventStore.Projections.Core.Tests.Services.grpc_service.ServerFeaturesTests<LogFormat+V3,UInt32>.should_receive_expected_endpoints"
];
nugetDeps = ./deps.nix;
projectFile = "src/EventStore.ClusterNode/EventStore.ClusterNode.csproj";
+1 -1
pkgs/top-level/all-packages.nix
···
buildDotnetModule = callPackage ../build-support/dotnet/build-dotnet-module { };
nuget-to-nix = callPackage ../build-support/dotnet/nuget-to-nix { };
mkNugetSource = callPackage ../build-support/dotnet/make-nuget-source { };
-
mkNugetDeps = callPackage ../build-support/dotnet/make-nuget-deps { };
buildDotnetGlobalTool = callPackage ../build-support/dotnet/build-dotnet-global-tool { };
···
buildDotnetModule = callPackage ../build-support/dotnet/build-dotnet-module { };
nuget-to-nix = callPackage ../build-support/dotnet/nuget-to-nix { };
mkNugetSource = callPackage ../build-support/dotnet/make-nuget-source { };
+
mkNugetDeps = (newScope dotnetCorePackages) ../build-support/dotnet/make-nuget-deps { };
buildDotnetGlobalTool = callPackage ../build-support/dotnet/build-dotnet-global-tool { };