1
0
Fork 0
mirror of https://github.com/nix-community/home-manager synced 2024-11-16 08:09:45 +01:00
home-manager/modules/programs/tmate.nix
Naïm Favier 2a6679aa9c
[23.05] modules: types.string throws error now (#4324) (#4343)
Since the merge of https://github.com/NixOS/nixpkgs/pull/247848

(cherry picked from commit 7b8d43fbaf)

Co-authored-by: Christian Albrecht <christian.albrecht@mayflower.de>
2023-08-15 13:45:05 +02:00

80 lines
2.2 KiB
Nix

{ config, lib, pkgs, ... }:
with lib;
let
cfg = config.programs.tmate;
in {
meta.maintainers = [ maintainers.jlesquembre ];
options = {
programs.tmate = {
enable = mkEnableOption "tmate";
package = mkOption {
type = types.package;
default = pkgs.tmate;
defaultText = literalExpression "pkgs.tmate";
example = literalExpression "pkgs.tmate";
description = "The tmate package to install.";
};
host = mkOption {
type = with types; nullOr str;
default = null;
example = literalExpression "tmate.io";
description = "Tmate server address.";
};
port = mkOption {
type = with types; nullOr port;
default = null;
example = 2222;
description = "Tmate server port.";
};
dsaFingerprint = mkOption {
type = with types; nullOr str;
default = null;
example = literalExpression
"SHA256:1111111111111111111111111111111111111111111";
description = "Tmate server EdDSA key fingerprint.";
};
rsaFingerprint = mkOption {
type = with types; nullOr str;
default = null;
example = literalExpression
"SHA256:1111111111111111111111111111111111111111111";
description = "Tmate server RSA key fingerprint.";
};
extraConfig = mkOption {
type = types.lines;
default = "";
description = ''
Additional content written at the end of
<filename>~/.tmate.conf</filename>.
'';
};
};
};
config = mkIf cfg.enable {
home.packages = [ cfg.package ];
home.file.".tmate.conf".text = let
conf =
optional (cfg.host != null) ''set -g tmate-server-host "${cfg.host}"''
++ optional (cfg.port != null)
"set -g tmate-server-port ${builtins.toString cfg.port}"
++ optional (cfg.dsaFingerprint != null)
''set -g tmate-server-ed25519-fingerprint "${cfg.dsaFingerprint}"''
++ optional (cfg.rsaFingerprint != null)
''set -g tmate-server-rsa-fingerprint "${cfg.rsaFingerprint}"''
++ optional (cfg.extraConfig != "") cfg.extraConfig;
in concatStringsSep "\n" conf + "\n";
};
}