2017-09-16 18:49:56 +01:00
|
|
|
{ config, lib, pkgs, ... }:
|
|
|
|
|
|
|
|
with lib;
|
|
|
|
|
|
|
|
let
|
|
|
|
cfg = config.services.gollum;
|
|
|
|
in
|
|
|
|
|
|
|
|
{
|
|
|
|
options.services.gollum = {
|
|
|
|
enable = mkOption {
|
|
|
|
type = types.bool;
|
|
|
|
default = false;
|
2022-07-28 22:19:15 +01:00
|
|
|
description = lib.mdDoc "Enable the Gollum service.";
|
2017-09-16 18:49:56 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
address = mkOption {
|
|
|
|
type = types.str;
|
|
|
|
default = "0.0.0.0";
|
2022-07-28 22:19:15 +01:00
|
|
|
description = lib.mdDoc "IP address on which the web server will listen.";
|
2017-09-16 18:49:56 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
port = mkOption {
|
|
|
|
type = types.int;
|
|
|
|
default = 4567;
|
2022-07-28 22:19:15 +01:00
|
|
|
description = lib.mdDoc "Port on which the web server will run.";
|
2017-09-16 18:49:56 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
extraConfig = mkOption {
|
|
|
|
type = types.lines;
|
|
|
|
default = "";
|
2022-07-28 22:19:15 +01:00
|
|
|
description = lib.mdDoc "Content of the configuration file";
|
2017-09-16 18:49:56 +01:00
|
|
|
};
|
|
|
|
|
2017-12-05 12:20:31 +00:00
|
|
|
mathjax = mkOption {
|
|
|
|
type = types.bool;
|
|
|
|
default = false;
|
2022-07-28 22:19:15 +01:00
|
|
|
description = lib.mdDoc "Enable support for math rendering using MathJax";
|
2017-12-05 12:20:31 +00:00
|
|
|
};
|
|
|
|
|
2017-12-06 09:10:54 +00:00
|
|
|
allowUploads = mkOption {
|
|
|
|
type = types.nullOr (types.enum [ "dir" "page" ]);
|
|
|
|
default = null;
|
2022-07-28 22:19:15 +01:00
|
|
|
description = lib.mdDoc "Enable uploads of external files";
|
2017-12-06 09:10:54 +00:00
|
|
|
};
|
|
|
|
|
2022-04-30 18:40:36 +01:00
|
|
|
user-icons = mkOption {
|
|
|
|
type = types.nullOr (types.enum [ "gravatar" "identicon" ]);
|
|
|
|
default = null;
|
2022-07-28 22:19:15 +01:00
|
|
|
description = lib.mdDoc "Enable specific user icons for history view";
|
2022-04-30 18:40:36 +01:00
|
|
|
};
|
|
|
|
|
2017-12-06 09:10:54 +00:00
|
|
|
emoji = mkOption {
|
|
|
|
type = types.bool;
|
|
|
|
default = false;
|
2022-07-28 22:19:15 +01:00
|
|
|
description = lib.mdDoc "Parse and interpret emoji tags";
|
2017-12-06 09:10:54 +00:00
|
|
|
};
|
|
|
|
|
2020-01-09 15:24:36 +00:00
|
|
|
h1-title = mkOption {
|
|
|
|
type = types.bool;
|
|
|
|
default = false;
|
2022-07-28 22:19:15 +01:00
|
|
|
description = lib.mdDoc "Use the first h1 as page title";
|
2020-01-09 15:24:36 +00:00
|
|
|
};
|
|
|
|
|
2022-04-30 18:40:37 +01:00
|
|
|
no-edit = mkOption {
|
|
|
|
type = types.bool;
|
|
|
|
default = false;
|
2022-07-28 22:19:15 +01:00
|
|
|
description = lib.mdDoc "Disable editing pages";
|
2022-04-30 18:40:37 +01:00
|
|
|
};
|
|
|
|
|
2022-06-17 11:50:41 +01:00
|
|
|
local-time = mkOption {
|
|
|
|
type = types.bool;
|
|
|
|
default = false;
|
2022-07-28 22:19:15 +01:00
|
|
|
description = lib.mdDoc "Use the browser's local timezone instead of the server's for displaying dates.";
|
2022-06-17 11:50:41 +01:00
|
|
|
};
|
|
|
|
|
2017-09-16 18:49:56 +01:00
|
|
|
branch = mkOption {
|
|
|
|
type = types.str;
|
|
|
|
default = "master";
|
|
|
|
example = "develop";
|
2022-07-28 22:19:15 +01:00
|
|
|
description = lib.mdDoc "Git branch to serve";
|
2017-09-16 18:49:56 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
stateDir = mkOption {
|
|
|
|
type = types.path;
|
|
|
|
default = "/var/lib/gollum";
|
2022-07-28 22:19:15 +01:00
|
|
|
description = lib.mdDoc "Specifies the path of the repository directory. If it does not exist, Gollum will create it on startup.";
|
2017-09-16 18:49:56 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
config = mkIf cfg.enable {
|
|
|
|
|
|
|
|
users.users.gollum = {
|
|
|
|
group = config.users.users.gollum.name;
|
|
|
|
description = "Gollum user";
|
|
|
|
createHome = false;
|
2019-10-12 21:25:28 +01:00
|
|
|
isSystemUser = true;
|
2017-09-16 18:49:56 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
users.groups.gollum = { };
|
|
|
|
|
2019-02-23 23:00:03 +00:00
|
|
|
systemd.tmpfiles.rules = [
|
|
|
|
"d '${cfg.stateDir}' - ${config.users.users.gollum.name} ${config.users.groups.gollum.name} - -"
|
|
|
|
];
|
|
|
|
|
2017-09-16 18:49:56 +01:00
|
|
|
systemd.services.gollum = {
|
|
|
|
description = "Gollum wiki";
|
|
|
|
after = [ "network.target" ];
|
|
|
|
wantedBy = [ "multi-user.target" ];
|
|
|
|
path = [ pkgs.git ];
|
|
|
|
|
2019-02-23 23:00:03 +00:00
|
|
|
preStart = ''
|
|
|
|
# This is safe to be run on an existing repo
|
2017-09-16 18:49:56 +01:00
|
|
|
git init ${cfg.stateDir}
|
|
|
|
'';
|
|
|
|
|
|
|
|
serviceConfig = {
|
2018-06-30 00:58:35 +01:00
|
|
|
User = config.users.users.gollum.name;
|
|
|
|
Group = config.users.groups.gollum.name;
|
2021-10-31 12:37:00 +00:00
|
|
|
WorkingDirectory = cfg.stateDir;
|
2017-09-16 18:49:56 +01:00
|
|
|
ExecStart = ''
|
|
|
|
${pkgs.gollum}/bin/gollum \
|
|
|
|
--port ${toString cfg.port} \
|
|
|
|
--host ${cfg.address} \
|
2020-08-12 18:16:05 +01:00
|
|
|
--config ${pkgs.writeText "gollum-config.rb" cfg.extraConfig} \
|
2017-09-16 18:49:56 +01:00
|
|
|
--ref ${cfg.branch} \
|
2017-12-05 12:20:31 +00:00
|
|
|
${optionalString cfg.mathjax "--mathjax"} \
|
2017-12-06 09:10:54 +00:00
|
|
|
${optionalString cfg.emoji "--emoji"} \
|
2020-01-09 15:24:36 +00:00
|
|
|
${optionalString cfg.h1-title "--h1-title"} \
|
2022-04-30 18:40:37 +01:00
|
|
|
${optionalString cfg.no-edit "--no-edit"} \
|
2022-06-17 11:50:41 +01:00
|
|
|
${optionalString cfg.local-time "--local-time"} \
|
2017-12-06 09:10:54 +00:00
|
|
|
${optionalString (cfg.allowUploads != null) "--allow-uploads ${cfg.allowUploads}"} \
|
2022-04-30 18:40:36 +01:00
|
|
|
${optionalString (cfg.user-icons != null) "--user-icons ${cfg.user-icons}"} \
|
2017-09-16 18:49:56 +01:00
|
|
|
${cfg.stateDir}
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
};
|
|
|
|
};
|
2021-02-27 18:56:10 +00:00
|
|
|
|
2022-04-30 15:47:25 +01:00
|
|
|
meta.maintainers = with lib.maintainers; [ erictapen bbenno ];
|
2017-09-16 18:49:56 +01:00
|
|
|
}
|