nixpkgs/nixos/modules/services/misc/gollum.nix

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

152 lines
4.0 KiB
Nix
Raw Normal View History

2017-09-16 17:49:56 +00:00
{ config, lib, pkgs, ... }:
with lib;
let
cfg = config.services.gollum;
in
{
options.services.gollum = {
enable = mkEnableOption "Gollum, a git-powered wiki service";
2017-09-16 17:49:56 +00:00
address = mkOption {
type = types.str;
default = "0.0.0.0";
description = "IP address on which the web server will listen.";
2017-09-16 17:49:56 +00:00
};
port = mkOption {
type = types.port;
2017-09-16 17:49:56 +00:00
default = 4567;
description = "Port on which the web server will run.";
2017-09-16 17:49:56 +00:00
};
extraConfig = mkOption {
type = types.lines;
default = "";
description = "Content of the configuration file";
2017-09-16 17:49:56 +00:00
};
mathjax = mkOption {
type = types.bool;
default = false;
description = "Enable support for math rendering using MathJax";
};
allowUploads = mkOption {
type = types.nullOr (types.enum [ "dir" "page" ]);
default = null;
description = "Enable uploads of external files";
};
2022-04-30 17:40:36 +00:00
user-icons = mkOption {
type = types.nullOr (types.enum [ "gravatar" "identicon" ]);
default = null;
description = "Enable specific user icons for history view";
2022-04-30 17:40:36 +00:00
};
emoji = mkOption {
type = types.bool;
default = false;
description = "Parse and interpret emoji tags";
};
h1-title = mkOption {
type = types.bool;
default = false;
description = "Use the first h1 as page title";
};
2022-04-30 17:40:37 +00:00
no-edit = mkOption {
type = types.bool;
default = false;
description = "Disable editing pages";
2022-04-30 17:40:37 +00:00
};
local-time = mkOption {
type = types.bool;
default = false;
description = "Use the browser's local timezone instead of the server's for displaying dates.";
};
2017-09-16 17:49:56 +00:00
branch = mkOption {
type = types.str;
default = "master";
example = "develop";
description = "Git branch to serve";
2017-09-16 17:49:56 +00:00
};
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.";
2017-09-16 17:49:56 +00:00
};
package = mkPackageOption pkgs "gollum" { };
user = mkOption {
type = types.str;
default = "gollum";
description = "Specifies the owner of the wiki directory";
};
group = mkOption {
type = types.str;
default = "gollum";
description = "Specifies the owner group of the wiki directory";
};
2017-09-16 17:49:56 +00:00
};
config = mkIf cfg.enable {
users.users.gollum = mkIf (cfg.user == "gollum") {
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
};
users.groups."${cfg.group}" = { };
2017-09-16 17:49:56 +00:00
systemd.tmpfiles.rules = [
"d '${cfg.stateDir}' - ${config.users.users.gollum.name} ${config.users.groups.gollum.name} - -"
];
2017-09-16 17:49:56 +00:00
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
2017-09-16 17:49:56 +00:00
git init ${cfg.stateDir}
'';
serviceConfig = {
User = cfg.user;
Group = cfg.group;
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} \
--config ${pkgs.writeText "gollum-config.rb" cfg.extraConfig} \
2017-09-16 17:49:56 +00:00
--ref ${cfg.branch} \
${optionalString cfg.mathjax "--mathjax"} \
${optionalString cfg.emoji "--emoji"} \
${optionalString cfg.h1-title "--h1-title"} \
2022-04-30 17:40:37 +00:00
${optionalString cfg.no-edit "--no-edit"} \
${optionalString cfg.local-time "--local-time"} \
${optionalString (cfg.allowUploads != null) "--allow-uploads ${cfg.allowUploads}"} \
2022-04-30 17:40:36 +00:00
${optionalString (cfg.user-icons != null) "--user-icons ${cfg.user-icons}"} \
2017-09-16 17:49:56 +00:00
${cfg.stateDir}
'';
};
};
};
meta.maintainers = with lib.maintainers; [ erictapen bbenno ];
2017-09-16 17:49:56 +00:00
}