1
0
Fork 0
mirror of https://github.com/nix-community/home-manager synced 2024-11-26 21:19:45 +01:00

irssi: format using nixfmt

This commit is contained in:
Robert Helgesson 2021-10-31 10:32:58 +01:00
parent 34327e067f
commit 275f955db9
No known key found for this signature in database
GPG key ID: 36BDAA14C2797E89
2 changed files with 50 additions and 54 deletions

7
format
View file

@ -12,12 +12,9 @@ case $1 in
;;
esac
# The first block of excludes are files where nixfmt does a poor job,
# IMHO. The second block of excludes are files touched by open pull
# requests and we want to avoid merge conflicts.
# The excludes are for files touched by open pull requests and we want
# to avoid merge conflicts.
find . -name '*.nix' \
! -path ./modules/programs/irssi.nix \
\
! -path ./home-manager/home-manager.nix \
! -path ./modules/default.nix \
! -path ./modules/files.nix \

View file

@ -7,15 +7,18 @@ let
cfg = config.programs.irssi;
boolStr = b: if b then "yes" else "no";
quoteStr = s: escape ["\""] s;
quoteStr = s: escape [ ''"'' ] s;
# Comma followed by newline.
cnl = ''
,
'';
assignFormat = set:
concatStringsSep "\n"
(mapAttrsToList (k: v: " ${k} = \"${quoteStr v}\";") set);
chatnetString =
concatStringsSep "\n"
(flip mapAttrsToList cfg.networks
chatnetString = concatStringsSep "\n" (flip mapAttrsToList cfg.networks
(k: v: ''
${k} = {
type = "${v.type}";
@ -24,9 +27,7 @@ let
};
''));
serversString =
concatStringsSep ",\n"
(flip mapAttrsToList cfg.networks
serversString = concatStringsSep cnl (flip mapAttrsToList cfg.networks
(k: v: ''
{
chatnet = "${k}";
@ -35,19 +36,16 @@ 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) ''
${
lib.optionalString (v.server.ssl.certificateFile != null) ''
ssl_cert = "${v.server.ssl.certificateFile}";
''}
''
}
}
''));
channelString =
concatStringsSep ",\n"
(flip mapAttrsToList cfg.networks
(k: v:
concatStringsSep ",\n"
(flip mapAttrsToList v.channels
(c: cv: ''
channelString = concatStringsSep cnl (flip mapAttrsToList cfg.networks (k: v:
concatStringsSep cnl (flip mapAttrsToList v.channels (c: cv: ''
{
chatnet = "${k}";
name = "${c}";
@ -147,9 +145,7 @@ let
};
});
in
{
in {
options = {
programs.irssi = {
@ -163,7 +159,10 @@ in
aliases = mkOption {
default = { };
example = { J = "join"; BYE = "quit";};
example = {
J = "join";
BYE = "quit";
};
description = "An attribute set that maps aliases to commands.";
type = types.attrsOf types.str;
};