Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

dotnet: split sdk packages by platform #343837

Open
wants to merge 14 commits into
base: master
Choose a base branch
from
Open
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
3 changes: 0 additions & 3 deletions pkgs/applications/audio/tagger/deps.nix

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

18 changes: 12 additions & 6 deletions pkgs/applications/misc/ArchiSteamFarm/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -27,22 +27,28 @@ buildDotnetModule rec {

projectFile = "ArchiSteamFarm.sln";
executable = "ArchiSteamFarm";

enableParallelBuilding = false;

useAppHost = false;
dotnetFlags = [
# useAppHost doesn't explicitly disable this
"-p:UseAppHost=false"
];
dotnetInstallFlags = [
"-p:RuntimeIdentifiers="
]
;
dotnetBuildFlags = [
"--framework=net8.0"
];
dotnetInstallFlags = dotnetBuildFlags;

runtimeDeps = [ libkrb5 zlib openssl ];

doCheck = true;

preBuild = ''
preInstall = ''
dotnetProjectFiles=(ArchiSteamFarm)
'';

preInstall = ''
# A mutable path, with this directory tree must be set. By default, this would point at the nix store causing errors.
makeWrapperArgs+=(
--run 'mkdir -p ~/.config/archisteamfarm/{config,logs,plugins}'
Expand All @@ -55,7 +61,7 @@ buildDotnetModule rec {
echo "Publishing plugin $1"
dotnet publish $1 -p:ContinuousIntegrationBuild=true -p:Deterministic=true \
--output $out/lib/ArchiSteamFarm/plugins/$1 --configuration Release \
-p:UseAppHost=false
$dotnetFlags $dotnetInstallFlags
}

buildPlugin ArchiSteamFarm.OfficialPlugins.ItemsMatcher
Expand Down
24 changes: 14 additions & 10 deletions pkgs/build-support/dotnet/build-dotnet-module/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,7 @@ let
useDotnetFromEnv
nugetDeps
runtimeId
dotnet-sdk
;

nativeBuildInputs = args.nativeBuildInputs or [ ] ++ [
Expand All @@ -149,12 +150,7 @@ let
dotnet-sdk
];

buildInputs =
args.buildInputs or [ ]
++ [
dotnet-sdk.packages
]
++ projectReferences;
buildInputs = args.buildInputs or [ ] ++ dotnet-sdk.packages ++ 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
Expand Down Expand Up @@ -206,7 +202,12 @@ stdenvNoCC.mkDerivation (
let
args = if lib.isFunction fnOrAttrs then fnOrAttrs (args' // finalAttrs) else fnOrAttrs;
args' = transformArgs finalAttrs args;
inherit (args') nugetDeps runtimeId meta;
inherit (args')
nugetDeps
runtimeId
meta
dotnet-sdk
;
args'' = removeAttrs args' [
"nugetDeps"
"runtimeId"
Expand All @@ -215,22 +216,25 @@ stdenvNoCC.mkDerivation (
"projectFile"
"projectReferences"
"runtimeDeps"
"runtimeId"
"disabledTests"
"testProjectFile"
"buildType"
"selfContainedBuild"
"useDotnet"
"useAppHost"
"dotnet-sdk"
];
in
if nugetDeps != null then
addNuGetDeps {
inherit nugetDeps;
overrideFetchAttrs =
a:
lib.optionalAttrs ((args'.runtimeId or null) == null) {
old:
lib.optionalAttrs ((args'.runtimeId or null) == null) rec {
dotnetRuntimeIds = map (system: dotnetCorePackages.systemToDotnetRid system) meta.platforms;
buildInputs =
old.buildInputs
++ lib.concatLists (lib.attrValues (lib.getAttrs dotnetRuntimeIds dotnet-sdk.targetPackages));
};
} args'' finalAttrs
else
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ dotnetCheckHook() {
-p:ContinuousIntegrationBuild=true \
-p:Deterministic=true \
--configuration "$dotnetBuildType" \
--no-restore \
--no-build \
--logger "console;verbosity=normal" \
"${runtimeIdFlagsArray[@]}" \
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ dotnetInstallHook() {
-p:OverwriteReadOnlyFiles=true \
--output "$dotnetInstallPath" \
--configuration "$dotnetBuildType" \
--no-restore \
--no-build \
"${runtimeIdFlagsArray[@]}" \
"${dotnetInstallFlagsArray[@]}" \
Expand All @@ -73,6 +74,7 @@ dotnetInstallHook() {
-p:OverwriteReadOnlyFiles=true \
--output "$out/share/nuget/source" \
--configuration "$dotnetBuildType" \
--no-restore \
--no-build \
--runtime "$runtimeId" \
"${dotnetPackFlagsArray[@]}" \
Expand Down
126 changes: 64 additions & 62 deletions pkgs/build-support/dotnet/fetch-nupkg/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -9,78 +9,80 @@
callPackage,
overrides ? callPackage ./overrides.nix { },
}:
{
pname,
version,
sha256 ? "",
hash ? "",
url ? "https://www.nuget.org/api/v2/package/${pname}/${version}",
installable ? false,
}:
let
package = stdenvNoCC.mkDerivation rec {
inherit pname version;
lib.makeOverridable (
{
pname,
version,
sha256 ? "",
hash ? "",
url ? "https://www.nuget.org/api/v2/package/${pname}/${version}",
installable ? false,
}:
let
package = 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
;
};
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
];
nativeBuildInputs = [
unzip
patchNupkgs
nugetPackageHook
];

unpackPhase = ''
runHook preUnpack
unpackPhase = ''
runHook preUnpack

unpackNupkg "$src" source
cd source
unpackNupkg "$src" source
cd source

runHook postUnpack
'';
runHook postUnpack
'';

prePatch = ''
shopt -s nullglob
local dir
for dir in tools runtimes/*/native; do
[[ ! -d "$dir" ]] || chmod -R +x "$dir"
done
rm -rf .signature.p7s
'';
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 = ''
runHook preInstall
installPhase = ''
runHook preInstall

dir=$out/share/nuget/packages/${lib.toLower pname}/${lib.toLower version}
mkdir -p $dir
cp -r . $dir
echo {} > "$dir"/.nupkg.metadata
dir=$out/share/nuget/packages/${lib.toLower pname}/${lib.toLower version}
mkdir -p $dir
cp -r . $dir
echo {} > "$dir"/.nupkg.metadata

runHook postInstall
'';
runHook postInstall
'';

preFixup = ''
patch-nupkgs $out/share/nuget/packages
'';
preFixup = ''
patch-nupkgs $out/share/nuget/packages
'';

createInstallableNugetSource = installable;
createInstallableNugetSource = installable;

meta = {
sourceProvenance = with lib.sourceTypes; [
binaryBytecode
binaryNativeCode
];
meta = {
sourceProvenance = with lib.sourceTypes; [
binaryBytecode
binaryNativeCode
];
};
};
};
in
overrides.${pname} or lib.id package
in
overrides.${pname} or lib.id package
)
7 changes: 5 additions & 2 deletions pkgs/by-name/av/avalonia/package.nix
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,11 @@ stdenvNoCC.mkDerivation (
dotnetCorePackages.addNuGetDeps
{
nugetDeps = ./deps.nix;
overrideFetchAttrs = old: {
overrideFetchAttrs = old: rec {
runtimeIds = map (system: dotnetCorePackages.systemToDotnetRid system) old.meta.platforms;
buildInputs =
old.buildInputs
++ lib.concatLists (lib.attrValues (lib.getAttrs runtimeIds dotnet-sdk.targetPackages));
};
}
rec {
Expand Down Expand Up @@ -159,7 +162,7 @@ stdenvNoCC.mkDerivation (
nodejs
dotnet-sdk
];
buildInputs = [ dotnet-sdk.packages ];
buildInputs = dotnet-sdk.packages;

buildTarget = "Package";

Expand Down
2 changes: 0 additions & 2 deletions pkgs/by-name/li/libation/deps.nix

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 5 additions & 1 deletion pkgs/by-name/li/libation/package.nix
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,11 @@ buildDotnetModule rec {

nugetDeps = ./deps.nix;

dotnetFlags = [ "-p:PublishReadyToRun=false" ];
dotnetFlags = [
"-p:PublishReadyToRun=false"
# for some reason this is set to win-x64 in the project files
"-p:RuntimeIdentifier="
];

projectFile = [
"LibationAvalonia/LibationAvalonia.csproj"
Expand Down
Loading