{ pkgs, lib, ... }: with lib; let networks = [ "bitlbee" "freenode" "hackint" "indymedia" "oftc" ]; toWeeChat = value: /**/ if value == true then "on" else if value == false then "off" else if isList value then concatStringsSep "," value else toString value; sec = [ "znc.username" "znc.password" "slack.api_tokens" ]; cfgin = { alias.cmd.B = "buffer"; irc.look.buffer_switch_autojoin = false; irc.look.display_join_message = false; irc.look.server_buffer = "independent"; irc.look.temporary_servers = true; irc.server_default = { addresses = "znc.qyliss.net/6697"; autoconnect = true; capabilities = [ "account-notify" "away-notify" "cap-notify" "multi-prefix" "server-time" "znc.in/server-time-iso" "znc.in/self-message" "znc.in/playback" ]; nicks = "qyliss"; password = "\\\${sec.data.znc.password}"; ssl = true; username = "\\\${sec.data.znc.username}"; }; irc.server = genAttrs networks (s: { username = "'\\\${sec.data.znc.username}/${s}'"; }); plugins.var.python.zncplayback.servers = networks; logger.color.backlog_end = "*default"; logger.look.backlog = 200; plugins.var.python.slack.slack_api_token = "\\\${sec.data.slack.api_tokens}"; plugins.var.python.slack.auto_open_threads = true; plugins.var.python.slack.background_load_all_history = true; plugins.var.python.slack.short_buffer_names = true; plugins.var.python.slack.show_reaction_nicks = true; plugins.var.python.vimode.no_warn = true; script.look.sort = "p,n"; weechat.bar.buflist.hidden = true; weechat.bar.fset.items = "fset"; weechat.bar.input.items = "[mode_indicator]+ [input_prompt]+(away),[input_search],[input_paste],input_text,[vi_buffer]"; weechat.bar.status.color_bg = 53; weechat.bar.status.items = "[otr],[buffer_plugin],buffer_name+(buffer_modes)+{buffer_nicklist_count}+buffer_zoom+buffer_filter,scroll,[lag],[hotlist],completion"; weechat.bar.title.color_bg = 53; weechat.color.chat_nick_colors = [ "cyan" "magenta" "green" "brown" "lightblue" "lightcyan" "lightmagenta" "lightgreen" "blue" ]; weechat.color.chat_nick_self = "default"; weechat.color.status_count_other = "white"; weechat.color.status_data_other = "white"; weechat.color.status_nicklist_count = "white"; weechat.color.status_time = "white"; weechat.completion.default_template = "%(nicks)|%(irc_channels)|%(emoji)"; weechat.completion.nick_completer = ":"; weechat.look.buffer_notify_default = "message"; weechat.look.highlight = [ "spectrum" "crosvm" "qyliss" "alyssa*" "*dntmissher" "*@alyssa" ]; weechat.look.hotlist_names_count = 10; weechat.look.hotlist_names_level = 14; weechat.look.mouse = true; weechat.look.prefix_align_max = 12; weechat.look.save_config_on_exit = false; weechat.look.window_title = "WeeChat \\\${info:version}"; }; commands = map (d: ''/set sec.data.${d} test'') sec ++ [ "/save" ] ++ map (n: "/server add ${n} ${cfgin.irc.server_default.addresses}") networks ++ [ "/ignore add osmbot-test oftc #osm-gb" ] ++ mapAttrsToList (name: value: "/set ${name} ${toWeeChat value}") (flattenAttrs cfgin); flattenAttrs' = sep: attrs: listToAttrs (concatLists (flip mapAttrsToList attrs (k: v: if isAttrs v then mapAttrsToList (k': nameValuePair "${k}${sep}${k'}") (flattenAttrs' sep v) else [ (nameValuePair k v) ]))); flattenAttrs = flattenAttrs' "."; cfg = pkgs.runCommand "weechat-config" {} '' ${pkgs.weechat}/bin/weechat-headless -d $out \ ${concatMapStringsSep " " (cmd: "-r ${escapeShellArg cmd}") commands} \ -r /save \ -r /exit ''; in { environment.extraInit = '' export WEECHAT_HOME="$HOME/state/weechat" ''; environment.systemPackages = with pkgs; [ (weechat.override { configure = { availablePlugins, ... }: { scripts = with weechatScripts; [ colorize_nicks go wee-slack zncplayback ]; }; }) ]; home.qyliss.dirs."state/weechat".activationScripts.config = '' for file in ${cfg}/*.conf do if [ "$file" != ${cfg}/sec.conf ] then ln -sf $file $(basename $file) fi done ''; }