summary refs log tree commit diff
path: root/nixos
diff options
context:
space:
mode:
authorMatej Cotman <cotman.matej@gmail.com>2014-04-03 18:54:10 +0200
committerDomen Kožar <domen@dev.si>2014-04-04 10:46:29 +0200
commit7df1ce5088f3404b985aac4bb1814f98463a43a0 (patch)
tree2fbe42b3b4332789084bab204741480267318d81 /nixos
parent8b5c6172378fdd447fb89acf4dbf2e1d5ed0f416 (diff)
downloadnixlib-7df1ce5088f3404b985aac4bb1814f98463a43a0.tar
nixlib-7df1ce5088f3404b985aac4bb1814f98463a43a0.tar.gz
nixlib-7df1ce5088f3404b985aac4bb1814f98463a43a0.tar.bz2
nixlib-7df1ce5088f3404b985aac4bb1814f98463a43a0.tar.lz
nixlib-7df1ce5088f3404b985aac4bb1814f98463a43a0.tar.xz
nixlib-7df1ce5088f3404b985aac4bb1814f98463a43a0.tar.zst
nixlib-7df1ce5088f3404b985aac4bb1814f98463a43a0.zip
syncthing: new package and nixos module
Diffstat (limited to 'nixos')
-rw-r--r--nixos/modules/module-list.nix1
-rw-r--r--nixos/modules/services/networking/syncthing.nix73
2 files changed, 74 insertions, 0 deletions
diff --git a/nixos/modules/module-list.nix b/nixos/modules/module-list.nix
index 652a99e7c5a6..5d8461bb8856 100644
--- a/nixos/modules/module-list.nix
+++ b/nixos/modules/module-list.nix
@@ -198,6 +198,7 @@
   ./services/networking/sabnzbd.nix
   ./services/networking/searx.nix
   ./services/networking/supybot.nix
+  ./services/networking/syncthing.nix
   ./services/networking/ssh/lshd.nix
   ./services/networking/ssh/sshd.nix
   ./services/networking/tftpd.nix
diff --git a/nixos/modules/services/networking/syncthing.nix b/nixos/modules/services/networking/syncthing.nix
new file mode 100644
index 000000000000..345693fec767
--- /dev/null
+++ b/nixos/modules/services/networking/syncthing.nix
@@ -0,0 +1,73 @@
+{ config, pkgs, ... }:
+
+with pkgs.lib;
+
+let
+
+  cfg = config.services.syncthing;
+
+in
+
+{
+
+  ###### interface
+
+  options = {
+
+    services.syncthing = {
+
+      enable = mkOption {
+        default = false;
+        description = ''
+          Whether to enable the Syncthing, self-hosted open-source alternative
+          to Dropbox and BittorrentSync. Initial interface will be
+          available on http://127.0.0.1:8080/.
+        '';
+      };
+
+      user = mkOption {
+        default = "syncthing";
+        description = ''
+          Syncthing will be run under this user (user must exist,
+          this can be your user name).
+        '';
+      };
+
+      dataDir = mkOption {
+        default = "/var/lib/syncthing";
+        description = ''
+          Path where the `.syncthing` (settings and keys) and `Sync`
+          (your synced files) directories will exist. This can be your home
+          directory.
+        '';
+      };
+
+    };
+
+  };
+
+
+  ###### implementation
+
+  config = mkIf config.services.syncthing.enable {
+
+    systemd.services.syncthing =
+      {
+        description = "Syncthing service";
+        after = [ "network.target" ];
+        wantedBy = [ "multi-user.target" ];
+        environment.STNORESTART = "placeholder";  # do not self-restart
+        environment.HOME = "${config.services.syncthing.dataDir}";
+        serviceConfig = {
+          User = "${config.services.syncthing.user}";
+          ExecStart = "${pkgs.syncthing}/bin/syncthing -home=${config.services.syncthing.dataDir}/.syncthing";
+          Restart = "always";
+        };
+
+      };
+
+    environment.systemPackages = [ pkgs.syncthing ];
+
+  };
+
+}