From 910292fe342071f83d6906c7ca24864eba28676a Mon Sep 17 00:00:00 2001 From: Aguirre Matteo <158215792+aguirre-matteo@users.noreply.github.com> Date: Sun, 11 May 2025 23:52:09 +0000 Subject: [PATCH] halloy: add module (#7034) --- modules/modules.nix | 1 + modules/programs/halloy.nix | 49 +++++++++++++++++++ tests/default.nix | 1 + tests/modules/programs/halloy/default.nix | 1 + .../programs/halloy/example-config.nix | 19 +++++++ .../programs/halloy/example-config.toml | 7 +++ 6 files changed, 78 insertions(+) create mode 100644 modules/programs/halloy.nix create mode 100644 tests/modules/programs/halloy/default.nix create mode 100644 tests/modules/programs/halloy/example-config.nix create mode 100644 tests/modules/programs/halloy/example-config.toml diff --git a/modules/modules.nix b/modules/modules.nix index 2d18bd20..b36a8d40 100644 --- a/modules/modules.nix +++ b/modules/modules.nix @@ -127,6 +127,7 @@ let ./programs/gpg.nix ./programs/gradle.nix ./programs/granted.nix + ./programs/halloy.nix ./programs/havoc.nix ./programs/helix.nix ./programs/hexchat.nix diff --git a/modules/programs/halloy.nix b/modules/programs/halloy.nix new file mode 100644 index 00000000..4ea21ebb --- /dev/null +++ b/modules/programs/halloy.nix @@ -0,0 +1,49 @@ +{ + lib, + pkgs, + config, + ... +}: +let + inherit (lib) + mkIf + mkEnableOption + mkPackageOption + mkOption + ; + + cfg = config.programs.halloy; + + formatter = pkgs.formats.toml { }; +in +{ + meta.maintainers = with lib.hm.maintainers; [ aguirre-matteo ]; + + options.programs.halloy = { + enable = mkEnableOption "halloy"; + package = mkPackageOption pkgs "halloy" { nullable = true; }; + settings = mkOption { + type = formatter.type; + default = { }; + example = { + "buffer.channel.topic".enabled = true; + "servers.liberachat" = { + nickname = "halloy-user"; + server = "irc.libera.chat"; + channels = [ "#halloy" ]; + }; + }; + description = '' + Configuration settings for halloy. All available options can be + found here: . + ''; + }; + }; + + config = mkIf cfg.enable { + home.packages = mkIf (cfg.package != null) [ cfg.package ]; + xdg.configFile."halloy/config.toml" = mkIf (cfg.settings != { }) { + source = formatter.generate "halloy-config" cfg.settings; + }; + }; +} diff --git a/tests/default.nix b/tests/default.nix index afa98fc7..2c89cc4e 100644 --- a/tests/default.nix +++ b/tests/default.nix @@ -371,6 +371,7 @@ import nmtSrc { ./modules/programs/getmail ./modules/programs/gnome-shell ./modules/programs/gnome-terminal + ./modules/programs/halloy ./modules/programs/hexchat ./modules/programs/hyprlock ./modules/programs/i3bar-river diff --git a/tests/modules/programs/halloy/default.nix b/tests/modules/programs/halloy/default.nix new file mode 100644 index 00000000..2d65b55d --- /dev/null +++ b/tests/modules/programs/halloy/default.nix @@ -0,0 +1 @@ +{ halloy-example-config = ./example-config.nix; } diff --git a/tests/modules/programs/halloy/example-config.nix b/tests/modules/programs/halloy/example-config.nix new file mode 100644 index 00000000..1bd90548 --- /dev/null +++ b/tests/modules/programs/halloy/example-config.nix @@ -0,0 +1,19 @@ +{ + programs.halloy = { + enable = true; + settings = { + buffer.channel.topic.enabled = true; + servers.liberachat = { + nickname = "halloy-user"; + server = "irc.libera.chat"; + channels = [ "#halloy" ]; + }; + }; + }; + + nmt.script = '' + assertFileExists home-files/.config/halloy/config.toml + assertFileContent home-files/.config/halloy/config.toml \ + ${./example-config.toml} + ''; +} diff --git a/tests/modules/programs/halloy/example-config.toml b/tests/modules/programs/halloy/example-config.toml new file mode 100644 index 00000000..380c3623 --- /dev/null +++ b/tests/modules/programs/halloy/example-config.toml @@ -0,0 +1,7 @@ +[buffer.channel.topic] +enabled = true + +[servers.liberachat] +channels = ["#halloy"] +nickname = "halloy-user" +server = "irc.libera.chat"