mirror of
https://github.com/nix-community/home-manager
synced 2024-11-26 21:19:45 +01:00
Revert "redshift/gammastep: use ini file"
Manual latitude and longitude setting doesn't work in Redshift.
This reverts commit dd6ee694df
.
This commit is contained in:
parent
dd6ee694df
commit
bdee1be7b3
10 changed files with 63 additions and 173 deletions
|
@ -72,35 +72,6 @@ programs.rofi.extraConfig = {
|
||||||
};
|
};
|
||||||
----
|
----
|
||||||
|
|
||||||
* The `services.redshift.extraOptions` and `services.gammastep.extraOptions`
|
|
||||||
options were removed in favor of <<opt-services.redshift.settings>> and
|
|
||||||
`services.gammastep.settings`, that are now an attribute set rather
|
|
||||||
than a string. They also support new features not available before, for
|
|
||||||
example:
|
|
||||||
+
|
|
||||||
[source,nix]
|
|
||||||
----
|
|
||||||
services.redshift = {
|
|
||||||
dawnTime = "6:00-7:45";
|
|
||||||
duskTime = "18:35-20:15";
|
|
||||||
settings = {
|
|
||||||
redshift = {
|
|
||||||
gamma = 0.8;
|
|
||||||
adjustment-method = "randr";
|
|
||||||
};
|
|
||||||
|
|
||||||
randr = {
|
|
||||||
screen = 0;
|
|
||||||
};
|
|
||||||
};
|
|
||||||
};
|
|
||||||
----
|
|
||||||
+
|
|
||||||
It is recommended to check either
|
|
||||||
https://github.com/jonls/redshift/blob/master/redshift.conf.sample[redshift.conf.sample] or
|
|
||||||
https://gitlab.com/chinstrap/gammastep/-/blob/master/gammastep.conf.sample[gammastep.conf.sample]
|
|
||||||
for the available additional options in each program.
|
|
||||||
|
|
||||||
[[sec-release-21.05-state-version-changes]]
|
[[sec-release-21.05-state-version-changes]]
|
||||||
=== State Version Changes
|
=== State Version Changes
|
||||||
|
|
||||||
|
|
|
@ -4,17 +4,14 @@ with lib;
|
||||||
|
|
||||||
let
|
let
|
||||||
commonOptions = import ./lib/options.nix {
|
commonOptions = import ./lib/options.nix {
|
||||||
inherit config lib pkgs;
|
inherit config lib;
|
||||||
|
|
||||||
moduleName = "gammastep";
|
moduleName = "gammastep";
|
||||||
programName = "Gammastep";
|
programName = "Gammastep";
|
||||||
# https://gitlab.com/chinstrap/gammastep/-/commit/1608ed61154cc652b087e85c4ce6125643e76e2f
|
|
||||||
mainSection = "general";
|
|
||||||
defaultPackage = pkgs.gammastep;
|
defaultPackage = pkgs.gammastep;
|
||||||
examplePackage = "pkgs.gammastep";
|
examplePackage = "pkgs.gammastep";
|
||||||
mainExecutable = "gammastep";
|
mainExecutable = "gammastep";
|
||||||
appletExecutable = "gammastep-indicator";
|
appletExecutable = "gammastep-indicator";
|
||||||
xdgConfigFilePath = "gammastep/config.ini";
|
|
||||||
serviceDocumentation = "https://gitlab.com/chinstrap/gammastep/";
|
serviceDocumentation = "https://gitlab.com/chinstrap/gammastep/";
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -1,61 +1,32 @@
|
||||||
{ config, lib, pkgs, moduleName, mainSection, programName, defaultPackage
|
# Adapted from Nixpkgs.
|
||||||
, examplePackage, mainExecutable, appletExecutable, xdgConfigFilePath
|
|
||||||
, serviceDocumentation }:
|
{ config, lib, moduleName, programName, defaultPackage, examplePackage
|
||||||
|
, mainExecutable, appletExecutable, serviceDocumentation }:
|
||||||
|
|
||||||
with lib;
|
with lib;
|
||||||
|
|
||||||
let
|
let
|
||||||
|
|
||||||
cfg = config.services.${moduleName};
|
cfg = config.services.${moduleName};
|
||||||
settingsFormat = pkgs.formats.ini { };
|
|
||||||
|
|
||||||
in {
|
in {
|
||||||
meta = {
|
meta = {
|
||||||
maintainers = with maintainers; [ rycee petabyteboy thiagokokada ];
|
maintainers = with maintainers; [ rycee petabyteboy thiagokokada ];
|
||||||
};
|
};
|
||||||
|
|
||||||
imports = let
|
|
||||||
mkRenamed = old: new:
|
|
||||||
mkRenamedOptionModule ([ "services" moduleName ] ++ old) [
|
|
||||||
"services"
|
|
||||||
moduleName
|
|
||||||
"settings"
|
|
||||||
mainSection
|
|
||||||
new
|
|
||||||
];
|
|
||||||
in [
|
|
||||||
(mkRemovedOptionModule [ "services" moduleName "extraOptions" ]
|
|
||||||
"All ${programName} configuration is now available through services.${moduleName}.settings instead.")
|
|
||||||
(mkRenamed [ "brightness" "day" ] "brightness-day")
|
|
||||||
(mkRenamed [ "brightness" "night" ] "brightness-night")
|
|
||||||
];
|
|
||||||
|
|
||||||
options = {
|
options = {
|
||||||
enable = mkEnableOption programName;
|
enable = mkOption {
|
||||||
|
type = types.bool;
|
||||||
dawnTime = mkOption {
|
default = false;
|
||||||
type = types.nullOr types.str;
|
example = true;
|
||||||
default = null;
|
|
||||||
example = "6:00-7:45";
|
|
||||||
description = ''
|
description = ''
|
||||||
Set the time interval of dawn manually.
|
Enable ${programName} to change your screen's colour temperature
|
||||||
The times must be specified as HH:MM in 24-hour format.
|
depending on the time of day.
|
||||||
'';
|
|
||||||
};
|
|
||||||
|
|
||||||
duskTime = mkOption {
|
|
||||||
type = types.nullOr types.str;
|
|
||||||
default = null;
|
|
||||||
example = "18:35-20:15";
|
|
||||||
description = ''
|
|
||||||
Set the time interval of dusk manually.
|
|
||||||
The times must be specified as HH:MM in 24-hour format.
|
|
||||||
'';
|
'';
|
||||||
};
|
};
|
||||||
|
|
||||||
latitude = mkOption {
|
latitude = mkOption {
|
||||||
type = with types; nullOr (either str float);
|
type = types.nullOr types.str;
|
||||||
apply = toString;
|
|
||||||
default = null;
|
default = null;
|
||||||
description = ''
|
description = ''
|
||||||
Your current latitude, between <literal>-90.0</literal> and
|
Your current latitude, between <literal>-90.0</literal> and
|
||||||
|
@ -65,8 +36,7 @@ in {
|
||||||
};
|
};
|
||||||
|
|
||||||
longitude = mkOption {
|
longitude = mkOption {
|
||||||
type = with types; nullOr (either str float);
|
type = types.nullOr types.str;
|
||||||
apply = toString;
|
|
||||||
default = null;
|
default = null;
|
||||||
description = ''
|
description = ''
|
||||||
Your current longitude, between <literal>-180.0</literal> and
|
Your current longitude, between <literal>-180.0</literal> and
|
||||||
|
@ -105,6 +75,26 @@ in {
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
|
brightness = {
|
||||||
|
day = mkOption {
|
||||||
|
type = types.str;
|
||||||
|
default = "1";
|
||||||
|
description = ''
|
||||||
|
Screen brightness to apply during the day,
|
||||||
|
between <literal>0.1</literal> and <literal>1.0</literal>.
|
||||||
|
'';
|
||||||
|
};
|
||||||
|
|
||||||
|
night = mkOption {
|
||||||
|
type = types.str;
|
||||||
|
default = "1";
|
||||||
|
description = ''
|
||||||
|
Screen brightness to apply during the night,
|
||||||
|
between <literal>0.1</literal> and <literal>1.0</literal>.
|
||||||
|
'';
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
package = mkOption {
|
package = mkOption {
|
||||||
type = types.package;
|
type = types.package;
|
||||||
default = defaultPackage;
|
default = defaultPackage;
|
||||||
|
@ -123,62 +113,26 @@ in {
|
||||||
'';
|
'';
|
||||||
};
|
};
|
||||||
|
|
||||||
settings = mkOption {
|
extraOptions = mkOption {
|
||||||
type = types.submodule { freeformType = settingsFormat.type; };
|
type = types.listOf types.str;
|
||||||
default = { };
|
default = [ ];
|
||||||
example = literalExample ''
|
example = [ "-v" "-m randr" ];
|
||||||
{
|
|
||||||
${mainSection} = {
|
|
||||||
adjustment-method = "randr";
|
|
||||||
};
|
|
||||||
randr = {
|
|
||||||
screen = 0;
|
|
||||||
};
|
|
||||||
};
|
|
||||||
'';
|
|
||||||
description = ''
|
description = ''
|
||||||
The configuration to pass to ${programName}.
|
Additional command-line arguments to pass to
|
||||||
Available options for ${programName} described in
|
<command>redshift</command>.
|
||||||
<citerefentry>
|
|
||||||
<refentrytitle>${moduleName}</refentrytitle>
|
|
||||||
<manvolnum>1</manvolnum>
|
|
||||||
</citerefentry>.
|
|
||||||
'';
|
'';
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
config = {
|
config = {
|
||||||
assertions = [{
|
assertions = [{
|
||||||
assertion = (cfg.settings ? ${moduleName}.dawn-time || cfg.settings
|
assertion = cfg.provider == "manual" -> cfg.latitude != null
|
||||||
? ${moduleName}.dusk-time)
|
&& cfg.longitude != null;
|
||||||
|| (cfg.settings.${moduleName}.location-provider) == "geoclue2"
|
message = "Must provide services.${moduleName}.latitude and"
|
||||||
|| ((cfg.settings.${moduleName}.location-provider) == "manual"
|
+ " services.${moduleName}.latitude when"
|
||||||
&& (cfg.settings ? ${moduleName}.latitude || cfg.settings
|
+ " services.${moduleName}.provider is set to \"manual\".";
|
||||||
? ${moduleName}.longitude));
|
|
||||||
message = ''
|
|
||||||
In order for ${programName} to know the time of action, you need to set one of
|
|
||||||
- services.${moduleName}.provider = "geoclue2" for automatically inferring your location
|
|
||||||
(you also need to enable Geoclue2 service separately)
|
|
||||||
- services.${moduleName}.longitude and .latitude for specifying your location manually
|
|
||||||
- services.${moduleName}.dawnTime and .duskTime for specifying the times manually
|
|
||||||
'';
|
|
||||||
}];
|
}];
|
||||||
|
|
||||||
services.${moduleName}.settings = {
|
|
||||||
${mainSection} = {
|
|
||||||
temp-day = cfg.temperature.day;
|
|
||||||
temp-night = cfg.temperature.night;
|
|
||||||
location-provider = cfg.provider;
|
|
||||||
dawn-time = mkIf (cfg.dawnTime != null) cfg.dawnTime;
|
|
||||||
dusk-time = mkIf (cfg.duskTime != null) cfg.dawnTime;
|
|
||||||
latitude = mkIf (cfg.latitude != null) cfg.latitude;
|
|
||||||
longitude = mkIf (cfg.longitude != null) cfg.longitude;
|
|
||||||
};
|
|
||||||
};
|
|
||||||
|
|
||||||
xdg.configFile.${xdgConfigFilePath}.source =
|
|
||||||
settingsFormat.generate xdgConfigFilePath cfg.settings;
|
|
||||||
|
|
||||||
systemd.user.services.${moduleName} = {
|
systemd.user.services.${moduleName} = {
|
||||||
Unit = {
|
Unit = {
|
||||||
Description = "${programName} colour temperature adjuster";
|
Description = "${programName} colour temperature adjuster";
|
||||||
|
@ -191,9 +145,21 @@ in {
|
||||||
|
|
||||||
Service = {
|
Service = {
|
||||||
ExecStart = let
|
ExecStart = let
|
||||||
|
providerString = if cfg.provider == "manual" then
|
||||||
|
"${cfg.latitude}:${cfg.longitude}"
|
||||||
|
else
|
||||||
|
cfg.provider;
|
||||||
|
|
||||||
|
args = [
|
||||||
|
"-l ${providerString}"
|
||||||
|
"-t ${toString cfg.temperature.day}:${
|
||||||
|
toString cfg.temperature.night
|
||||||
|
}"
|
||||||
|
"-b ${toString cfg.brightness.day}:${toString cfg.brightness.night}"
|
||||||
|
] ++ cfg.extraOptions;
|
||||||
|
|
||||||
command = if cfg.tray then appletExecutable else mainExecutable;
|
command = if cfg.tray then appletExecutable else mainExecutable;
|
||||||
configFullPath = config.xdg.configHome + "/${xdgConfigFilePath}";
|
in "${cfg.package}/bin/${command} ${concatStringsSep " " args}";
|
||||||
in "${cfg.package}/bin/${command} -c ${configFullPath}";
|
|
||||||
RestartSec = 3;
|
RestartSec = 3;
|
||||||
Restart = "on-failure";
|
Restart = "on-failure";
|
||||||
};
|
};
|
||||||
|
|
|
@ -4,16 +4,14 @@ with lib;
|
||||||
|
|
||||||
let
|
let
|
||||||
commonOptions = import ./lib/options.nix {
|
commonOptions = import ./lib/options.nix {
|
||||||
inherit config lib pkgs;
|
inherit config lib;
|
||||||
|
|
||||||
moduleName = "redshift";
|
moduleName = "redshift";
|
||||||
programName = "Redshift";
|
programName = "Redshift";
|
||||||
mainSection = "redshift";
|
|
||||||
defaultPackage = pkgs.redshift;
|
defaultPackage = pkgs.redshift;
|
||||||
examplePackage = "pkgs.redshift";
|
examplePackage = "pkgs.redshift";
|
||||||
mainExecutable = "redshift";
|
mainExecutable = "redshift";
|
||||||
appletExecutable = "redshift-gtk";
|
appletExecutable = "redshift-gtk";
|
||||||
xdgConfigFilePath = "redshift/redshift.conf";
|
|
||||||
serviceDocumentation = "http://jonls.dk/redshift/";
|
serviceDocumentation = "http://jonls.dk/redshift/";
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
WantedBy=graphical-session.target
|
WantedBy=graphical-session.target
|
||||||
|
|
||||||
[Service]
|
[Service]
|
||||||
ExecStart=@gammastep@/bin/gammastep -c /home/hm-user/.config/gammastep/config.ini
|
ExecStart=@gammastep@/bin/gammastep -l 0.0:0.0 -t 5500:3700 -b 1:1
|
||||||
Restart=on-failure
|
Restart=on-failure
|
||||||
RestartSec=3
|
RestartSec=3
|
||||||
|
|
||||||
|
|
|
@ -1,11 +0,0 @@
|
||||||
[general]
|
|
||||||
adjustment-method=randr
|
|
||||||
gamma=0.800000
|
|
||||||
latitude=0.0
|
|
||||||
location-provider=manual
|
|
||||||
longitude=0.000000
|
|
||||||
temp-day=5500
|
|
||||||
temp-night=3700
|
|
||||||
|
|
||||||
[randr]
|
|
||||||
screen=0
|
|
|
@ -6,14 +6,7 @@
|
||||||
enable = true;
|
enable = true;
|
||||||
provider = "manual";
|
provider = "manual";
|
||||||
latitude = "0.0";
|
latitude = "0.0";
|
||||||
longitude = 0.0;
|
longitude = "0.0";
|
||||||
settings = {
|
|
||||||
general = {
|
|
||||||
adjustment-method = "randr";
|
|
||||||
gamma = 0.8;
|
|
||||||
};
|
|
||||||
randr = { screen = 0; };
|
|
||||||
};
|
|
||||||
};
|
};
|
||||||
|
|
||||||
nixpkgs.overlays = [
|
nixpkgs.overlays = [
|
||||||
|
@ -25,9 +18,6 @@
|
||||||
];
|
];
|
||||||
|
|
||||||
nmt.script = ''
|
nmt.script = ''
|
||||||
assertFileContent \
|
|
||||||
home-files/.config/gammastep/config.ini \
|
|
||||||
${./gammastep-basic-configuration-file-expected.conf}
|
|
||||||
assertFileContent \
|
assertFileContent \
|
||||||
home-files/.config/systemd/user/gammastep.service \
|
home-files/.config/systemd/user/gammastep.service \
|
||||||
${./gammastep-basic-configuration-expected.service}
|
${./gammastep-basic-configuration-expected.service}
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
WantedBy=graphical-session.target
|
WantedBy=graphical-session.target
|
||||||
|
|
||||||
[Service]
|
[Service]
|
||||||
ExecStart=@redshift@/bin/redshift -c /home/hm-user/.config/redshift/redshift.conf
|
ExecStart=@redshift@/bin/redshift -l 0.0:0.0 -t 5500:3700 -b 1:1
|
||||||
Restart=on-failure
|
Restart=on-failure
|
||||||
RestartSec=3
|
RestartSec=3
|
||||||
|
|
||||||
|
|
|
@ -1,11 +0,0 @@
|
||||||
[randr]
|
|
||||||
screen=0
|
|
||||||
|
|
||||||
[redshift]
|
|
||||||
adjustment-method=randr
|
|
||||||
gamma=0.800000
|
|
||||||
latitude=0.000000
|
|
||||||
location-provider=manual
|
|
||||||
longitude=0.0
|
|
||||||
temp-day=5500
|
|
||||||
temp-night=3700
|
|
|
@ -5,15 +5,8 @@
|
||||||
services.redshift = {
|
services.redshift = {
|
||||||
enable = true;
|
enable = true;
|
||||||
provider = "manual";
|
provider = "manual";
|
||||||
latitude = 0.0;
|
latitude = "0.0";
|
||||||
longitude = "0.0";
|
longitude = "0.0";
|
||||||
settings = {
|
|
||||||
redshift = {
|
|
||||||
adjustment-method = "randr";
|
|
||||||
gamma = 0.8;
|
|
||||||
};
|
|
||||||
randr = { screen = 0; };
|
|
||||||
};
|
|
||||||
};
|
};
|
||||||
|
|
||||||
nixpkgs.overlays = [
|
nixpkgs.overlays = [
|
||||||
|
@ -25,9 +18,6 @@
|
||||||
];
|
];
|
||||||
|
|
||||||
nmt.script = ''
|
nmt.script = ''
|
||||||
assertFileContent \
|
|
||||||
home-files/.config/redshift/redshift.conf \
|
|
||||||
${./redshift-basic-configuration-file-expected.conf}
|
|
||||||
assertFileContent \
|
assertFileContent \
|
||||||
home-files/.config/systemd/user/redshift.service \
|
home-files/.config/systemd/user/redshift.service \
|
||||||
${./redshift-basic-configuration-expected.service}
|
${./redshift-basic-configuration-expected.service}
|
||||||
|
|
Loading…
Reference in a new issue