mirror of
https://github.com/NixOS/nixpkgs.git
synced 2024-12-16 02:33:25 +00:00
2e751c0772
the conversion procedure is simple: - find all things that look like options, ie calls to either `mkOption` or `lib.mkOption` that take an attrset. remember the attrset as the option - for all options, find a `description` attribute who's value is not a call to `mdDoc` or `lib.mdDoc` - textually convert the entire value of the attribute to MD with a few simple regexes (the set from mdize-module.sh) - if the change produced a change in the manual output, discard - if the change kept the manual unchanged, add some text to the description to make sure we've actually found an option. if the manual changes this time, keep the converted description this procedure converts 80% of nixos options to markdown. around 2000 options remain to be inspected, but most of those fail the "does not change the manual output check": currently the MD conversion process does not faithfully convert docbook tags like <code> and <package>, so any option using such tags will not be converted at all.
107 lines
3.4 KiB
Nix
107 lines
3.4 KiB
Nix
{ pkgs, lib, config, ... }:
|
|
|
|
with lib;
|
|
|
|
let
|
|
cfg = config.services.thelounge;
|
|
dataDir = "/var/lib/thelounge";
|
|
configJsData = "module.exports = " + builtins.toJSON (
|
|
{ inherit (cfg) public port; } // cfg.extraConfig
|
|
);
|
|
pluginManifest = {
|
|
dependencies = builtins.listToAttrs (builtins.map (pkg: { name = getName pkg; value = getVersion pkg; }) cfg.plugins);
|
|
};
|
|
plugins = pkgs.runCommandLocal "thelounge-plugins" { } ''
|
|
mkdir -p $out/node_modules
|
|
echo ${escapeShellArg (builtins.toJSON pluginManifest)} >> $out/package.json
|
|
${concatMapStringsSep "\n" (pkg: ''
|
|
ln -s ${pkg}/lib/node_modules/${getName pkg} $out/node_modules/${getName pkg}
|
|
'') cfg.plugins}
|
|
'';
|
|
in
|
|
{
|
|
imports = [ (mkRemovedOptionModule [ "services" "thelounge" "private" ] "The option was renamed to `services.thelounge.public` to follow upstream changes.") ];
|
|
|
|
options.services.thelounge = {
|
|
enable = mkEnableOption "The Lounge web IRC client";
|
|
|
|
public = mkOption {
|
|
type = types.bool;
|
|
default = false;
|
|
description = lib.mdDoc ''
|
|
Make your The Lounge instance public.
|
|
Setting this to `false` will require you to configure user
|
|
accounts by using the ({command}`thelounge`) command or by adding
|
|
entries in {file}`${dataDir}/users`. You might need to restart
|
|
The Lounge after making changes to the state directory.
|
|
'';
|
|
};
|
|
|
|
port = mkOption {
|
|
type = types.port;
|
|
default = 9000;
|
|
description = lib.mdDoc "TCP port to listen on for http connections.";
|
|
};
|
|
|
|
extraConfig = mkOption {
|
|
default = { };
|
|
type = types.attrs;
|
|
example = literalExpression ''{
|
|
reverseProxy = true;
|
|
defaults = {
|
|
name = "Your Network";
|
|
host = "localhost";
|
|
port = 6697;
|
|
};
|
|
}'';
|
|
description = lib.mdDoc ''
|
|
The Lounge's {file}`config.js` 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.
|
|
Note: In case of duplicate configuration, options from {option}`extraConfig` have priority.
|
|
|
|
Documentation: <https://thelounge.chat/docs/server/configuration>
|
|
'';
|
|
};
|
|
|
|
plugins = mkOption {
|
|
default = [ ];
|
|
type = types.listOf types.package;
|
|
example = literalExpression "[ pkgs.theLoungePlugins.themes.solarized ]";
|
|
description = lib.mdDoc ''
|
|
The Lounge plugins to install. Plugins can be found in
|
|
`pkgs.theLoungePlugins.plugins` and `pkgs.theLoungePlugins.themes`.
|
|
'';
|
|
};
|
|
};
|
|
|
|
config = mkIf cfg.enable {
|
|
users.users.thelounge = {
|
|
description = "The Lounge service user";
|
|
group = "thelounge";
|
|
isSystemUser = true;
|
|
};
|
|
|
|
users.groups.thelounge = { };
|
|
|
|
systemd.services.thelounge = {
|
|
description = "The Lounge web IRC client";
|
|
wantedBy = [ "multi-user.target" ];
|
|
preStart = "ln -sf ${pkgs.writeText "config.js" configJsData} ${dataDir}/config.js";
|
|
environment.THELOUNGE_PACKAGES = mkIf (cfg.plugins != [ ]) "${plugins}";
|
|
serviceConfig = {
|
|
User = "thelounge";
|
|
StateDirectory = baseNameOf dataDir;
|
|
ExecStart = "${pkgs.thelounge}/bin/thelounge start";
|
|
};
|
|
};
|
|
|
|
environment.systemPackages = [ pkgs.thelounge ];
|
|
};
|
|
|
|
meta = {
|
|
maintainers = with lib.maintainers; [ winter ];
|
|
};
|
|
}
|