fork/home-manager

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

Christian Albrechtmodules: types.string throws error now (#4324)7b8d43fb

master
2.2 KiB80 linesraw
1{ config, lib, pkgs, ... }:
2
3with lib;
4
5let
6
7  cfg = config.programs.tmate;
8
9in {
10  meta.maintainers = [ maintainers.jlesquembre ];
11
12  options = {
13    programs.tmate = {
14      enable = mkEnableOption "tmate";
15
16      package = mkOption {
17        type = types.package;
18        default = pkgs.tmate;
19        defaultText = literalExpression "pkgs.tmate";
20        example = literalExpression "pkgs.tmate";
21        description = "The tmate package to install.";
22      };
23
24      host = mkOption {
25        type = with types; nullOr str;
26        default = null;
27        example = literalExpression "tmate.io";
28        description = "Tmate server address.";
29      };
30
31      port = mkOption {
32        type = with types; nullOr port;
33        default = null;
34        example = 2222;
35        description = "Tmate server port.";
36      };
37
38      dsaFingerprint = mkOption {
39        type = with types; nullOr str;
40        default = null;
41        example = literalExpression
42          "SHA256:1111111111111111111111111111111111111111111";
43        description = "Tmate server EdDSA key fingerprint.";
44      };
45
46      rsaFingerprint = mkOption {
47        type = with types; nullOr str;
48        default = null;
49        example = literalExpression
50          "SHA256:1111111111111111111111111111111111111111111";
51        description = "Tmate server RSA key fingerprint.";
52      };
53
54      extraConfig = mkOption {
55        type = types.lines;
56        default = "";
57        description = ''
58          Additional content written at the end of
59          {file}`~/.tmate.conf`.
60        '';
61      };
62    };
63  };
64
65  config = mkIf cfg.enable {
66    home.packages = [ cfg.package ];
67
68    home.file.".tmate.conf" = let
69      conf =
70        optional (cfg.host != null) ''set -g tmate-server-host "${cfg.host}"''
71        ++ optional (cfg.port != null)
72        "set -g tmate-server-port ${builtins.toString cfg.port}"
73        ++ optional (cfg.dsaFingerprint != null)
74        ''set -g tmate-server-ed25519-fingerprint "${cfg.dsaFingerprint}"''
75        ++ optional (cfg.rsaFingerprint != null)
76        ''set -g tmate-server-rsa-fingerprint "${cfg.rsaFingerprint}"''
77        ++ optional (cfg.extraConfig != "") cfg.extraConfig;
78    in mkIf (conf != [ ]) { text = concatLines conf; };
79  };
80}