fork/home-manager

git clone https://git.julia.blue/fork/home-manager

Robert HelgessonMerge PR #421575790441

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