summary refs log tree commit diff
path: root/pkgs/applications/misc/redshift/default.nix
blob: dc799bd6ff528305ade6a400f1545036300d84d4 (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
{ fetchurl, stdenv, gettext, intltool, pkgconfig, makeWrapper
, geoclue, python, pygobject3, pyxdg
, libdrm, libX11, libxcb, libXxf86vm
, guiSupport ? true
, drmSupport ? true
, randrSupport ? true
, vidModeSupport ? true
}:

let
  version = "1.10";
  mkFlag = flag: name: if flag then "--enable-${name}" else "--disable-${name}";
in
stdenv.mkDerivation {
  name = "redshift-${version}";
  src = fetchurl {
    sha256 = "19pfk9il5x2g2ivqix4a555psz8mj3m0cvjwnjpjvx0llh5fghjv";
    url = "https://github.com/jonls/redshift/releases/download/v${version}/redshift-${version}.tar.xz";
  };

  buildInputs = [ geoclue ]
    ++ stdenv.lib.optional guiSupport [ python pygobject3 pyxdg ]
    ++ stdenv.lib.optional drmSupport [ libdrm ]
    ++ stdenv.lib.optional randrSupport [ libxcb ]
    ++ stdenv.lib.optional vidModeSupport [ libX11 libXxf86vm ];
  nativeBuildInputs = [ gettext intltool makeWrapper pkgconfig ];

  configureFlags = [
    (mkFlag guiSupport "gui")
    (mkFlag drmSupport "drm")
    (mkFlag randrSupport "randr")
    (mkFlag vidModeSupport "vidmode")
  ];

  preInstall = stdenv.lib.optionalString guiSupport ''
    substituteInPlace src/redshift-gtk/redshift-gtk python \
      --replace "/usr/bin/env python3" "${python}/bin/${python.executable}"
  '';

  postInstall = stdenv.lib.optionalString guiSupport ''
    wrapProgram "$out/bin/redshift-gtk" --prefix PYTHONPATH : "$PYTHONPATH"
  '';

  meta = with stdenv.lib; {
    inherit version;
    description = "Gradually change screen color temperature";
    longDescription = ''
      The color temperature is set according to the position of the
      sun. A different color temperature is set during night and
      daytime. During twilight and early morning, the color
      temperature transitions smoothly from night to daytime
      temperature to allow your eyes to slowly adapt.
    '';
    license = licenses.gpl3Plus;
    homepage = http://jonls.dk/redshift;
    platforms = platforms.linux;
    maintainers = with maintainers; [ mornfall nckx ];
  }; 
}