about summary refs log tree commit diff
path: root/pkgs/desktops/gnome/misc/gnome-panel/wrapper.nix
blob: 10b81eaad62cdb0ac02328b7ab073a469955a838 (plain) (blame)
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
{ stdenv
, lib
, buildEnv
, gnome-panel
, gnome-flashback
, xorg
, glib
, wrapGAppsHook3
, panelModulePackages ? [ ]
}:

let
  # We always want to find the built-in panel applets.
  selectedPanelModulePackages = [ gnome-panel gnome-flashback ] ++ panelModulePackages;

  panelModulesEnv = buildEnv {
    name = "gnome-panel-modules-env";
    paths = selectedPanelModulePackages;
    pathsToLink = [ "/lib/gnome-panel/modules" ];
  };
in
stdenv.mkDerivation {
  pname = "${gnome-panel.pname}-with-modules";
  inherit (gnome-panel) version;

  nativeBuildInputs = [
    glib
    wrapGAppsHook3
  ];

  buildInputs = selectedPanelModulePackages ++
    lib.forEach selectedPanelModulePackages (x: x.buildInputs or [ ]);

  dontUnpack = true;
  dontConfigure = true;
  dontBuild = true;

  preferLocalBuild = true;
  allowSubstitutes = false;

  installPhase = ''
    runHook preInstall

    mkdir -p $out
    ${xorg.lndir}/bin/lndir -silent ${gnome-panel} $out

    rm -r $out/lib/gnome-panel/modules
    ${xorg.lndir}/bin/lndir -silent ${panelModulesEnv} $out

    rm $out/share/applications/gnome-panel.desktop

    substitute ${gnome-panel}/share/applications/gnome-panel.desktop \
      $out/share/applications/gnome-panel.desktop --replace \
      "Exec=${gnome-panel}/bin/gnome-panel" "Exec=$out/bin/gnome-panel"

    runHook postInstall
  '';

  preFixup = ''
    gappsWrapperArgs+=(
      --set NIX_GNOME_PANEL_MODULESDIR "$out/lib/gnome-panel/modules"
    )
  '';

  meta = gnome-panel.meta // { outputsToInstall = [ "out" ]; };
}