1{ lib, stdenv, fetchFromGitHub, fetchFromGitLab
2, autoconf, automake, gettext, intltool
3, libtool, pkg-config, wrapGAppsHook, wrapPython, gobject-introspection
4, gtk3, python, pygobject3, pyxdg
5
6, withQuartz ? stdenv.isDarwin, ApplicationServices
7, withRandr ? stdenv.isLinux, libxcb
8, withDrm ? stdenv.isLinux, libdrm
9
10, withGeolocation ? true
11, withCoreLocation ? withGeolocation && stdenv.isDarwin, CoreLocation, Foundation, Cocoa
12, withGeoclue ? withGeolocation && stdenv.isLinux, geoclue
13, withAppIndicator ? stdenv.isLinux, libappindicator, libayatana-appindicator
14}:
15
16let
17 mkRedshift =
18 { pname, version, src, meta }:
19 stdenv.mkDerivation rec {
20 inherit pname version src meta;
21
22 patches = lib.optionals (pname != "gammastep") [
23 # https://github.com/jonls/redshift/pull/575
24 ./575.patch
25 ];
26
27 nativeBuildInputs = [
28 autoconf
29 automake
30 gettext
31 intltool
32 libtool
33 pkg-config
34 wrapGAppsHook
35 wrapPython
36 gobject-introspection
37 ];
38
39 configureFlags = [
40 "--enable-randr=${if withRandr then "yes" else "no"}"
41 "--enable-geoclue2=${if withGeoclue then "yes" else "no"}"
42 "--enable-drm=${if withDrm then "yes" else "no"}"
43 "--enable-quartz=${if withQuartz then "yes" else "no"}"
44 "--enable-corelocation=${if withCoreLocation then "yes" else "no"}"
45 ] ++ lib.optionals (pname == "gammastep") [
46 "--with-systemduserunitdir=${placeholder "out"}/lib/systemd/user/"
47 "--enable-apparmor"
48 ];
49
50 buildInputs = [
51 gtk3
52 python
53 ] ++ lib.optional withRandr libxcb
54 ++ lib.optional withGeoclue geoclue
55 ++ lib.optional withDrm libdrm
56 ++ lib.optional withQuartz ApplicationServices
57 ++ lib.optionals withCoreLocation [ CoreLocation Foundation Cocoa ]
58 ++ lib.optional withAppIndicator (if (pname != "gammastep")
59 then libappindicator
60 else libayatana-appindicator)
61 ;
62
63 pythonPath = [ pygobject3 pyxdg ];
64
65 preConfigure = "./bootstrap";
66
67 dontWrapGApps = true;
68
69 preFixup = ''
70 makeWrapperArgs+=("''${gappsWrapperArgs[@]}")
71 '';
72
73 postFixup = ''
74 wrapPythonPrograms
75 wrapGApp $out/bin/${pname}
76 '';
77
78 # the geoclue agent may inspect these paths and expect them to be
79 # valid without having the correct $PATH set
80 postInstall = if (pname == "gammastep") then ''
81 substituteInPlace $out/share/applications/gammastep.desktop \
82 --replace 'Exec=gammastep' "Exec=$out/bin/gammastep"
83 substituteInPlace $out/share/applications/gammastep-indicator.desktop \
84 --replace 'Exec=gammastep-indicator' "Exec=$out/bin/gammastep-indicator"
85 '' else ''
86 substituteInPlace $out/share/applications/redshift.desktop \
87 --replace 'Exec=redshift' "Exec=$out/bin/redshift"
88 substituteInPlace $out/share/applications/redshift-gtk.desktop \
89 --replace 'Exec=redshift-gtk' "Exec=$out/bin/redshift-gtk"
90 '';
91
92 enableParallelBuilding = true;
93 };
94in
95rec {
96 redshift = mkRedshift rec {
97 pname = "redshift";
98 version = "1.12";
99
100 src = fetchFromGitHub {
101 owner = "jonls";
102 repo = "redshift";
103 rev = "v${version}";
104 sha256 = "12cb4gaqkybp4bkkns8pam378izr2mwhr2iy04wkprs2v92j7bz6";
105 };
106
107 meta = with lib; {
108 description = "Screen color temperature manager";
109 longDescription = ''
110 Redshift adjusts the color temperature according to the position
111 of the sun. A different color temperature is set during night and
112 daytime. During twilight and early morning, the color temperature
113 transitions smoothly from night to daytime temperature to allow
114 your eyes to slowly adapt. At night the color temperature should
115 be set to match the lamps in your room.
116 '';
117 license = licenses.gpl3Plus;
118 homepage = "http://jonls.dk/redshift";
119 platforms = platforms.unix;
120 mainProgram = "redshift";
121 maintainers = with maintainers; [ yana ];
122 };
123 };
124
125 gammastep = mkRedshift rec {
126 pname = "gammastep";
127 version = "2.0.9";
128
129 src = fetchFromGitLab {
130 owner = "chinstrap";
131 repo = pname;
132 rev = "v${version}";
133 sha256 = "sha256-EdVLBBIEjMu+yy9rmcxQf4zdW47spUz5SbBDbhmLjOU=";
134 };
135
136 meta = redshift.meta // {
137 name = "${pname}-${version}";
138 longDescription = "Gammastep"
139 + lib.removePrefix "Redshift" redshift.meta.longDescription;
140 homepage = "https://gitlab.com/chinstrap/gammastep";
141 mainProgram = "gammastep";
142 maintainers = (with lib.maintainers; [ eclairevoyant primeos ]) ++ redshift.meta.maintainers;
143 };
144 };
145}