at v192 1.4 kB view raw
1{ config, lib, pkgs, ... }: 2 3with lib; 4 5let 6 7 cfg = config.services.syncthing; 8 9in 10 11{ 12 13 ###### interface 14 15 options = { 16 17 services.syncthing = { 18 19 enable = mkOption { 20 default = false; 21 description = '' 22 Whether to enable the Syncthing, self-hosted open-source alternative 23 to Dropbox and BittorrentSync. Initial interface will be 24 available on http://127.0.0.1:8080/. 25 ''; 26 }; 27 28 user = mkOption { 29 default = "syncthing"; 30 description = '' 31 Syncthing will be run under this user (user must exist, 32 this can be your user name). 33 ''; 34 }; 35 36 dataDir = mkOption { 37 default = "/var/lib/syncthing"; 38 description = '' 39 Path where the settings and keys will exist. 40 ''; 41 }; 42 43 }; 44 45 }; 46 47 48 ###### implementation 49 50 config = mkIf cfg.enable { 51 52 systemd.services.syncthing = 53 { 54 description = "Syncthing service"; 55 after = [ "network.target" ]; 56 wantedBy = [ "multi-user.target" ]; 57 environment.STNORESTART = "placeholder"; # do not self-restart 58 serviceConfig = { 59 User = "${cfg.user}"; 60 PermissionsStartOnly = true; 61 Restart = "always"; 62 ExecStart = "${pkgs.syncthing}/bin/syncthing -no-browser -home=${cfg.dataDir}"; 63 }; 64 }; 65 66 environment.systemPackages = [ pkgs.syncthing ]; 67 68 }; 69 70}