2024-07-29 10:46:13 +00:00
|
|
|
{
|
|
|
|
config,
|
|
|
|
lib,
|
|
|
|
pkgs,
|
|
|
|
...
|
|
|
|
}:
|
2017-09-16 17:49:56 +00:00
|
|
|
let
|
|
|
|
cfg = config.services.gollum;
|
|
|
|
in
|
|
|
|
|
|
|
|
{
|
2024-07-29 10:33:09 +00:00
|
|
|
imports = [
|
2024-08-24 20:05:44 +00:00
|
|
|
(lib.mkRemovedOptionModule
|
2024-07-29 10:46:13 +00:00
|
|
|
[
|
|
|
|
"services"
|
|
|
|
"gollum"
|
|
|
|
"mathjax"
|
|
|
|
]
|
2024-07-29 10:33:09 +00:00
|
|
|
"MathJax rendering might be discontinued in the future, use services.gollum.math instead to enable KaTeX rendering or file a PR if you really need Mathjax"
|
|
|
|
)
|
|
|
|
];
|
|
|
|
|
2017-09-16 17:49:56 +00:00
|
|
|
options.services.gollum = {
|
2024-08-24 20:05:44 +00:00
|
|
|
enable = lib.mkEnableOption "Gollum, a git-powered wiki service";
|
2017-09-16 17:49:56 +00:00
|
|
|
|
2024-08-24 20:05:44 +00:00
|
|
|
address = lib.mkOption {
|
|
|
|
type = lib.types.str;
|
2017-09-16 17:49:56 +00:00
|
|
|
default = "0.0.0.0";
|
|
|
|
description = "IP address on which the web server will listen.";
|
|
|
|
};
|
|
|
|
|
2024-08-24 20:05:44 +00:00
|
|
|
port = lib.mkOption {
|
|
|
|
type = lib.types.port;
|
2017-09-16 17:49:56 +00:00
|
|
|
default = 4567;
|
|
|
|
description = "Port on which the web server will run.";
|
|
|
|
};
|
|
|
|
|
2024-08-24 20:05:44 +00:00
|
|
|
extraConfig = lib.mkOption {
|
|
|
|
type = lib.types.lines;
|
2017-09-16 17:49:56 +00:00
|
|
|
default = "";
|
|
|
|
description = "Content of the configuration file";
|
|
|
|
};
|
|
|
|
|
2024-08-24 20:05:44 +00:00
|
|
|
math = lib.mkOption {
|
|
|
|
type = lib.types.bool;
|
2017-12-05 12:20:31 +00:00
|
|
|
default = false;
|
2024-07-29 10:33:09 +00:00
|
|
|
description = "Enable support for math rendering using KaTeX";
|
2017-12-05 12:20:31 +00:00
|
|
|
};
|
|
|
|
|
2024-08-24 20:05:44 +00:00
|
|
|
allowUploads = lib.mkOption {
|
|
|
|
type = lib.types.nullOr (
|
|
|
|
lib.types.enum [
|
2024-07-29 10:46:13 +00:00
|
|
|
"dir"
|
|
|
|
"page"
|
|
|
|
]
|
|
|
|
);
|
2017-12-06 09:10:54 +00:00
|
|
|
default = null;
|
|
|
|
description = "Enable uploads of external files";
|
|
|
|
};
|
|
|
|
|
2024-08-24 20:05:44 +00:00
|
|
|
user-icons = lib.mkOption {
|
|
|
|
type = lib.types.nullOr (
|
|
|
|
lib.types.enum [
|
2024-07-29 10:46:13 +00:00
|
|
|
"gravatar"
|
|
|
|
"identicon"
|
|
|
|
]
|
|
|
|
);
|
2022-04-30 17:40:36 +00:00
|
|
|
default = null;
|
2022-06-17 10:50:13 +00:00
|
|
|
description = "Enable specific user icons for history view";
|
2022-04-30 17:40:36 +00:00
|
|
|
};
|
|
|
|
|
2024-08-24 20:05:44 +00:00
|
|
|
emoji = lib.mkOption {
|
|
|
|
type = lib.types.bool;
|
2017-12-06 09:10:54 +00:00
|
|
|
default = false;
|
|
|
|
description = "Parse and interpret emoji tags";
|
|
|
|
};
|
|
|
|
|
2024-08-24 20:05:44 +00:00
|
|
|
h1-title = lib.mkOption {
|
|
|
|
type = lib.types.bool;
|
2020-01-09 15:24:36 +00:00
|
|
|
default = false;
|
|
|
|
description = "Use the first h1 as page title";
|
|
|
|
};
|
|
|
|
|
2024-08-24 20:05:44 +00:00
|
|
|
no-edit = lib.mkOption {
|
|
|
|
type = lib.types.bool;
|
2022-04-30 17:40:37 +00:00
|
|
|
default = false;
|
|
|
|
description = "Disable editing pages";
|
|
|
|
};
|
|
|
|
|
2024-08-24 20:05:44 +00:00
|
|
|
local-time = lib.mkOption {
|
|
|
|
type = lib.types.bool;
|
2022-06-17 10:50:41 +00:00
|
|
|
default = false;
|
|
|
|
description = "Use the browser's local timezone instead of the server's for displaying dates.";
|
|
|
|
};
|
|
|
|
|
2024-08-24 20:05:44 +00:00
|
|
|
branch = lib.mkOption {
|
|
|
|
type = lib.types.str;
|
2017-09-16 17:49:56 +00:00
|
|
|
default = "master";
|
|
|
|
example = "develop";
|
|
|
|
description = "Git branch to serve";
|
|
|
|
};
|
|
|
|
|
2024-08-24 20:05:44 +00:00
|
|
|
stateDir = lib.mkOption {
|
|
|
|
type = lib.types.path;
|
2017-09-16 17:49:56 +00:00
|
|
|
default = "/var/lib/gollum";
|
|
|
|
description = "Specifies the path of the repository directory. If it does not exist, Gollum will create it on startup.";
|
|
|
|
};
|
|
|
|
|
2024-08-24 20:05:44 +00:00
|
|
|
package = lib.mkPackageOption pkgs "gollum" { };
|
2022-11-29 15:17:25 +00:00
|
|
|
|
2024-08-24 20:05:44 +00:00
|
|
|
user = lib.mkOption {
|
|
|
|
type = lib.types.str;
|
2022-11-29 15:17:25 +00:00
|
|
|
default = "gollum";
|
|
|
|
description = "Specifies the owner of the wiki directory";
|
|
|
|
};
|
|
|
|
|
2024-08-24 20:05:44 +00:00
|
|
|
group = lib.mkOption {
|
|
|
|
type = lib.types.str;
|
2022-11-29 15:17:25 +00:00
|
|
|
default = "gollum";
|
|
|
|
description = "Specifies the owner group of the wiki directory";
|
|
|
|
};
|
2017-09-16 17:49:56 +00:00
|
|
|
};
|
|
|
|
|
2024-08-24 20:05:44 +00:00
|
|
|
config = lib.mkIf cfg.enable {
|
2017-09-16 17:49:56 +00:00
|
|
|
|
2024-08-24 20:05:44 +00:00
|
|
|
users.users.gollum = lib.mkIf (cfg.user == "gollum") {
|
2022-11-29 15:17:25 +00:00
|
|
|
group = cfg.group;
|
2017-09-16 17:49:56 +00:00
|
|
|
description = "Gollum user";
|
|
|
|
createHome = false;
|
2019-10-12 20:25:28 +00:00
|
|
|
isSystemUser = true;
|
2017-09-16 17:49:56 +00:00
|
|
|
};
|
|
|
|
|
2023-03-21 12:26:22 +00:00
|
|
|
users.groups."${cfg.group}" = { };
|
2017-09-16 17:49:56 +00:00
|
|
|
|
2024-07-29 10:46:13 +00:00
|
|
|
systemd.tmpfiles.rules = [ "d '${cfg.stateDir}' - ${cfg.user} ${cfg.group} - -" ];
|
2019-02-23 23:00:03 +00:00
|
|
|
|
2017-09-16 17:49:56 +00: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 17:49:56 +00:00
|
|
|
git init ${cfg.stateDir}
|
|
|
|
'';
|
|
|
|
|
|
|
|
serviceConfig = {
|
2022-11-29 15:17:25 +00:00
|
|
|
User = cfg.user;
|
|
|
|
Group = cfg.group;
|
2021-10-31 12:37:00 +00:00
|
|
|
WorkingDirectory = cfg.stateDir;
|
2017-09-16 17:49:56 +00:00
|
|
|
ExecStart = ''
|
2022-09-10 15:56:33 +00:00
|
|
|
${cfg.package}/bin/gollum \
|
2017-09-16 17:49:56 +00:00
|
|
|
--port ${toString cfg.port} \
|
|
|
|
--host ${cfg.address} \
|
2020-08-12 17:16:05 +00:00
|
|
|
--config ${pkgs.writeText "gollum-config.rb" cfg.extraConfig} \
|
2017-09-16 17:49:56 +00:00
|
|
|
--ref ${cfg.branch} \
|
2024-08-24 20:05:44 +00:00
|
|
|
${lib.optionalString cfg.math "--math"} \
|
|
|
|
${lib.optionalString cfg.emoji "--emoji"} \
|
|
|
|
${lib.optionalString cfg.h1-title "--h1-title"} \
|
|
|
|
${lib.optionalString cfg.no-edit "--no-edit"} \
|
|
|
|
${lib.optionalString cfg.local-time "--local-time"} \
|
|
|
|
${lib.optionalString (cfg.allowUploads != null) "--allow-uploads ${cfg.allowUploads}"} \
|
|
|
|
${lib.optionalString (cfg.user-icons != null) "--user-icons ${cfg.user-icons}"} \
|
2017-09-16 17:49:56 +00:00
|
|
|
${cfg.stateDir}
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
};
|
|
|
|
};
|
2021-02-27 18:56:10 +00:00
|
|
|
|
2024-07-29 10:46:13 +00:00
|
|
|
meta.maintainers = with lib.maintainers; [
|
|
|
|
erictapen
|
|
|
|
bbenno
|
|
|
|
];
|
2017-09-16 17:49:56 +00:00
|
|
|
}
|