fork/home-manager

git clone https://git.julia.blue/fork/home-manager

Robert HelgessonMerge PR #421575790441

master
1.7 KiB65 linesraw
1{ config, lib, pkgs, ... }:
2
3with lib;
4let
5  cfg = config.programs.tiny;
6  format = pkgs.formats.yaml { };
7  configDir = if pkgs.stdenv.isDarwin then
8    "Library/Application Support/tiny"
9  else
10    "${config.xdg.configHome}/tiny";
11in {
12  meta.maintainers = [ hm.maintainers.kmaasrud ];
13
14  options = {
15    programs.tiny = {
16      enable = mkEnableOption "tiny, a TUI IRC client written in Rust";
17
18      package = mkOption {
19        type = types.package;
20        default = pkgs.tiny;
21        defaultText = literalExpression "pkgs.tiny";
22        description = "The {command}`tiny` package to install.";
23      };
24
25      settings = mkOption {
26        type = format.type;
27        default = { };
28        defaultText = literalExpression "{ }";
29        example = literalExpression ''
30          {
31            servers = [
32              {
33                addr = "irc.libera.chat";
34                port = 6697;
35                tls = true;
36                realname = "John Doe";
37                nicks = [ "tinyuser" ];
38              }
39            ];
40            defaults = {
41              nicks = [ "tinyuser" ];
42              realname = "John Doe";
43              join = [];
44              tls = true;
45            };
46          };
47        '';
48        description = ''
49          Configuration written to
50          {file}`$XDG_CONFIG_HOME/tiny/config.yml`. See
51          <https://github.com/osa1/tiny/blob/master/crates/tiny/config.yml>
52          for the default configuration.
53        '';
54      };
55    };
56  };
57
58  config = mkIf cfg.enable {
59    home.packages = [ cfg.package ];
60
61    home.file."${configDir}/config.yml" = mkIf (cfg.settings != { }) {
62      source = format.generate "tiny-config" cfg.settings;
63    };
64  };
65}