irssi: format using nixfmt
This commit is contained in:
parent
34327e067f
commit
275f955db9
7
format
7
format
|
@ -12,12 +12,9 @@ case $1 in
|
||||||
;;
|
;;
|
||||||
esac
|
esac
|
||||||
|
|
||||||
# The first block of excludes are files where nixfmt does a poor job,
|
# The excludes are for files touched by open pull requests and we want
|
||||||
# IMHO. The second block of excludes are files touched by open pull
|
# to avoid merge conflicts.
|
||||||
# requests and we want to avoid merge conflicts.
|
|
||||||
find . -name '*.nix' \
|
find . -name '*.nix' \
|
||||||
! -path ./modules/programs/irssi.nix \
|
|
||||||
\
|
|
||||||
! -path ./home-manager/home-manager.nix \
|
! -path ./home-manager/home-manager.nix \
|
||||||
! -path ./modules/default.nix \
|
! -path ./modules/default.nix \
|
||||||
! -path ./modules/files.nix \
|
! -path ./modules/files.nix \
|
||||||
|
|
|
@ -7,15 +7,18 @@ let
|
||||||
cfg = config.programs.irssi;
|
cfg = config.programs.irssi;
|
||||||
|
|
||||||
boolStr = b: if b then "yes" else "no";
|
boolStr = b: if b then "yes" else "no";
|
||||||
quoteStr = s: escape ["\""] s;
|
quoteStr = s: escape [ ''"'' ] s;
|
||||||
|
|
||||||
|
# Comma followed by newline.
|
||||||
|
cnl = ''
|
||||||
|
,
|
||||||
|
'';
|
||||||
|
|
||||||
assignFormat = set:
|
assignFormat = set:
|
||||||
concatStringsSep "\n"
|
concatStringsSep "\n"
|
||||||
(mapAttrsToList (k: v: " ${k} = \"${quoteStr v}\";") set);
|
(mapAttrsToList (k: v: " ${k} = \"${quoteStr v}\";") set);
|
||||||
|
|
||||||
chatnetString =
|
chatnetString = concatStringsSep "\n" (flip mapAttrsToList cfg.networks
|
||||||
concatStringsSep "\n"
|
|
||||||
(flip mapAttrsToList cfg.networks
|
|
||||||
(k: v: ''
|
(k: v: ''
|
||||||
${k} = {
|
${k} = {
|
||||||
type = "${v.type}";
|
type = "${v.type}";
|
||||||
|
@ -24,9 +27,7 @@ let
|
||||||
};
|
};
|
||||||
''));
|
''));
|
||||||
|
|
||||||
serversString =
|
serversString = concatStringsSep cnl (flip mapAttrsToList cfg.networks
|
||||||
concatStringsSep ",\n"
|
|
||||||
(flip mapAttrsToList cfg.networks
|
|
||||||
(k: v: ''
|
(k: v: ''
|
||||||
{
|
{
|
||||||
chatnet = "${k}";
|
chatnet = "${k}";
|
||||||
|
@ -35,19 +36,16 @@ let
|
||||||
use_ssl = "${boolStr v.server.ssl.enable}";
|
use_ssl = "${boolStr v.server.ssl.enable}";
|
||||||
ssl_verify = "${boolStr v.server.ssl.verify}";
|
ssl_verify = "${boolStr v.server.ssl.verify}";
|
||||||
autoconnect = "${boolStr v.server.autoConnect}";
|
autoconnect = "${boolStr v.server.autoConnect}";
|
||||||
${lib.optionalString (v.server.ssl.certificateFile != null) ''
|
${
|
||||||
|
lib.optionalString (v.server.ssl.certificateFile != null) ''
|
||||||
ssl_cert = "${v.server.ssl.certificateFile}";
|
ssl_cert = "${v.server.ssl.certificateFile}";
|
||||||
''}
|
''
|
||||||
|
}
|
||||||
}
|
}
|
||||||
''));
|
''));
|
||||||
|
|
||||||
channelString =
|
channelString = concatStringsSep cnl (flip mapAttrsToList cfg.networks (k: v:
|
||||||
concatStringsSep ",\n"
|
concatStringsSep cnl (flip mapAttrsToList v.channels (c: cv: ''
|
||||||
(flip mapAttrsToList cfg.networks
|
|
||||||
(k: v:
|
|
||||||
concatStringsSep ",\n"
|
|
||||||
(flip mapAttrsToList v.channels
|
|
||||||
(c: cv: ''
|
|
||||||
{
|
{
|
||||||
chatnet = "${k}";
|
chatnet = "${k}";
|
||||||
name = "${c}";
|
name = "${c}";
|
||||||
|
@ -72,7 +70,7 @@ let
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
networkType = types.submodule ({ name, ...}: {
|
networkType = types.submodule ({ name, ... }: {
|
||||||
options = {
|
options = {
|
||||||
name = mkOption {
|
name = mkOption {
|
||||||
visible = false;
|
visible = false;
|
||||||
|
@ -93,7 +91,7 @@ let
|
||||||
|
|
||||||
autoCommands = mkOption {
|
autoCommands = mkOption {
|
||||||
type = types.listOf types.str;
|
type = types.listOf types.str;
|
||||||
default = [];
|
default = [ ];
|
||||||
description = "List of commands to execute on connect.";
|
description = "List of commands to execute on connect.";
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -142,14 +140,12 @@ let
|
||||||
channels = mkOption {
|
channels = mkOption {
|
||||||
description = "Channels for the given network.";
|
description = "Channels for the given network.";
|
||||||
type = types.attrsOf channelType;
|
type = types.attrsOf channelType;
|
||||||
default = {};
|
default = { };
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
});
|
});
|
||||||
|
|
||||||
in
|
in {
|
||||||
|
|
||||||
{
|
|
||||||
|
|
||||||
options = {
|
options = {
|
||||||
programs.irssi = {
|
programs.irssi = {
|
||||||
|
@ -162,14 +158,17 @@ in
|
||||||
};
|
};
|
||||||
|
|
||||||
aliases = mkOption {
|
aliases = mkOption {
|
||||||
default = {};
|
default = { };
|
||||||
example = { J = "join"; BYE = "quit";};
|
example = {
|
||||||
|
J = "join";
|
||||||
|
BYE = "quit";
|
||||||
|
};
|
||||||
description = "An attribute set that maps aliases to commands.";
|
description = "An attribute set that maps aliases to commands.";
|
||||||
type = types.attrsOf types.str;
|
type = types.attrsOf types.str;
|
||||||
};
|
};
|
||||||
|
|
||||||
networks = mkOption {
|
networks = mkOption {
|
||||||
default = {};
|
default = { };
|
||||||
example = literalExpression ''
|
example = literalExpression ''
|
||||||
{
|
{
|
||||||
freenode = {
|
freenode = {
|
||||||
|
|
Loading…
Reference in a new issue