summary refs log tree commit diff
path: root/nixos
diff options
context:
space:
mode:
authorMarek Mahut <marek.mahut@gmail.com>2019-11-04 17:53:49 +0100
committerGitHub <noreply@github.com>2019-11-04 17:53:49 +0100
commite51f707437c2600881f0f0759b5bf2dc2fba76e7 (patch)
tree9e736d76f606b1ed75d38ae824365cf1a4b580f6 /nixos
parentb1b776b11c2e4b73e69d4bef7f33fd2bb215c286 (diff)
parente71b1e3363831a1ae0ded2963142a853cc1e926f (diff)
downloadnixpkgs-e51f707437c2600881f0f0759b5bf2dc2fba76e7.tar
nixpkgs-e51f707437c2600881f0f0759b5bf2dc2fba76e7.tar.gz
nixpkgs-e51f707437c2600881f0f0759b5bf2dc2fba76e7.tar.bz2
nixpkgs-e51f707437c2600881f0f0759b5bf2dc2fba76e7.tar.lz
nixpkgs-e51f707437c2600881f0f0759b5bf2dc2fba76e7.tar.xz
nixpkgs-e51f707437c2600881f0f0759b5bf2dc2fba76e7.tar.zst
nixpkgs-e51f707437c2600881f0f0759b5bf2dc2fba76e7.zip
Merge pull request #72729 from mmahut/trac
nixos/trac: init
Diffstat (limited to 'nixos')
-rw-r--r--nixos/modules/module-list.nix1
-rw-r--r--nixos/modules/services/web-apps/trac.nix79
-rw-r--r--nixos/tests/all-tests.nix1
-rw-r--r--nixos/tests/trac.nix19
4 files changed, 100 insertions, 0 deletions
diff --git a/nixos/modules/module-list.nix b/nixos/modules/module-list.nix
index 1dcbf71dfaf..0b14b3e3301 100644
--- a/nixos/modules/module-list.nix
+++ b/nixos/modules/module-list.nix
@@ -816,6 +816,7 @@
   ./services/web-apps/moinmoin.nix
   ./services/web-apps/restya-board.nix
   ./services/web-apps/tt-rss.nix
+  ./services/web-apps/trac.nix
   ./services/web-apps/selfoss.nix
   ./services/web-apps/shiori.nix
   ./services/web-apps/virtlyst.nix
diff --git a/nixos/modules/services/web-apps/trac.nix b/nixos/modules/services/web-apps/trac.nix
new file mode 100644
index 00000000000..207fb857438
--- /dev/null
+++ b/nixos/modules/services/web-apps/trac.nix
@@ -0,0 +1,79 @@
+{ config, lib, pkgs, ... }:
+
+let
+  cfg = config.services.trac;
+
+  inherit (lib) mkEnableOption mkIf mkOption types;
+
+in {
+
+  options = {
+
+    services.trac = {
+      enable = mkEnableOption "Trac service";
+
+      listen = {
+        ip = mkOption {
+          type = types.str;
+          default = "0.0.0.0";
+          description = ''
+            IP address that Trac should listen on.
+          '';
+        };
+
+        port = mkOption {
+          type = types.port;
+          default = 8000;
+          description = ''
+            Listen port for Trac.
+          '';
+        };
+      };
+
+      dataDir = mkOption {
+        default = "/var/lib/trac";
+        type = types.path;
+        description = ''
+            The directory for storing the Trac data.
+        '';
+      };
+
+      openFirewall = mkOption {
+        type = types.bool;
+        default = false;
+        description = ''
+          Open ports in the firewall for Trac.
+        '';
+      };
+    };
+
+  };
+
+  config = mkIf cfg.enable {
+
+    systemd.services.trac = {
+      description = "Trac server";
+      wantedBy = [ "multi-user.target" ];
+      serviceConfig = {
+        DynamicUser = true;
+        StateDirectory = baseNameOf cfg.dataDir;
+        ExecStart = ''
+          ${pkgs.trac}/bin/tracd -s \
+            -b ${toString cfg.listen.ip} \
+            -p ${toString cfg.listen.port} \
+            ${cfg.dataDir}
+        '';
+      };
+      preStart = ''
+        if [ ! -e ${cfg.dataDir}/VERSION ]; then
+          ${pkgs.trac}/bin/trac-admin ${cfg.dataDir} initenv Trac "sqlite:db/trac.db"
+        fi
+      '';
+    };
+
+    networking.firewall = mkIf cfg.openFirewall {
+      allowedTCPPorts = [ cfg.listen.port ];
+    };
+
+  };
+}
diff --git a/nixos/tests/all-tests.nix b/nixos/tests/all-tests.nix
index 5c473f0aa89..1d933153ffa 100644
--- a/nixos/tests/all-tests.nix
+++ b/nixos/tests/all-tests.nix
@@ -281,6 +281,7 @@ in
   tinydns = handleTest ./tinydns.nix {};
   tor = handleTest ./tor.nix {};
   transmission = handleTest ./transmission.nix {};
+  trac = handleTest ./trac.nix {};
   trezord = handleTest ./trezord.nix {};
   trickster = handleTest ./trickster.nix {};
   udisks2 = handleTest ./udisks2.nix {};
diff --git a/nixos/tests/trac.nix b/nixos/tests/trac.nix
new file mode 100644
index 00000000000..643095d947e
--- /dev/null
+++ b/nixos/tests/trac.nix
@@ -0,0 +1,19 @@
+import ./make-test.nix ({ pkgs, ... }: {
+  name = "trac";
+  meta = with pkgs.stdenv.lib.maintainers; {
+    maintainers = [ mmahut ];
+  };
+
+  nodes = {
+    machine = { ... }: {
+      services.trac.enable = true;
+    };
+  };
+
+  testScript = ''
+    startAll;
+    $machine->waitForUnit("trac.service");
+    $machine->waitForOpenPort(8000);
+    $machine->waitUntilSucceeds("curl -L http://localhost:8000/ | grep 'Trac Powered'");
+  '';
+})