diff --git a/modules/programs/trippy.nix b/modules/programs/trippy.nix new file mode 100644 index 00000000..0cb67bd8 --- /dev/null +++ b/modules/programs/trippy.nix @@ -0,0 +1,57 @@ +{ + lib, + pkgs, + config, + ... +}: +let + inherit (lib) + mkIf + mkEnableOption + mkPackageOption + mkOption + ; + + cfg = config.programs.trippy; + tomlFormat = pkgs.formats.toml { }; +in +{ + meta.maintainers = with lib.hm.maintainers; [ aguirre-matteo ]; + + options.programs.trippy = { + enable = mkEnableOption "trippy"; + package = mkPackageOption pkgs "trippy" { nullable = true; }; + settings = mkOption { + type = tomlFormat.type; + default = { }; + example = { + theme-colors = { + bg-color = "black"; + border-color = "gray"; + text-color = "gray"; + tab-text-color = "green"; + }; + bindings = { + toggle-help = "h"; + toggle-help-alt = "?"; + toggle-settings = "s"; + toggle-settings-tui = "1"; + toggle-settings-trace = "2"; + toggle-settings-dns = "3"; + toggle-settings-geoip = "4"; + }; + }; + description = '' + Configuration settings for trippy. All the available options can be found + here: + ''; + }; + }; + + config = mkIf cfg.enable { + home.packages = mkIf (cfg.package != null) [ cfg.package ]; + xdg.configFile."trippy/trippy.toml" = mkIf (cfg.settings != { }) { + source = tomlFormat.generate "trippy-config" cfg.settings; + }; + }; +} diff --git a/tests/modules/programs/trippy/default.nix b/tests/modules/programs/trippy/default.nix new file mode 100644 index 00000000..982dca90 --- /dev/null +++ b/tests/modules/programs/trippy/default.nix @@ -0,0 +1 @@ +{ trippy-example = ./example-config.nix; } diff --git a/tests/modules/programs/trippy/example-config.nix b/tests/modules/programs/trippy/example-config.nix new file mode 100644 index 00000000..45b01dd9 --- /dev/null +++ b/tests/modules/programs/trippy/example-config.nix @@ -0,0 +1,28 @@ +{ + programs.trippy = { + enable = true; + settings = { + theme-colors = { + bg-color = "black"; + border-color = "gray"; + text-color = "gray"; + tab-text-color = "green"; + }; + bindings = { + toggle-help = "h"; + toggle-help-alt = "?"; + toggle-settings = "s"; + toggle-settings-tui = "1"; + toggle-settings-trace = "2"; + toggle-settings-dns = "3"; + toggle-settings-geoip = "4"; + }; + }; + }; + + nmt.script = '' + assertFileExists home-files/.config/trippy/trippy.toml + assertFileContent home-files/.config/trippy/trippy.toml \ + ${./trippy.toml} + ''; +} diff --git a/tests/modules/programs/trippy/trippy.toml b/tests/modules/programs/trippy/trippy.toml new file mode 100644 index 00000000..eb9b5ecc --- /dev/null +++ b/tests/modules/programs/trippy/trippy.toml @@ -0,0 +1,14 @@ +[bindings] +toggle-help = "h" +toggle-help-alt = "?" +toggle-settings = "s" +toggle-settings-dns = "3" +toggle-settings-geoip = "4" +toggle-settings-trace = "2" +toggle-settings-tui = "1" + +[theme-colors] +bg-color = "black" +border-color = "gray" +tab-text-color = "green" +text-color = "gray"