1{ pkgs, lib, config, options, ... }: 2 3with lib; 4 5let 6 cfg = config.services.shout; 7 shoutHome = "/var/lib/shout"; 8 9in { 10 options.services.shout = { 11 enable = mkEnableOption "Shout web IRC client"; 12 13 private = mkOption { 14 type = types.bool; 15 default = false; 16 description = '' 17 Make your shout instance private. You will need to configure user 18 accounts by adding entries in <filename>${shoutHome}/users</filename>. 19 ''; 20 }; 21 22 listenAddress = mkOption { 23 type = types.string; 24 default = "0.0.0.0"; 25 description = "IP interface to listen on for http connections."; 26 }; 27 28 port = mkOption { 29 type = types.int; 30 default = 9000; 31 description = "TCP port to listen on for http connections."; 32 }; 33 34 configFile = mkOption { 35 type = types.nullOr types.lines; 36 default = null; 37 description = '' 38 Contents of Shout's <filename>config.js</filename> file. If left empty, 39 Shout will generate from its defaults at first startup. 40 41 Documentation: http://shout-irc.com/docs/server/configuration.html 42 ''; 43 }; 44 }; 45 46 config = mkIf cfg.enable { 47 users.extraUsers = singleton { 48 name = "shout"; 49 uid = config.ids.uids.shout; 50 description = "Shout daemon user"; 51 home = shoutHome; 52 createHome = true; 53 }; 54 55 systemd.services.shout = { 56 description = "Shout web IRC client"; 57 wantedBy = [ "multi-user.target" ]; 58 wants = [ "network-online.target" ]; 59 after = [ "network-online.target" ]; 60 preStart = if isNull cfg.configFile then "" 61 else '' 62 ln -sf ${pkgs.writeText "config.js" cfg.configFile} \ 63 ${shoutHome}/config.js 64 ''; 65 script = concatStringsSep " " [ 66 "${pkgs.shout}/bin/shout" 67 (if cfg.private then "--private" else "--public") 68 "--port" (toString cfg.port) 69 "--host" (toString cfg.listenAddress) 70 "--home" shoutHome 71 ]; 72 serviceConfig = { 73 User = "shout"; 74 ProtectHome = "true"; 75 ProtectSystem = "full"; 76 PrivateTmp = "true"; 77 }; 78 }; 79 }; 80}