mirror of
https://github.com/NixOS/nixpkgs.git
synced 2025-07-14 06:00:33 +03:00
Merge pull request #14564 from valeriangalliat/shout/config
Shout: configure with attrs
This commit is contained in:
commit
9c484f29ce
1 changed files with 42 additions and 8 deletions
|
@ -6,6 +6,21 @@ let
|
||||||
cfg = config.services.shout;
|
cfg = config.services.shout;
|
||||||
shoutHome = "/var/lib/shout";
|
shoutHome = "/var/lib/shout";
|
||||||
|
|
||||||
|
defaultConfig = pkgs.runCommand "config.js" {} ''
|
||||||
|
EDITOR=true ${pkgs.shout}/bin/shout config --home $PWD
|
||||||
|
mv config.js $out
|
||||||
|
'';
|
||||||
|
|
||||||
|
configFile = if (cfg.configFile != null) then cfg.configFile else ''
|
||||||
|
var _ = require('${pkgs.shout}/lib/node_modules/shout/node_modules/lodash')
|
||||||
|
|
||||||
|
module.exports = _.merge(
|
||||||
|
{},
|
||||||
|
require('${defaultConfig}'),
|
||||||
|
${builtins.toJSON cfg.config}
|
||||||
|
)
|
||||||
|
'';
|
||||||
|
|
||||||
in {
|
in {
|
||||||
options.services.shout = {
|
options.services.shout = {
|
||||||
enable = mkEnableOption "Shout web IRC client";
|
enable = mkEnableOption "Shout web IRC client";
|
||||||
|
@ -33,10 +48,33 @@ in {
|
||||||
|
|
||||||
configFile = mkOption {
|
configFile = mkOption {
|
||||||
type = types.nullOr types.lines;
|
type = types.nullOr types.lines;
|
||||||
default = null;
|
default = configFile;
|
||||||
description = ''
|
description = ''
|
||||||
Contents of Shout's <filename>config.js</filename> file. If left empty,
|
Contents of Shout's <filename>config.js</filename> file.
|
||||||
Shout will generate from its defaults at first startup.
|
|
||||||
|
Used for backward compatibility, recommended way is now to use
|
||||||
|
the <literal>config</literal> option.
|
||||||
|
|
||||||
|
Documentation: http://shout-irc.com/docs/server/configuration.html
|
||||||
|
'';
|
||||||
|
};
|
||||||
|
|
||||||
|
config = mkOption {
|
||||||
|
default = {};
|
||||||
|
type = types.attrs;
|
||||||
|
example = {
|
||||||
|
displayNetwork = false;
|
||||||
|
defaults = {
|
||||||
|
name = "Your Network";
|
||||||
|
host = "localhost";
|
||||||
|
port = 6697;
|
||||||
|
};
|
||||||
|
};
|
||||||
|
description = ''
|
||||||
|
Shout <filename>config.js</filename> contents as attribute set (will be
|
||||||
|
converted to JSON to generate the configuration file).
|
||||||
|
|
||||||
|
The options defined here will be merged to the default configuration file.
|
||||||
|
|
||||||
Documentation: http://shout-irc.com/docs/server/configuration.html
|
Documentation: http://shout-irc.com/docs/server/configuration.html
|
||||||
'';
|
'';
|
||||||
|
@ -57,11 +95,7 @@ in {
|
||||||
wantedBy = [ "multi-user.target" ];
|
wantedBy = [ "multi-user.target" ];
|
||||||
wants = [ "network-online.target" ];
|
wants = [ "network-online.target" ];
|
||||||
after = [ "network-online.target" ];
|
after = [ "network-online.target" ];
|
||||||
preStart = if isNull cfg.configFile then ""
|
preStart = "ln -sf ${pkgs.writeText "config.js" configFile} ${shoutHome}/config.js";
|
||||||
else ''
|
|
||||||
ln -sf ${pkgs.writeText "config.js" cfg.configFile} \
|
|
||||||
${shoutHome}/config.js
|
|
||||||
'';
|
|
||||||
script = concatStringsSep " " [
|
script = concatStringsSep " " [
|
||||||
"${pkgs.shout}/bin/shout"
|
"${pkgs.shout}/bin/shout"
|
||||||
(if cfg.private then "--private" else "--public")
|
(if cfg.private then "--private" else "--public")
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue