1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
|
{
dotnetCorePackages,
fetchFromGitHub,
fetchNpmDeps,
fetchzip,
fontconfig,
lib,
libICE,
libSM,
libX11,
libXcursor,
libXext,
libXi,
libXrandr,
liberation_ttf,
makeFontsConf,
nodejs,
npmHooks,
runCommand,
stdenvNoCC,
}:
let
inherit (dotnetCorePackages) systemToDotnetRid;
dotnet-sdk =
with dotnetCorePackages;
combinePackages [
sdk_6_0
sdk_7_0_1xx
];
npmDepsFile = ./npm-deps.nix;
in
stdenvNoCC.mkDerivation (
finalAttrs:
dotnetCorePackages.addNuGetDeps
{
nugetDeps = ./deps.nix;
overrideFetchAttrs = old: {
runtimeIds = map (system: dotnetCorePackages.systemToDotnetRid system) old.meta.platforms;
};
}
rec {
pname = "Avalonia";
version = "11.0.11";
src = fetchFromGitHub {
owner = "AvaloniaUI";
repo = "Avalonia";
rev = version;
fetchSubmodules = true;
hash = "sha256-Du8DEsZKl7rnVH9YZKAWTCpEQ/5HrNlgacgK/46kx/o=";
};
patches = [
# Fix failing tests that use unicode.org
./0001-use-files-for-unicode-character-database.patch
# [ERR] Compile: [...]/Microsoft.NET.Sdk.targets(148,5): error MSB4018: The "GenerateDepsFile" task failed unexpectedly. [/build/source/src/tools/DevAnalyzers/DevAnalyzers.csproj]
# [ERR] Compile: [...]/Microsoft.NET.Sdk.targets(148,5): error MSB4018: System.IO.IOException: The process cannot access the file '/build/source/src/tools/DevAnalyzers/bin/Release/netstandard2.0/DevAnalyzers.deps.json' because it is being used by another process. [/build/source/src/tools/DevAnalyzers/DevAnalyzers.csproj]
./0002-disable-parallel-compile.patch
];
# this needs to be match the version being patched above
UNICODE_CHARACTER_DATABASE = fetchzip {
url = "https://www.unicode.org/Public/15.0.0/ucd/UCD.zip";
hash = "sha256-jj6bX46VcnH7vpc9GwM9gArG+hSPbOGL6E4SaVd0s60=";
stripRoot = false;
};
postPatch =
''
patchShebangs build.sh
substituteInPlace src/Avalonia.X11/ICELib.cs \
--replace-fail '"libICE.so.6"' '"${lib.getLib libICE}/lib/libICE.so.6"'
substituteInPlace src/Avalonia.X11/SMLib.cs \
--replace-fail '"libSM.so.6"' '"${lib.getLib libSM}/lib/libSM.so.6"'
substituteInPlace src/Avalonia.X11/XLib.cs \
--replace-fail '"libX11.so.6"' '"${lib.getLib libX11}/lib/libX11.so.6"' \
--replace-fail '"libXrandr.so.2"' '"${lib.getLib libXrandr}/lib/libXrandr.so.2"' \
--replace-fail '"libXext.so.6"' '"${lib.getLib libXext}/lib/libXext.so.6"' \
--replace-fail '"libXi.so.6"' '"${lib.getLib libXi}/lib/libXi.so.6"' \
--replace-fail '"libXcursor.so.1"' '"${lib.getLib libXcursor}/lib/libXcursor.so.1"'
# from RestoreAdditionalProjectSources, which isn't supported by nuget-to-nix
dotnet nuget add source https://pkgs.dev.azure.com/dnceng/public/_packaging/dotnet8-transport/nuget/v3/index.json
# Tricky way to run npmConfigHook multiple times (borrowed from pagefind)
(
local postPatchHooks=() # written to by npmConfigHook
source ${npmHooks.npmConfigHook}/nix-support/setup-hook
''
+
# TODO: implement updateScript
lib.concatMapStrings (
{ path, hash }:
let
deps = fetchNpmDeps {
src = "${src}/${path}";
inherit hash;
};
in
''
npmRoot=${path} npmDeps="${deps}" npmConfigHook
rm -rf "$TMPDIR/cache"
''
) (import npmDepsFile)
+ ''
)
# Avalonia.Native is normally only packed on darwin.
substituteInPlace src/Avalonia.Native/Avalonia.Native.csproj \
--replace-fail \
'<IsPackable>$(PackAvaloniaNative)</IsPackable>' \
'<IsPackable>true</IsPackable>'
'';
makeCacheWritable = true;
# CSC : error CS1566: Error reading resource 'pdbstr.exe' -- 'Could not find a part of the path '/build/.nuget-temp/packages/sourcelink/1.1.0/tools/pdbstr.exe'.' [/build/source/nukebuild/_build.csproj]
linkNugetPackages = true;
# [WRN] Could not inject value for Build.ApiCompatTool
# System.Exception: Missing package reference/download.
# Run one of the following commands:
# ---> System.ArgumentException: Could not find package 'Microsoft.DotNet.ApiCompat.Tool' using:
# - Project assets file '/build/source/nukebuild/obj/project.assets.json'
# - NuGet packages config '/build/source/nukebuild/_build.csproj'
makeEmptyNupkgInPackages = true;
FONTCONFIG_FILE =
let
fc = makeFontsConf { fontDirectories = [ liberation_ttf ]; };
in
runCommand "fonts.conf" { } ''
substitute ${fc} $out \
--replace-fail "/etc/" "${fontconfig.out}/etc/"
'';
preConfigure = ''
# closed source (telemetry?) https://github.com/AvaloniaUI/Avalonia/discussions/16878
dotnet remove packages/Avalonia/Avalonia.csproj package Avalonia.BuildServices
'';
runtimeIds = [ (systemToDotnetRid stdenvNoCC.hostPlatform.system) ];
configurePhase = ''
runHook preConfigure
for project in nukebuild/_build.csproj dirs.proj; do
for rid in $runtimeIds; do
dotnet restore --runtime "$rid" "$project"
done
done
runHook postConfigure
'';
nativeBuildInputs = [
nodejs
dotnet-sdk
];
buildInputs = [ dotnet-sdk.packages ];
buildTarget = "Package";
buildPhase = ''
runHook preBuild
# ValidateApiDiff requires a network connection
./build.sh --target $buildTarget --verbosity Verbose --skip ValidateApiDiff
runHook postBuild
'';
installPhase = ''
runHook preInstall
mkdir -p "$out/share/nuget/source"
cp artifacts/nuget/* "$out/share/nuget/source"
runHook postInstall
'';
passthru = {
updateScript = ./update.bash;
inherit npmDepsFile;
};
meta = {
homepage = "https://avaloniaui.net/";
license = [ lib.licenses.mit ];
maintainers = with lib.maintainers; [ corngood ];
description = "A cross-platform UI framework for dotnet";
sourceProvenance = with lib.sourceTypes; [
fromSource
binaryNativeCode # npm dependencies contain binaries
];
platforms = dotnet-sdk.meta.platforms;
broken = stdenvNoCC.hostPlatform.isDarwin;
};
}
finalAttrs
)
|