Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 2 additions & 3 deletions .github/CODEOWNERS
Original file line number Diff line number Diff line change
Expand Up @@ -167,8 +167,6 @@

/modules/services/fluidsynth.nix @Valodim

/modules/services/gammastep.nix @petabyteboy

/modules/services/gnome-keyring.nix @rycee

/modules/services/gpg-agent.nix @rycee
Expand Down Expand Up @@ -215,7 +213,8 @@

/modules/services/random-background.nix @rycee

/modules/services/redshift.nix @rycee
/modules/services/redshift-gammastep @rycee @petabyteboy @thiagokokada
/tests/modules/redshift-gammastep @thiagokokada

/modules/services/status-notifier-watcher.nix @pltanton

Expand Down
4 changes: 2 additions & 2 deletions modules/modules.nix
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@ let
(loadModule ./services/emacs.nix { condition = hostPlatform.isLinux; })
(loadModule ./services/flameshot.nix { })
(loadModule ./services/fluidsynth.nix { condition = hostPlatform.isLinux; })
(loadModule ./services/gammastep.nix { condition = hostPlatform.isLinux; })
(loadModule ./services/redshift-gammastep/gammastep.nix { condition = hostPlatform.isLinux; })
(loadModule ./services/getmail.nix { condition = hostPlatform.isLinux; })
(loadModule ./services/gnome-keyring.nix { })
(loadModule ./services/gpg-agent.nix { })
Expand Down Expand Up @@ -178,7 +178,7 @@ let
(loadModule ./services/polybar.nix { })
(loadModule ./services/pulseeffects.nix { condition = hostPlatform.isLinux; })
(loadModule ./services/random-background.nix { })
(loadModule ./services/redshift.nix { })
(loadModule ./services/redshift-gammastep/redshift.nix { })
(loadModule ./services/rsibreak.nix { condition = hostPlatform.isLinux; })
(loadModule ./services/screen-locker.nix { })
(loadModule ./services/stalonetray.nix { })
Expand Down
166 changes: 0 additions & 166 deletions modules/services/gammastep.nix

This file was deleted.

22 changes: 22 additions & 0 deletions modules/services/redshift-gammastep/gammastep.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
{ config, lib, pkgs, ... }:

with lib;

let
commonOptions = import ./lib/options.nix {
inherit config lib;

moduleName = "gammastep";
programName = "Gammastep";
defaultPackage = pkgs.gammastep;
examplePackage = "pkgs.gammastep";
mainExecutable = "gammastep";
appletExecutable = "gammastep-indicator";
serviceDocumentation = "https://gitlab.com/chinstrap/gammastep/";
};

in {
meta = commonOptions.meta;
options.services.gammastep = commonOptions.options;
config = mkIf config.services.gammastep.enable commonOptions.config;
}
Original file line number Diff line number Diff line change
@@ -1,24 +1,27 @@
# Adapted from Nixpkgs.

{ config, lib, pkgs, ... }:
{ config, lib, moduleName, programName, defaultPackage, examplePackage
, mainExecutable, appletExecutable, serviceDocumentation }:

with lib;

let

cfg = config.services.redshift;
cfg = config.services.${moduleName};

in {
meta.maintainers = [ maintainers.rycee ];
meta = {
maintainers = with maintainers; [ rycee petabyteboy thiagokokada ];
};

options.services.redshift = {
options = {
enable = mkOption {
type = types.bool;
default = false;
example = true;
description = ''
Enable Redshift to change your screen's colour temperature depending on
the time of day.
Enable ${programName} to change your screen's colour temperature
depending on the time of day.
'';
};

Expand Down Expand Up @@ -81,6 +84,7 @@ in {
between <literal>0.1</literal> and <literal>1.0</literal>.
'';
};

night = mkOption {
type = types.str;
default = "1";
Expand All @@ -93,10 +97,10 @@ in {

package = mkOption {
type = types.package;
default = pkgs.redshift;
defaultText = literalExample "pkgs.redshift";
default = defaultPackage;
defaultText = literalExample examplePackage;
description = ''
redshift derivation to use.
${programName} derivation to use.
'';
};

Expand All @@ -105,7 +109,7 @@ in {
default = false;
example = true;
description = ''
Start the redshift-gtk tray applet.
Start the ${appletExecutable} tray applet.
'';
};

Expand All @@ -120,19 +124,19 @@ in {
};
};

config = mkIf cfg.enable {
config = {
assertions = [{
assertion = cfg.provider == "manual" -> cfg.latitude != null
&& cfg.longitude != null;
message = "Must provide services.redshift.latitude and"
+ " services.redshift.latitude when"
+ " services.redshift.provider is set to \"manual\".";
message = "Must provide services.${moduleName}.latitude and"
+ " services.${moduleName}.latitude when"
+ " services.${moduleName}.provider is set to \"manual\".";
}];

systemd.user.services.redshift = {
systemd.user.services.${moduleName} = {
Unit = {
Description = "Redshift colour temperature adjuster";
Documentation = "http://jonls.dk/redshift/";
Description = "${programName} colour temperature adjuster";
Documentation = serviceDocumentation;
After = [ "graphical-session-pre.target" ];
PartOf = [ "graphical-session.target" ];
};
Expand All @@ -154,12 +158,11 @@ in {
"-b ${toString cfg.brightness.day}:${toString cfg.brightness.night}"
] ++ cfg.extraOptions;

command = if cfg.tray then "redshift-gtk" else "redshift";
command = if cfg.tray then appletExecutable else mainExecutable;
in "${cfg.package}/bin/${command} ${concatStringsSep " " args}";
RestartSec = 3;
Restart = "on-failure";
};
};
};

}
22 changes: 22 additions & 0 deletions modules/services/redshift-gammastep/redshift.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
{ config, lib, pkgs, ... }:

with lib;

let
commonOptions = import ./lib/options.nix {
inherit config lib;

moduleName = "redshift";
programName = "Redshift";
defaultPackage = pkgs.redshift;
examplePackage = "pkgs.redshift";
mainExecutable = "redshift";
appletExecutable = "redshift-gtk";
serviceDocumentation = "http://jonls.dk/redshift/";
};

in {
meta = commonOptions.meta;
options.services.redshift = commonOptions.options;
config = mkIf config.services.redshift.enable commonOptions.config;
}
1 change: 1 addition & 0 deletions tests/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,7 @@ import nmt {
./modules/services/fluidsynth
./modules/services/kanshi
./modules/services/lieer
./modules/services/redshift-gammastep
./modules/services/pbgopy
./modules/services/polybar
./modules/services/sxhkd
Expand Down
4 changes: 4 additions & 0 deletions tests/modules/services/redshift-gammastep/default.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
gammastep-basic-configuration = ./gammastep-basic-configuration.nix;
redshift-basic-configuration = ./redshift-basic-configuration.nix;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
[Install]
WantedBy=graphical-session.target

[Service]
ExecStart=@gammastep@/bin/gammastep -l 0.0:0.0 -t 5500:3700 -b 1:1
Restart=on-failure
RestartSec=3

[Unit]
After=graphical-session-pre.target
Description=Gammastep colour temperature adjuster
Documentation=https://gitlab.com/chinstrap/gammastep/
PartOf=graphical-session.target
Loading