1 { pkgs, lib, config, ... }:
6 cfg = config.services.shout;
7 shoutHome = "/var/lib/shout";
9 defaultConfig = pkgs.runCommand "config.js" { preferLocalBuild = true; } ''
10 EDITOR=true ${pkgs.shout}/bin/shout config --home $PWD
14 finalConfigFile = if (cfg.configFile != null) then cfg.configFile else ''
15 var _ = require('${pkgs.shout}/lib/node_modules/shout/node_modules/lodash')
17 module.exports = _.merge(
19 require('${defaultConfig}'),
20 ${builtins.toJSON cfg.config}
25 options.services.shout = {
26 enable = mkEnableOption "Shout web IRC client";
32 Make your shout instance private. You will need to configure user
33 accounts by adding entries in {file}`${shoutHome}/users`.
37 listenAddress = mkOption {
40 description = "IP interface to listen on for http connections.";
46 description = "TCP port to listen on for http connections.";
49 configFile = mkOption {
50 type = types.nullOr types.lines;
53 Contents of Shout's {file}`config.js` file.
55 Used for backward compatibility, recommended way is now to use
58 Documentation: http://shout-irc.com/docs/server/configuration.html
66 displayNetwork = false;
68 name = "Your Network";
74 Shout {file}`config.js` contents as attribute set (will be
75 converted to JSON to generate the configuration file).
77 The options defined here will be merged to the default configuration file.
79 Documentation: http://shout-irc.com/docs/server/configuration.html
84 config = mkIf cfg.enable {
88 description = "Shout daemon user";
92 users.groups.shout = {};
94 systemd.services.shout = {
95 description = "Shout web IRC client";
96 wantedBy = [ "multi-user.target" ];
97 wants = [ "network-online.target" ];
98 after = [ "network-online.target" ];
99 preStart = "ln -sf ${pkgs.writeText "config.js" finalConfigFile} ${shoutHome}/config.js";
100 script = concatStringsSep " " [
101 "${pkgs.shout}/bin/shout"
102 (if cfg.private then "--private" else "--public")
103 "--port" (toString cfg.port)
104 "--host" (toString cfg.listenAddress)
109 ProtectHome = "true";
110 ProtectSystem = "full";