aboutsummaryrefslogtreecommitdiff
path: root/share/hm-modules/tofi.nix
blob: 4d6dbee68298d63ee26226c48fab6e0c6153e85c (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
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
{ config, lib, pkgs, ... }:
with lib;
let
  cfg = config.programs.tofi;

  format = pkgs.formats.keyValue {
    mkKeyValue = generators.mkKeyValueDefault
      {
        mkValueString = v:
          if builtins.isBool v then
            if v then "true" else "false"
          else if builtins.isString v then
            ''"${v}"''
          else generators.mkValueStringDefault { } v;
      } "=";
  };

  configFile = format.generate "config" cfg.settings;
in
{
  options.programs.tofi = {
    enable = mkEnableOption
      "tofi - An extremely fast and simple dmenu/rofi.";

    package = mkOption {
      default = pkgs.tofi;
      defaultText = literalExpression "pkgs.tofi";
      type = types.package;
      example = literalExpression "pkgs.tofi";
      description = "The package to use for the tofi binaries.";
    };

    settings = mkOption {
      inherit (format) type;
      default = { };
      description = lib.mdDoc ''
        Tofi configuration. Refer to tofi(5) for supported values.
      '';
      example = {
        font = "Fira Code";
        font-size = "22";

        width = "1920";
        terminal = "kitty";
      };
    };
  };

  config = mkIf cfg.enable {
    home.packages = [ cfg.package ];
    xdg.configFile.tofi-config = {
      enable = true;
      target = "tofi/config";
      source = configFile;
    };
  };
}