redshift: create module
This commit is contained in:
parent
f2699971d4
commit
9ce514aa6d
1 changed files with 42 additions and 0 deletions
42
home/modules/redshift.nix
Normal file
42
home/modules/redshift.nix
Normal file
|
@ -0,0 +1,42 @@
|
|||
{ lib, config, pkgs, ... }:
|
||||
|
||||
let
|
||||
cfg = config.snowhawk.redshift;
|
||||
cfgDir = config.xdg.configHome + "/redshift";
|
||||
in
|
||||
{
|
||||
options.snowhawk.redshift = {
|
||||
enable = lib.mkEnableOption "redshift home-manager module";
|
||||
};
|
||||
|
||||
config = lib.mkIf cfg.enable {
|
||||
systemd.user.services.redshift = {
|
||||
Unit = {
|
||||
Description = "redshift service";
|
||||
PartOf = [ "graphical-session.target" ];
|
||||
};
|
||||
Service = {
|
||||
Type = "exec";
|
||||
ExecStart =
|
||||
let
|
||||
catFile = file: "$(${pkgs.coreutils}/bin/cat ${file})";
|
||||
toPaths = deg: "${cfgDir}/${deg}";
|
||||
fetchLatLon = lib.right
|
||||
(lib.strings.concatStringsSep ":")
|
||||
(map catFile)
|
||||
(map toPaths)
|
||||
[ "lat" "lon" ];
|
||||
in
|
||||
"${pkgs.redshift}/bin/redshift -l ${fetchLatLon}";
|
||||
};
|
||||
Install = {
|
||||
WantedBy = [ "graphical-session.target" ];
|
||||
};
|
||||
};
|
||||
|
||||
sops.secrets = {
|
||||
"locations/snowhawk/lat".path = "${cfgDir}/lat";
|
||||
"locations/snowhawk/lon".path = "${cfgDir}/lon";
|
||||
};
|
||||
};
|
||||
}
|
Loading…
Reference in a new issue