about summary refs log tree commit diff
path: root/pkgs/applications/networking/browsers/firefox/wrapper.nix
blob: f68f0f92e287263af3653070b232cea3ae964cf5 (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
{stdenv, browser, browserName ? "firefox", nameSuffix ? "", makeDesktopItem, makeWrapper, plugins}:

stdenv.mkDerivation {
  name = browser.name + "-with-plugins";

  desktopItem = makeDesktopItem {
    name = browserName;
    exec = browserName;
    icon = "${browser}/lib/${browser.name}/icons/mozicon128.png";
    comment = "";
    desktopName = browserName;
    genericName = "Web Browser";
    categories = "Application;Network;";
  };

  buildInputs = [makeWrapper];

  buildCommand = ''
    if [ ! -x "${browser}/bin/${browserName}" ]
    then
        echo "cannot find executable file \`${browser}/bin/${browserName}'"
        exit 1
    fi

    makeWrapper "${browser}/bin/${browserName}" \
        "$out/bin/${browserName}${nameSuffix}" \
        --suffix-each MOZ_PLUGIN_PATH ':' "$plugins" \
        --suffix-contents PATH ':' "$(filterExisting $(addSuffix /extra-bin-path $plugins))"

    ensureDir $out/share/applications
    cp $desktopItem/share/applications/* $out/share/applications
  '';

  # Let each plugin tell us (through its `mozillaPlugin') attribute
  # where to find the plugin in its tree.
  plugins = map (x: x + x.mozillaPlugin) plugins;

  meta = {
    description =
      browser.meta.description
      + " (with plugins: "
      + (let lib = import ../../../../lib;
        in lib.concatStrings (lib.intersperse ", " (map (x: x.name) plugins)))
      + ")";
  };
}