1{
2 lib,
3 stdenv,
4 buildDotnetModule,
5 fetchFromGitHub,
6 dotnetCorePackages,
7 wrapGAppsHook3,
8 glew,
9 gtk3,
10 xorg,
11}:
12
13buildDotnetModule rec {
14 pname = "libation";
15 version = "12.3.1";
16
17 src = fetchFromGitHub {
18 owner = "rmcrackan";
19 repo = "Libation";
20 tag = "v${version}";
21 hash = "sha256-jir1r78HbAhlOiCj6pSw0+o4V9ceCkJQWnKtt6VzLDY=";
22 };
23
24 sourceRoot = "${src.name}/Source";
25
26 dotnet-sdk = dotnetCorePackages.sdk_9_0;
27
28 dotnet-runtime = dotnetCorePackages.runtime_9_0;
29
30 nugetDeps = ./deps.json;
31
32 dotnetFlags = [
33 "-p:PublishReadyToRun=false"
34 # for some reason this is set to win-x64 in the project files
35 "-p:RuntimeIdentifier="
36 ];
37
38 projectFile = [
39 "LibationAvalonia/LibationAvalonia.csproj"
40 "LibationCli/LibationCli.csproj"
41 "HangoverAvalonia/HangoverAvalonia.csproj"
42 ];
43
44 nativeBuildInputs = [ wrapGAppsHook3 ];
45
46 runtimeDeps = [
47 # For Avalonia UI
48 glew
49 xorg.libXrandr
50 xorg.libXi
51 xorg.libXcursor
52 # For file dialogs
53 gtk3
54 ];
55
56 postInstall = ''
57 install -Dm644 LoadByOS/LinuxConfigApp/libation_glass.svg $out/share/icons/hicolor/scalable/apps/libation.svg
58 install -Dm644 LoadByOS/LinuxConfigApp/Libation.desktop $out/share/applications/libation.desktop
59 substituteInPlace $out/share/applications/libation.desktop \
60 --replace-fail "/usr/bin/libation" "libation"
61 '';
62
63 # wrap manually, because we need lower case executables
64 dontDotnetFixup = true;
65
66 preFixup = ''
67 # remove binaries for other platform, like upstream does
68 pushd $out/lib/libation
69 rm -f *.x86.dll *.x64.dll
70 ${lib.optionalString (stdenv.system != "x86_64-linux") "rm -f *.x64.so"}
71 ${lib.optionalString (stdenv.system != "aarch64-linux") "rm -f *.arm64.so"}
72 ${lib.optionalString (stdenv.system != "x86_64-darwin") "rm -f *.x64.dylib"}
73 ${lib.optionalString (stdenv.system != "aarch64-darwin") "rm -f *.arm64.dylib"}
74 popd
75
76 wrapDotnetProgram $out/lib/libation/Libation $out/bin/libation
77 wrapDotnetProgram $out/lib/libation/LibationCli $out/bin/libationcli
78 wrapDotnetProgram $out/lib/libation/Hangover $out/bin/hangover
79 '';
80
81 meta = {
82 changelog = "https://github.com/rmcrackan/Libation/releases/tag/v${version}";
83 description = "Audible audiobook manager";
84 homepage = "https://github.com/rmcrackan/Libation";
85 license = lib.licenses.gpl3Plus;
86 mainProgram = "libation";
87 maintainers = with lib.maintainers; [ tomasajt ];
88 };
89}