1{
2 lib,
3 fetchFromGitHub,
4 buildDotnetModule,
5 dotnetCorePackages,
6 stdenv,
7 nix-update-script,
8 aot ? dotnetCorePackages.sdk_9_0.hasILCompiler && !stdenv.hostPlatform.isDarwin,
9}:
10
11buildDotnetModule rec {
12 pname = "patchcil";
13 version = "0.2.2";
14
15 src = fetchFromGitHub {
16 owner = "GGG-KILLER";
17 repo = "patchcil";
18 tag = "v${version}";
19 hash = "sha256-jqVXKp5ShWkIMAgmcwu9/QHy+Ey9d1Piv62wsO0Xm44=";
20 };
21
22 nativeBuildInputs = lib.optional aot stdenv.cc;
23
24 projectFile = "src/PatchCil.csproj";
25 nugetDeps = ./deps.json;
26
27 dotnet-sdk = dotnetCorePackages.sdk_9_0;
28 dotnet-runtime = if aot then null else dotnetCorePackages.runtime_9_0;
29
30 selfContainedBuild = aot;
31 dotnetFlags = lib.optionals (!aot) [
32 # Disable AOT
33 "-p:PublishAot=false"
34 "-p:InvariantGlobalization=false"
35 "-p:EventSourceSupport=true"
36 "-p:HttpActivityPropagationSupport=true"
37 "-p:MetadataUpdaterSupport=true"
38 "-p:MetricsSupport=true"
39 "-p:UseNativeHttpHandler=false"
40 "-p:XmlResolverIsNetworkingEnabledByDefault=true"
41 "-p:EnableGeneratedComInterfaceComImportInterop=true"
42 "-p:_ComObjectDescriptorSupport=true"
43 "-p:_DataSetXmlSerializationSupport=true"
44 "-p:_DefaultValueAttributeSupport=true"
45 "-p:_DesignerHostSupport=true"
46 "-p:_EnableConsumingManagedCodeFromNativeHosting=true"
47 "-p:_UseManagedNtlm=true"
48 ];
49
50 preFixup = lib.optionalString aot ''
51 # Remove debug symbols as they shouldn't have anything in them.
52 rm $out/lib/patchcil/patchcil.dbg
53 '';
54
55 executables = [ "patchcil" ];
56
57 passthru = {
58 updateScript = nix-update-script { };
59 };
60
61 meta = {
62 description = "Small utility to modify the library paths from PInvoke in .NET assemblies";
63 homepage = "https://github.com/GGG-KILLER/patchcil";
64 license = lib.licenses.mit;
65 maintainers = with lib.maintainers; [ ggg ];
66 mainProgram = "patchcil";
67 platforms = [
68 "x86_64-linux"
69 "aarch64-linux"
70 "x86_64-darwin"
71 "aarch64-darwin"
72 "x86_64-windows"
73 "i686-windows"
74 ];
75 };
76}