summary refs log tree commit diff
path: root/pkgs/applications/networking/browsers/chromium/default.nix
blob: 1b5da0763e70b414f779d12c2ed41a625b3243e2 (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
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
{ newScope, stdenv, makeWrapper, makeDesktopItem

# package customization
, channel ? "stable"
, enableSELinux ? false
, enableNaCl ? false
, enableHotwording ? false
, useOpenSSL ? false
, gnomeSupport ? false
, gnomeKeyringSupport ? false
, proprietaryCodecs ? true
, enablePepperFlash ? false
, enableWideVine ? false
, cupsSupport ? true
, pulseSupport ? false
, hiDPISupport ? false
}:

let
  callPackage = newScope chromium;

  chromium = {
    source = callPackage ./source {
      inherit channel;
      # XXX: common config
      inherit useOpenSSL;
    };

    mkChromiumDerivation = callPackage ./common.nix {
      inherit enableSELinux enableNaCl enableHotwording useOpenSSL gnomeSupport
              gnomeKeyringSupport proprietaryCodecs cupsSupport pulseSupport
              hiDPISupport;
    };

    browser = callPackage ./browser.nix { };

    plugins = callPackage ./plugins.nix {
      inherit enablePepperFlash enableWideVine;
    };
  };

  desktopItem = makeDesktopItem {
    name = "chromium";
    exec = "chromium";
    icon = "${chromium.browser}/share/icons/hicolor/48x48/apps/chromium.png";
    comment = "An open source web browser from Google";
    desktopName = "Chromium";
    genericName = "Web browser";
    mimeType = stdenv.lib.concatStringsSep ";" [
      "text/html"
      "text/xml"
      "application/xhtml+xml"
      "x-scheme-handler/http"
      "x-scheme-handler/https"
      "x-scheme-handler/ftp"
      "x-scheme-handler/mailto"
      "x-scheme-handler/webcal"
      "x-scheme-handler/about"
      "x-scheme-handler/unknown"
    ];
    categories = "Network;WebBrowser";
  };

  suffix = if channel != "stable" then "-" + channel else "";

in stdenv.mkDerivation {
  name = "chromium${suffix}-${chromium.browser.version}";

  buildInputs = [ makeWrapper ] ++ chromium.plugins.enabledPlugins;

  buildCommand = let
    browserBinary = "${chromium.browser}/libexec/chromium/chromium";
    mkEnvVar = key: val: "--set '${key}' '${val}'";
    envVars = chromium.plugins.settings.envVars or {};
    flags = chromium.plugins.settings.flags or [];
  in with stdenv.lib; ''
    mkdir -p "$out/bin" "$out/share/applications"

    ln -s "${chromium.browser}/share" "$out/share"
    makeWrapper "${browserBinary}" "$out/bin/chromium" \
      ${concatStrings (mapAttrsToList mkEnvVar envVars)} \
      --add-flags "${concatStringsSep " " flags}"

    ln -s "$out/bin/chromium" "$out/bin/chromium-browser"
    ln -s "${chromium.browser}/share/icons" "$out/share/icons"
    cp -v "${desktopItem}/share/applications/"* "$out/share/applications"
  '';

  inherit (chromium.browser) meta packageName;

  passthru = {
    mkDerivation = chromium.mkChromiumDerivation;
  };
}