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