8 cfg = config.services.gollum;
13 (lib.mkRemovedOptionModule
19 "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"
23 options.services.gollum = {
24 enable = lib.mkEnableOption "Gollum, a git-powered wiki service";
26 address = lib.mkOption {
29 description = "IP address on which the web server will listen.";
33 type = lib.types.port;
35 description = "Port on which the web server will run.";
38 extraConfig = lib.mkOption {
39 type = lib.types.lines;
41 description = "Content of the configuration file";
45 type = lib.types.bool;
47 description = "Enable support for math rendering using KaTeX";
50 allowUploads = lib.mkOption {
51 type = lib.types.nullOr (
58 description = "Enable uploads of external files";
61 user-icons = lib.mkOption {
62 type = lib.types.nullOr (
69 description = "Enable specific user icons for history view";
72 emoji = lib.mkOption {
73 type = lib.types.bool;
75 description = "Parse and interpret emoji tags";
78 h1-title = lib.mkOption {
79 type = lib.types.bool;
81 description = "Use the first h1 as page title";
84 no-edit = lib.mkOption {
85 type = lib.types.bool;
87 description = "Disable editing pages";
90 local-time = lib.mkOption {
91 type = lib.types.bool;
93 description = "Use the browser's local timezone instead of the server's for displaying dates.";
96 branch = lib.mkOption {
100 description = "Git branch to serve";
103 stateDir = lib.mkOption {
104 type = lib.types.path;
105 default = "/var/lib/gollum";
106 description = "Specifies the path of the repository directory. If it does not exist, Gollum will create it on startup.";
109 package = lib.mkPackageOption pkgs "gollum" { };
111 user = lib.mkOption {
112 type = lib.types.str;
114 description = "Specifies the owner of the wiki directory";
117 group = lib.mkOption {
118 type = lib.types.str;
120 description = "Specifies the owner group of the wiki directory";
124 config = lib.mkIf cfg.enable {
126 users.users.gollum = lib.mkIf (cfg.user == "gollum") {
128 description = "Gollum user";
133 users.groups."${cfg.group}" = { };
135 systemd.tmpfiles.rules = [ "d '${cfg.stateDir}' - ${cfg.user} ${cfg.group} - -" ];
137 systemd.services.gollum = {
138 description = "Gollum wiki";
139 after = [ "network.target" ];
140 wantedBy = [ "multi-user.target" ];
144 # This is safe to be run on an existing repo
145 git init ${cfg.stateDir}
151 WorkingDirectory = cfg.stateDir;
153 ${cfg.package}/bin/gollum \
154 --port ${toString cfg.port} \
155 --host ${cfg.address} \
156 --config ${pkgs.writeText "gollum-config.rb" cfg.extraConfig} \
157 --ref ${cfg.branch} \
158 ${lib.optionalString cfg.math "--math"} \
159 ${lib.optionalString cfg.emoji "--emoji"} \
160 ${lib.optionalString cfg.h1-title "--h1-title"} \
161 ${lib.optionalString cfg.no-edit "--no-edit"} \
162 ${lib.optionalString cfg.local-time "--local-time"} \
163 ${lib.optionalString (cfg.allowUploads != null) "--allow-uploads ${cfg.allowUploads}"} \
164 ${lib.optionalString (cfg.user-icons != null) "--user-icons ${cfg.user-icons}"} \
171 meta.maintainers = with lib.maintainers; [