1 { config, lib, pkgs, ... }:
7 cfg = config.services.redshift;
8 lcfg = config.location;
13 (mkChangedOptionModule [ "services" "redshift" "latitude" ] [ "location" "latitude" ]
15 let value = getAttrFromPath [ "services" "redshift" "latitude" ] config;
16 in if value == null then
17 throw "services.redshift.latitude is set to null, you can remove this"
18 else builtins.fromJSON value))
19 (mkChangedOptionModule [ "services" "redshift" "longitude" ] [ "location" "longitude" ]
21 let value = getAttrFromPath [ "services" "redshift" "longitude" ] config;
22 in if value == null then
23 throw "services.redshift.longitude is set to null, you can remove this"
24 else builtins.fromJSON value))
25 (mkRenamedOptionModule [ "services" "redshift" "provider" ] [ "location" "provider" ])
28 options.services.redshift = {
33 Enable Redshift to change your screen's colour temperature depending on
43 Colour temperature to use during the day, between
51 Colour temperature to use at night, between
62 Screen brightness to apply during the day,
63 between `0.1` and `1.0`.
70 Screen brightness to apply during the night,
71 between `0.1` and `1.0`.
76 package = mkPackageOption pkgs "redshift" { };
78 executable = mkOption {
80 default = "/bin/redshift";
81 example = "/bin/redshift-gtk";
83 Redshift executable to use within the package.
87 extraOptions = mkOption {
88 type = types.listOf types.str;
90 example = [ "-v" "-m randr" ];
92 Additional command-line arguments to pass to
98 config = mkIf cfg.enable {
99 # needed so that .desktop files are installed, which geoclue cares about
100 environment.systemPackages = [ cfg.package ];
102 services.geoclue2.appConfig.redshift = {
107 systemd.user.services.redshift =
109 providerString = if lcfg.provider == "manual"
110 then "${toString lcfg.latitude}:${toString lcfg.longitude}"
114 description = "Redshift colour temperature adjuster";
115 wantedBy = [ "graphical-session.target" ];
116 partOf = [ "graphical-session.target" ];
119 ${cfg.package}${cfg.executable} \
120 -l ${providerString} \
121 -t ${toString cfg.temperature.day}:${toString cfg.temperature.night} \
122 -b ${toString cfg.brightness.day}:${toString cfg.brightness.night} \
123 ${lib.strings.concatStringsSep " " cfg.extraOptions}