2017-09-16 19:49:56 +02:00
|
|
|
{ config, lib, pkgs, ... }:
|
|
|
|
|
|
|
|
with lib;
|
|
|
|
|
|
|
|
let
|
|
|
|
cfg = config.services.gollum;
|
|
|
|
in
|
|
|
|
|
|
|
|
{
|
|
|
|
options.services.gollum = {
|
|
|
|
enable = mkOption {
|
|
|
|
type = types.bool;
|
|
|
|
default = false;
|
|
|
|
description = "Enable the Gollum service.";
|
|
|
|
};
|
|
|
|
|
|
|
|
address = mkOption {
|
|
|
|
type = types.str;
|
|
|
|
default = "0.0.0.0";
|
|
|
|
description = "IP address on which the web server will listen.";
|
|
|
|
};
|
|
|
|
|
|
|
|
port = mkOption {
|
|
|
|
type = types.int;
|
|
|
|
default = 4567;
|
|
|
|
description = "Port on which the web server will run.";
|
|
|
|
};
|
|
|
|
|
|
|
|
extraConfig = mkOption {
|
|
|
|
type = types.lines;
|
|
|
|
default = "";
|
|
|
|
description = "Content of the configuration file";
|
|
|
|
};
|
|
|
|
|
2017-12-05 13:20:31 +01:00
|
|
|
mathjax = mkOption {
|
|
|
|
type = types.bool;
|
|
|
|
default = false;
|
|
|
|
description = "Enable support for math rendering using MathJax";
|
|
|
|
};
|
|
|
|
|
2017-12-06 10:10:54 +01:00
|
|
|
allowUploads = mkOption {
|
|
|
|
type = types.nullOr (types.enum [ "dir" "page" ]);
|
|
|
|
default = null;
|
|
|
|
description = "Enable uploads of external files";
|
|
|
|
};
|
|
|
|
|
|
|
|
emoji = mkOption {
|
|
|
|
type = types.bool;
|
|
|
|
default = false;
|
|
|
|
description = "Parse and interpret emoji tags";
|
|
|
|
};
|
|
|
|
|
2017-09-16 19:49:56 +02:00
|
|
|
branch = mkOption {
|
|
|
|
type = types.str;
|
|
|
|
default = "master";
|
|
|
|
example = "develop";
|
|
|
|
description = "Git branch to serve";
|
|
|
|
};
|
|
|
|
|
|
|
|
stateDir = mkOption {
|
|
|
|
type = types.path;
|
|
|
|
default = "/var/lib/gollum";
|
|
|
|
description = "Specifies the path of the repository directory. If it does not exist, Gollum will create it on startup.";
|
|
|
|
};
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
config = mkIf cfg.enable {
|
|
|
|
|
|
|
|
users.users.gollum = {
|
|
|
|
group = config.users.users.gollum.name;
|
|
|
|
description = "Gollum user";
|
|
|
|
createHome = false;
|
2019-10-12 22:25:28 +02:00
|
|
|
isSystemUser = true;
|
2017-09-16 19:49:56 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
users.groups.gollum = { };
|
|
|
|
|
2019-02-24 00:00:03 +01:00
|
|
|
systemd.tmpfiles.rules = [
|
|
|
|
"d '${cfg.stateDir}' - ${config.users.users.gollum.name} ${config.users.groups.gollum.name} - -"
|
|
|
|
];
|
|
|
|
|
2017-09-16 19:49:56 +02:00
|
|
|
systemd.services.gollum = {
|
|
|
|
description = "Gollum wiki";
|
|
|
|
after = [ "network.target" ];
|
|
|
|
wantedBy = [ "multi-user.target" ];
|
|
|
|
path = [ pkgs.git ];
|
|
|
|
|
2019-02-24 00:00:03 +01:00
|
|
|
preStart = ''
|
|
|
|
# This is safe to be run on an existing repo
|
2017-09-16 19:49:56 +02:00
|
|
|
git init ${cfg.stateDir}
|
|
|
|
'';
|
|
|
|
|
|
|
|
serviceConfig = {
|
2018-06-30 01:58:35 +02:00
|
|
|
User = config.users.users.gollum.name;
|
|
|
|
Group = config.users.groups.gollum.name;
|
2017-09-16 19:49:56 +02:00
|
|
|
ExecStart = ''
|
|
|
|
${pkgs.gollum}/bin/gollum \
|
|
|
|
--port ${toString cfg.port} \
|
|
|
|
--host ${cfg.address} \
|
|
|
|
--config ${builtins.toFile "gollum-config.rb" cfg.extraConfig} \
|
|
|
|
--ref ${cfg.branch} \
|
2017-12-05 13:20:31 +01:00
|
|
|
${optionalString cfg.mathjax "--mathjax"} \
|
2017-12-06 10:10:54 +01:00
|
|
|
${optionalString cfg.emoji "--emoji"} \
|
|
|
|
${optionalString (cfg.allowUploads != null) "--allow-uploads ${cfg.allowUploads}"} \
|
2017-09-16 19:49:56 +02:00
|
|
|
${cfg.stateDir}
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
};
|
|
|
|
};
|
|
|
|
}
|