summaryrefslogtreecommitdiff
path: root/modules/zcfan.nix
blob: d26c07d41f1c27d72d7514fb166667b7d6351fc5 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
{ lib, config, pkgs, ... }:

let cfg = config.this.laptop.zcfan;
    mkConf = c: lib.generators.toKeyValue {
      mkKeyValue = lib.generators.mkKeyValueDefault {} " ";
    } c;
    conf = mkConf cfg.settings;
in
{
  options = {
    this.laptop.zcfan.enable = lib.mkEnableOption "zcfan";
    this.laptop.zcfan.settings = lib.mkOption {
      type = with lib.types;
        attrsOf (oneOf [int str]);
      default = { };
      description = "Settings for zcfan.";
    };
  };

  config = lib.mkIf cfg.enable {
    environment.etc."zcfan.conf" = lib.mkIf (conf != "") { text = conf; };
    environment.systemPackages = [ pkgs.zcfan ];
    systemd.packages = [ pkgs.zcfan ];
  };
}