1{
2 lib,
3 fetchFromGitHub,
4 buildGoModule,
5 pkg-config,
6 deepin-gettext-tools,
7 wrapGAppsHook3,
8 alsa-lib,
9 gtk3,
10 libcanberra,
11 libgudev,
12 librsvg,
13 poppler,
14 pulseaudio,
15 gdk-pixbuf-xlib,
16 coreutils,
17 dbus,
18}:
19
20buildGoModule rec {
21 pname = "dde-api";
22 version = "6.0.11";
23
24 src = fetchFromGitHub {
25 owner = "linuxdeepin";
26 repo = pname;
27 rev = version;
28 hash = "sha256-VpZwVNXxdi8ODwxbksQpT0nnUuLOTJ9h0JYucEKdGYM=";
29 };
30
31 vendorHash = "sha256-zrtUsCF2+301DKwgWectw+UbOehOp8h8u/IMf09XQ8Q=";
32
33 postPatch = ''
34 substituteInPlace misc/systemd/system/deepin-shutdown-sound.service \
35 --replace-fail "/usr/bin/true" "${coreutils}/bin/true"
36
37 substituteInPlace sound-theme-player/main.go \
38 --replace-fail "/usr/sbin/alsactl" "alsactl"
39
40 substituteInPlace misc/{scripts/deepin-boot-sound.sh,systemd/system/deepin-login-sound.service} \
41 --replace-fail "/usr/bin/dbus-send" "${dbus}/bin/dbus-send"
42
43 substituteInPlace lunar-calendar/huangli.go adjust-grub-theme/main.go \
44 --replace-fail "/usr/share/dde-api" "$out/share/dde-api"
45
46 substituteInPlace themes/{theme.go,settings.go} \
47 --replace-fail "/usr/share" "/run/current-system/sw/share"
48
49 for file in $(grep "/usr/lib/deepin-api" * -nR |awk -F: '{print $1}')
50 do
51 sed -i 's|/usr/lib/deepin-api|/run/current-system/sw/lib/deepin-api|g' $file
52 done
53 '';
54
55 nativeBuildInputs = [
56 pkg-config
57 deepin-gettext-tools
58 wrapGAppsHook3
59 ];
60
61 buildInputs = [
62 alsa-lib
63 gtk3
64 libcanberra
65 libgudev
66 librsvg
67 poppler
68 pulseaudio
69 gdk-pixbuf-xlib
70 ];
71
72 buildPhase = ''
73 runHook preBuild
74 make GOBUILD_OPTIONS="$GOFLAGS"
75 runHook postBuild
76 '';
77
78 doCheck = false;
79
80 installPhase = ''
81 runHook preInstall
82 make install DESTDIR="$out" PREFIX="/"
83 runHook postInstall
84 '';
85
86 postFixup = ''
87 for binary in $out/lib/deepin-api/*; do
88 wrapProgram $binary "''${gappsWrapperArgs[@]}"
89 done
90 '';
91
92 meta = with lib; {
93 description = "Dbus interfaces used for screen zone detecting, thumbnail generating, sound playing, etc";
94 mainProgram = "dde-open";
95 homepage = "https://github.com/linuxdeepin/dde-api";
96 license = licenses.gpl3Plus;
97 platforms = platforms.linux;
98 teams = [ teams.deepin ];
99 };
100}