irssi: add ssl_cert option for servers (#2043)

* irssi: add ssl_cert option for servers

I was following these instructions
https://www.oftc.net/NickServ/CertFP/
and found that the `/server add -ssl_cert` option was needed.

This patch therefore adds an optional
`programs.irssi.networks.<name>.server.ssl.certificateFile` path.

Perhaps this could also be done with a `settings` attribute, but that
would probably require most of this module to be reworked.

* irsii: Add example-settings test case
This commit is contained in:
Rodney Lorrimar 2021-06-07 07:31:25 +10:00 committed by GitHub
parent 7591c8041d
commit afb5fd962c
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 88 additions and 0 deletions

View file

@ -35,6 +35,9 @@ let
use_ssl = "${boolStr v.server.ssl.enable}";
ssl_verify = "${boolStr v.server.ssl.verify}";
autoconnect = "${boolStr v.server.autoConnect}";
${lib.optionalString (v.server.ssl.certificateFile != null) ''
ssl_cert = "${v.server.ssl.certificateFile}";
''}
}
''));
@ -118,6 +121,15 @@ let
default = true;
description = "Whether the SSL certificate should be verified.";
};
certificateFile = mkOption {
type = types.nullOr types.path;
default = null;
description = ''
Path to a file containing the certificate used for
client authentication to the server.
'';
};
};
autoConnect = mkOption {

View file

@ -55,6 +55,7 @@ import nmt {
./modules/programs/gpg
./modules/programs/htop
./modules/programs/i3status
./modules/programs/irsii
./modules/programs/kakoune
./modules/programs/kitty
./modules/programs/lf

View file

@ -0,0 +1 @@
{ irsii-example-settings = ./example-settings.nix; }

View file

@ -0,0 +1,43 @@
settings = {
core = {
settings_autosave = "no";
};
};
aliases = {
};
chatnets = {
oftc = {
type = "IRC";
nick = "nick";
autosendcmd = "";
};
};
servers = (
{
chatnet = "oftc";
address = "irc.oftc.net";
port = "6697";
use_ssl = "yes";
ssl_verify = "yes";
autoconnect = "yes";
ssl_cert = "/home/hm-user/.irssi/certs/nick.pem";
}
);
channels = (
{
chatnet = "oftc";
name = "home-manager";
autojoin = "yes";
}
);

View file

@ -0,0 +1,31 @@
{ config, lib, pkgs, ... }:
with lib;
{
config = {
programs.irssi = {
enable = true;
networks.oftc = {
nick = "nick";
server = {
address = "irc.oftc.net";
port = 6697;
autoConnect = true;
ssl.certificateFile =
"${config.home.homeDirectory}/.irssi/certs/nick.pem";
};
channels.home-manager.autoJoin = true;
};
};
nmt.script = ''
assertFileContent \
home-files/.irssi/config \
${./example-settings-expected.config}
'';
nixpkgs.overlays =
[ (self: super: { irsii = pkgs.writeScriptBin "dummy-irsii" ""; }) ];
};
}