1 { config, lib, pkgs, ... }:
6 cfg = config.services.gollum;
10 options.services.gollum = {
11 enable = mkEnableOption (lib.mdDoc "Gollum service");
16 description = lib.mdDoc "IP address on which the web server will listen.";
22 description = lib.mdDoc "Port on which the web server will run.";
25 extraConfig = mkOption {
28 description = lib.mdDoc "Content of the configuration file";
34 description = lib.mdDoc "Enable support for math rendering using MathJax";
37 allowUploads = mkOption {
38 type = types.nullOr (types.enum [ "dir" "page" ]);
40 description = lib.mdDoc "Enable uploads of external files";
43 user-icons = mkOption {
44 type = types.nullOr (types.enum [ "gravatar" "identicon" ]);
46 description = lib.mdDoc "Enable specific user icons for history view";
52 description = lib.mdDoc "Parse and interpret emoji tags";
58 description = lib.mdDoc "Use the first h1 as page title";
64 description = lib.mdDoc "Disable editing pages";
67 local-time = mkOption {
70 description = lib.mdDoc "Use the browser's local timezone instead of the server's for displaying dates.";
77 description = lib.mdDoc "Git branch to serve";
82 default = "/var/lib/gollum";
83 description = lib.mdDoc "Specifies the path of the repository directory. If it does not exist, Gollum will create it on startup.";
88 default = pkgs.gollum;
89 defaultText = literalExpression "pkgs.gollum";
90 description = lib.mdDoc ''
91 The package used in the service
96 config = mkIf cfg.enable {
98 users.users.gollum = {
99 group = config.users.users.gollum.name;
100 description = "Gollum user";
105 users.groups.gollum = { };
107 systemd.tmpfiles.rules = [
108 "d '${cfg.stateDir}' - ${config.users.users.gollum.name} ${config.users.groups.gollum.name} - -"
111 systemd.services.gollum = {
112 description = "Gollum wiki";
113 after = [ "network.target" ];
114 wantedBy = [ "multi-user.target" ];
118 # This is safe to be run on an existing repo
119 git init ${cfg.stateDir}
123 User = config.users.users.gollum.name;
124 Group = config.users.groups.gollum.name;
125 WorkingDirectory = cfg.stateDir;
127 ${cfg.package}/bin/gollum \
128 --port ${toString cfg.port} \
129 --host ${cfg.address} \
130 --config ${pkgs.writeText "gollum-config.rb" cfg.extraConfig} \
131 --ref ${cfg.branch} \
132 ${optionalString cfg.mathjax "--mathjax"} \
133 ${optionalString cfg.emoji "--emoji"} \
134 ${optionalString cfg.h1-title "--h1-title"} \
135 ${optionalString cfg.no-edit "--no-edit"} \
136 ${optionalString cfg.local-time "--local-time"} \
137 ${optionalString (cfg.allowUploads != null) "--allow-uploads ${cfg.allowUploads}"} \
138 ${optionalString (cfg.user-icons != null) "--user-icons ${cfg.user-icons}"} \
145 meta.maintainers = with lib.maintainers; [ erictapen bbenno ];