nixos/home/modules/redshift.nix

43 lines
1.1 KiB
Nix
Raw Normal View History

2024-07-24 07:18:22 +00:00
{ 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";
};
};
}