summary refs log tree commit diff
path: root/nixos
diff options
context:
space:
mode:
authorJustin Humm <justin.humm@posteo.de>2017-09-16 19:49:56 +0200
committerFranz Pletz <fpletz@fnordicwalking.de>2017-09-18 11:55:00 +0200
commitb5a5d0ba8427f7a5070475bb4fe08a4239ee82c6 (patch)
tree63959d87c0201306e75857f3770567a96438fcdb /nixos
parent700b0945b1375a4f658d22aa5476ebe7a077246d (diff)
downloadnixlib-b5a5d0ba8427f7a5070475bb4fe08a4239ee82c6.tar
nixlib-b5a5d0ba8427f7a5070475bb4fe08a4239ee82c6.tar.gz
nixlib-b5a5d0ba8427f7a5070475bb4fe08a4239ee82c6.tar.bz2
nixlib-b5a5d0ba8427f7a5070475bb4fe08a4239ee82c6.tar.lz
nixlib-b5a5d0ba8427f7a5070475bb4fe08a4239ee82c6.tar.xz
nixlib-b5a5d0ba8427f7a5070475bb4fe08a4239ee82c6.tar.zst
nixlib-b5a5d0ba8427f7a5070475bb4fe08a4239ee82c6.zip
gollum service: init
Diffstat (limited to 'nixos')
-rw-r--r--nixos/modules/module-list.nix1
-rw-r--r--nixos/modules/services/misc/gollum.nix92
2 files changed, 93 insertions, 0 deletions
diff --git a/nixos/modules/module-list.nix b/nixos/modules/module-list.nix
index d40b4a1361b1..eb478f66d40f 100644
--- a/nixos/modules/module-list.nix
+++ b/nixos/modules/module-list.nix
@@ -301,6 +301,7 @@
   ./services/misc/gitlab.nix
   ./services/misc/gitolite.nix
   ./services/misc/gogs.nix
+  ./services/misc/gollum.nix
   ./services/misc/gpsd.nix
   #./services/misc/ihaskell.nix
   ./services/misc/irkerd.nix
diff --git a/nixos/modules/services/misc/gollum.nix b/nixos/modules/services/misc/gollum.nix
new file mode 100644
index 000000000000..81fb024f9094
--- /dev/null
+++ b/nixos/modules/services/misc/gollum.nix
@@ -0,0 +1,92 @@
+{ config, lib, pkgs, ... }:
+
+with lib;
+
+let
+  cfg = config.services.gollum;
+in
+
+{
+  options.services.gollum = {
+    enable = mkOption {
+      type = types.bool;
+      default = false;
+      description = "Enable the Gollum service.";
+    };
+
+    address = mkOption {
+      type = types.str;
+      default = "0.0.0.0";
+      description = "IP address on which the web server will listen.";
+    };
+
+    port = mkOption {
+      type = types.int;
+      default = 4567;
+      description = "Port on which the web server will run.";
+    };
+
+    extraConfig = mkOption {
+      type = types.lines;
+      default = "";
+      description = "Content of the configuration file";
+    };
+
+    branch = mkOption {
+      type = types.str;
+      default = "master";
+      example = "develop";
+      description = "Git branch to serve";
+    };
+
+    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.";
+    };
+
+  };
+
+  config = mkIf cfg.enable {
+
+    users.users.gollum = {
+      group = config.users.users.gollum.name;
+      description = "Gollum user";
+      createHome = false;
+    };
+
+    users.groups.gollum = { };
+
+    systemd.services.gollum = {
+      description = "Gollum wiki";
+      after = [ "network.target" ];
+      wantedBy = [ "multi-user.target" ];
+      path = [ pkgs.git ];
+
+      preStart = let
+          userName = config.users.users.gollum.name;
+          groupName = config.users.groups.gollum.name;
+        in ''
+        # All of this is safe to be run on an existing repo
+        mkdir -p ${cfg.stateDir}
+        git init ${cfg.stateDir}
+        chmod 755 ${cfg.stateDir}
+        chown -R ${userName}:${groupName} ${cfg.stateDir}
+      '';
+
+      serviceConfig = {
+        User = config.users.extraUsers.gollum.name;
+        Group = config.users.extraGroups.gollum.name;
+        PermissionsStartOnly = true;
+        ExecStart = ''
+          ${pkgs.gollum}/bin/gollum \
+            --port ${toString cfg.port} \
+            --host ${cfg.address} \
+            --config ${builtins.toFile "gollum-config.rb" cfg.extraConfig} \
+            --ref ${cfg.branch} \
+            ${cfg.stateDir}
+        '';
+      };
+    };
+  };
+}