aboutsummaryrefslogtreecommitdiff
path: root/nixpkgs/pkgs/desktops/deepin/dde-api/default.nix
blob: 011be982df5b31823a2597ac2a8ccc330a5a7d31 (plain)
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
{ stdenv
, buildGoPackage
, fetchFromGitHub
, pkgconfig
, alsaLib
, bc
, blur-effect
, coreutils
, deepin
, deepin-gettext-tools
, fontconfig
, go
, go-dbus-factory
, go-gir-generator
, go-lib
, grub2
, gtk3
, libcanberra
, libgudev
, librsvg
, poppler
, pulseaudio
, rfkill
, xcur2png
}:

buildGoPackage rec {
  pname = "dde-api";
  version = "5.0.0";

  goPackagePath = "pkg.deepin.io/dde/api";

  src = fetchFromGitHub {
    owner = "linuxdeepin";
    repo = pname;
    rev = version;
    sha256 = "0iv4krj6dqdknwvmax7aj40k1h96259kqcfnljadrwpl7cvsvp5p";
  };

  goDeps = ./deps.nix;

  nativeBuildInputs = [
    pkgconfig
    deepin-gettext-tools # build
    deepin.setupHook

    # TODO: using $PATH to find run time executable does not work with cross compiling
    bc          # run (to adjust grub theme?)
    blur-effect # run (is it really needed?)
    coreutils   # run (is it really needed?)
    fontconfig  # run (is it really needed?)
    rfkill      # run
    xcur2png    # run
    grub2       # run (is it really needed?)
  ];

  buildInputs = [
    go-dbus-factory      # needed
    go-gir-generator     # needed
    go-lib               # build

    alsaLib     # needed
    #glib        # ? arch
    gtk3        # build run
    libcanberra # build run
    libgudev    # needed
    librsvg     # build run
    poppler     # build run
    pulseaudio  # needed
    #locales     # run (locale-helper needs locale-gen, which is unavailable on NixOS?)
  ];

  postPatch = ''
    searchHardCodedPaths  # debugging

    fixPath $out /usr/lib/deepin-api \
      lunar-calendar/main.go \
      misc/services/com.deepin.api.CursorHelper.service \
      misc/services/com.deepin.api.Graphic.service \
      misc/services/com.deepin.api.LunarCalendar.service \
      misc/services/com.deepin.api.Pinyin.service \
      misc/system-services/com.deepin.api.Device.service \
      misc/system-services/com.deepin.api.LocaleHelper.service \
      misc/system-services/com.deepin.api.SoundThemePlayer.service \
      misc/systemd/system/deepin-shutdown-sound.service \
      theme_thumb/gtk/gtk.go \
      thumbnails/gtk/gtk.go
    fixPath $out /boot/grub Makefile     # TODO: confirm where to install grub themes
    fixPath $out /var Makefile

    # This package wants to install polkit local authority files into
    # /var/lib. Nix does not allow a package to install files into /var/lib
    # because it is outside of the Nix store and should contain applications
    # state information (persistent data modified by programs as they
    # run). Polkit looks for them in both /etc/polkit-1 and
    # /var/lib/polkit-1 (with /etc having priority over /var/lib). An
    # work around is to install them to $out/etc and simlnk them to
    # /etc in the deepin module.

    sed -i -e "s,/var/lib/polkit-1,/etc/polkit-1," Makefile
  '';

  buildPhase = ''
    export GOCACHE="$TMPDIR/go-cache";
    make -C go/src/${goPackagePath}
  '';

  installPhase = ''
    make install PREFIX="$out" SYSTEMD_LIB_DIR="$out/lib" -C go/src/${goPackagePath}
    mv $out/share/gocode $out/share/go
    remove-references-to -t ${go} $out/lib/deepin-api/*
  '';

  postFixup = ''
    searchHardCodedPaths $out  # debugging
  '';

  passthru.updateScript = deepin.updateScript { inherit pname version src; };

  meta = with stdenv.lib; {
    description = "Go-lang bindings for dde-daemon";
    homepage = "https://github.com/linuxdeepin/dde-api";
    license = licenses.gpl3;
    platforms = platforms.linux;
    maintainers = with maintainers; [ romildo ];
  };
}