senpai: switch to scfg format
This commit is contained in:
parent
029545350c
commit
ca922258e1
15 changed files with 275 additions and 20 deletions
|
|
@ -2,9 +2,7 @@
|
|||
|
||||
with lib;
|
||||
|
||||
let
|
||||
cfg = config.programs.senpai;
|
||||
cfgFmt = pkgs.formats.yaml { };
|
||||
let cfg = config.programs.senpai;
|
||||
in {
|
||||
options.programs.senpai = {
|
||||
enable = mkEnableOption "senpai";
|
||||
|
|
@ -16,23 +14,30 @@ in {
|
|||
};
|
||||
config = mkOption {
|
||||
type = types.submodule {
|
||||
freeformType = cfgFmt.type;
|
||||
freeformType = types.attrsOf types.anything;
|
||||
options = {
|
||||
addr = mkOption {
|
||||
address = mkOption {
|
||||
type = types.str;
|
||||
description = ''
|
||||
The address (host[:port]) of the IRC server. senpai uses TLS
|
||||
connections by default unless you specify no-tls option. TLS
|
||||
connections default to port 6697, plain-text use port 6667.
|
||||
The address (`host[:port]`) of the IRC server. senpai uses TLS
|
||||
connections by default unless you specify tls option to be false.
|
||||
TLS connections default to port 6697, plain-text use port 6667.
|
||||
|
||||
UR`ircs://`, `irc://`, and `irc+insecure://` URLs are supported,
|
||||
in which case only the hostname and port parts will be used. If
|
||||
the scheme is `ircs/irc+insecure`, tls will be overriden and set
|
||||
to true/false accordingly.
|
||||
'';
|
||||
};
|
||||
nick = mkOption {
|
||||
|
||||
nickname = mkOption {
|
||||
type = types.str;
|
||||
description = ''
|
||||
Your nickname, sent with a NICK IRC message. It mustn't contain
|
||||
spaces or colons (:).
|
||||
'';
|
||||
};
|
||||
|
||||
password = mkOption {
|
||||
type = types.nullOr types.str;
|
||||
default = null;
|
||||
|
|
@ -41,17 +46,28 @@ in {
|
|||
reside world-readable in the Nix store.
|
||||
'';
|
||||
};
|
||||
no-tls = mkOption {
|
||||
type = types.bool;
|
||||
default = false;
|
||||
description = "Disables TLS encryption.";
|
||||
|
||||
password-cmd = mkOption {
|
||||
type = types.nullOr (types.listOf types.str);
|
||||
default = null;
|
||||
example = [ "gopass" "show" "irc/guest" ];
|
||||
description = ''
|
||||
Alternatively to providing your SASL authentication password
|
||||
directly in plaintext, you can specify a command to be run to
|
||||
fetch the password at runtime. This is useful if you store your
|
||||
passwords in a separate (probably encrypted) file using `gpg` or a
|
||||
command line password manager such as `pass` or `gopass`. If a
|
||||
password-cmd is provided, the value of password will be ignored
|
||||
and the first line of the output of `password-cmd` will be used
|
||||
for login.
|
||||
'';
|
||||
};
|
||||
};
|
||||
};
|
||||
example = literalExpression ''
|
||||
{
|
||||
addr = "libera.chat:6697";
|
||||
nick = "nicholas";
|
||||
address = "libera.chat:6697";
|
||||
nickname = "nicholas";
|
||||
password = "verysecurepassword";
|
||||
}
|
||||
'';
|
||||
|
|
@ -63,9 +79,27 @@ in {
|
|||
};
|
||||
|
||||
config = mkIf cfg.enable {
|
||||
assertions = with cfg.config; [
|
||||
{
|
||||
assertion = !isNull password-cmd -> isNull password;
|
||||
message = "senpai: password-cmd overrides password!";
|
||||
}
|
||||
{
|
||||
assertion = !cfg.config ? addr;
|
||||
message = "senpai: addr is deprecated, use address instead";
|
||||
}
|
||||
{
|
||||
assertion = !cfg.config ? nick;
|
||||
message = "senpai: nick is deprecated, use nickname instead";
|
||||
}
|
||||
{
|
||||
assertion = !cfg.config ? no-tls;
|
||||
message = "senpai: no-tls is deprecated, use tls instead";
|
||||
}
|
||||
];
|
||||
home.packages = [ cfg.package ];
|
||||
xdg.configFile."senpai/senpai.yaml".source =
|
||||
cfgFmt.generate "senpai.yaml" cfg.config;
|
||||
xdg.configFile."senpai/senpai.scfg".text =
|
||||
lib.hm.generators.toSCFG { } cfg.config;
|
||||
};
|
||||
|
||||
meta.maintainers = [ hm.maintainers.malvo ];
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue