From 1d90b6065a0e8713b21cffd7af4f03e31894ae8b Mon Sep 17 00:00:00 2001 From: kmaasrud Date: Sat, 26 Feb 2022 23:42:01 +0100 Subject: [PATCH] tiny: add module (#2735) Added module for tiny, a TUI IRC client written in Rust. Thanks to @ratsclub for helping me write my first Nix module! --- .github/CODEOWNERS | 2 ++ modules/lib/maintainers.nix | 6 ++++ modules/modules.nix | 1 + modules/programs/tiny.nix | 65 +++++++++++++++++++++++++++++++++++++ 4 files changed, 74 insertions(+) create mode 100644 modules/programs/tiny.nix diff --git a/.github/CODEOWNERS b/.github/CODEOWNERS index b3e45d6f4..f21753301 100644 --- a/.github/CODEOWNERS +++ b/.github/CODEOWNERS @@ -236,6 +236,8 @@ /modules/programs/timidity.nix @amesgen +/modules/programs/tiny.nix @kmaasrud + /modules/programs/topgrade.nix @msfjarvis /tests/modules/programs/topgrade @msfjarvis diff --git a/modules/lib/maintainers.nix b/modules/lib/maintainers.nix index 1c655f91d..8beb5a9ea 100644 --- a/modules/lib/maintainers.nix +++ b/modules/lib/maintainers.nix @@ -217,4 +217,10 @@ github = "mainrs"; githubId = 5113257; }; + kmaasrud = { + name = "Knut Magnus Aasrud"; + email = "km@aasrud.com"; + github = "kmaasrud"; + githubId = 54394333; + }; } diff --git a/modules/modules.nix b/modules/modules.nix index a43c9e3d5..26777a14f 100644 --- a/modules/modules.nix +++ b/modules/modules.nix @@ -150,6 +150,7 @@ let ./programs/texlive.nix ./programs/timidity.nix ./programs/tint2.nix + ./programs/tiny.nix ./programs/tmux.nix ./programs/topgrade.nix ./programs/urxvt.nix diff --git a/modules/programs/tiny.nix b/modules/programs/tiny.nix new file mode 100644 index 000000000..d502801f9 --- /dev/null +++ b/modules/programs/tiny.nix @@ -0,0 +1,65 @@ +{ config, lib, pkgs, ... }: + +with lib; +let + cfg = config.programs.tiny; + format = pkgs.formats.yaml { }; + configDir = if pkgs.stdenv.isDarwin then + "Library/Application Support/tiny" + else + "${config.xdg.configHome}/tiny"; +in { + meta.maintainers = [ hm.maintainers.kmaasrud ]; + + options = { + programs.tiny = { + enable = mkEnableOption "tiny, a TUI IRC client written in Rust"; + + package = mkOption { + type = types.package; + default = pkgs.tiny; + defaultText = literalExpression "pkgs.tiny"; + description = "The tiny package to install."; + }; + + settings = mkOption { + type = format.type; + default = { }; + defaultText = literalExpression "{ }"; + example = literalExpression '' + { + servers = [ + { + addr = "irc.libera.chat"; + port = 6697; + tls = true; + realname = "John Doe"; + nicks = [ "tinyuser" ]; + } + ]; + defaults = { + nicks = [ "tinyuser" ]; + realname = "John Doe"; + join = []; + tls = true; + }; + }; + ''; + description = '' + Configuration written to + $XDG_CONFIG_HOME/tiny/config.yml. See + + for the default configuration. + ''; + }; + }; + }; + + config = mkIf cfg.enable { + home.packages = [ cfg.package ]; + + home.file."${configDir}/config.yml" = mkIf (cfg.settings != { }) { + source = format.generate "tiny-config" cfg.settings; + }; + }; +}