fork/home-manager
git clone https://git.julia.blue/fork/home-manager
75790441
master
1{ config , lib , pkgs , ...} : 2 3with lib ; 4 5let cfg = config . services . wlsunset ; 6 7in { 8meta . maintainers = [ hm . maintainers . matrss ]; 9 10options . services . wlsunset = { 11enable = mkEnableOption "wlsunset" ; 12 13package = mkOption { 14type = types . package ; 15default = pkgs . wlsunset ; 16defaultText = "pkgs.wlsunset" ; 17description = '' 18wlsunset derivation to use. 19'' ; 20}; 21 22latitude = mkOption { 23type = types . str ; 24description = '' 25Your current latitude, between `-90.0` and 26`90.0`. 27'' ; 28}; 29 30longitude = mkOption { 31type = types . str ; 32description = '' 33Your current longitude, between `-180.0` and 34`180.0`. 35'' ; 36}; 37 38temperature = { 39day = mkOption { 40type = types . int ; 41default = 6500 ; 42description = '' 43Colour temperature to use during the day, in Kelvin (K). 44This value must be greater than `temperature.night`. 45'' ; 46}; 47 48night = mkOption { 49type = types . int ; 50default = 4000 ; 51description = '' 52Colour temperature to use during the night, in Kelvin (K). 53This value must be smaller than `temperature.day`. 54'' ; 55}; 56}; 57 58gamma = mkOption { 59type = types . str ; 60default = "1.0" ; 61description = '' 62Gamma value to use. 63'' ; 64}; 65 66systemdTarget = mkOption { 67type = types . str ; 68default = "graphical-session.target" ; 69description = '' 70Systemd target to bind to. 71'' ; 72}; 73}; 74 75config = mkIf cfg . enable { 76assertions = [ 77( lib . hm . assertions . assertPlatform "services.wlsunset" pkgs 78lib . platforms . linux ) 79]; 80 81systemd . user . services . wlsunset = { 82Unit = { 83Description = "Day/night gamma adjustments for Wayland compositors." ; 84PartOf = [ "graphical-session.target" ]; 85}; 86 87Service = { 88ExecStart = let 89args = [ 90"-l ${ cfg . latitude } " 91"-L ${ cfg . longitude } " 92"-t ${ toString cfg . temperature . night } " 93"-T ${ toString cfg . temperature . day } " 94"-g ${ cfg . gamma } " 95]; 96in " ${ cfg . package } /bin/wlsunset ${ concatStringsSep " " args } " ; 97}; 98 99Install = { WantedBy = [ cfg . systemdTarget ]; }; 100}; 101}; 102}