Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add module for tofi #9

Merged
merged 1 commit into from
Feb 25, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
40 changes: 40 additions & 0 deletions modules/collection/programs/tofi.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
{
config,
lib,
pkgs,
...
}: let
inherit (lib.modules) mkIf;
inherit (lib.options) mkOption mkEnableOption mkPackageOption;
inherit (lib.generators) toKeyValue;
inherit (lib.rum.types) tofiSettingsType;

cfg = config.rum.programs.tofi;
in {
options.rum.programs.tofi = {
enable = mkEnableOption "tofi";

package = mkPackageOption pkgs "tofi" {};

settings = mkOption {
type = tofiSettingsType;
default = {};
example = {
text-color = "#FFFFFF";
num-results = 0;
horizontal = false;
};
description = ''
The configuration converted into "key = value" and written to
`${config.directory}/.config/tofi/config`.
Please reference tofi(5) (manpage) at https://github.com/philj56/tofi/blob/master/doc/tofi.5.md,
or see an example at https://github.com/philj56/tofi/blob/master/doc/config.
'';
};
};

config = mkIf cfg.enable {
packages = [cfg.package];
files.".config/tofi/config".text = mkIf (cfg.settings != {}) (toKeyValue cfg.settings);
};
}
1 change: 1 addition & 0 deletions modules/lib/types/default.nix
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
{lib}: {
gtkType = import ./gtkType.nix {inherit lib;};
tofiSettingsType = import ./tofiSettingsType.nix {inherit lib;};
}
11 changes: 11 additions & 0 deletions modules/lib/types/tofiSettingsType.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{lib}: let
inherit (lib.types) attrsOf oneOf str path bool int float;
in (
attrsOf (oneOf [
str
path
bool
int
float
])
)