{ 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; }; }; }