53 lines
1.3 KiB
Nix
53 lines
1.3 KiB
Nix
{ config, pkgs, lib, nixosConfig, ... }:
|
|
|
|
with lib;
|
|
|
|
let
|
|
inherit (nixosConfig.networking) hostName;
|
|
cfg = config.services.resilio-sync;
|
|
settingsFormat = pkgs.formats.json { };
|
|
|
|
capitalise = str: (toUpper (substring 0 1 str)) ++ substring 1 (-1) str;
|
|
in {
|
|
options.services.resilio-sync.enable = mkEnableOption "resilio-sync";
|
|
|
|
config = mkIf cfg.enable {
|
|
home.packages = [ pkgs.resilio-sync ];
|
|
home.file.".cache/rslsync/debug.txt".text = ''
|
|
80000000
|
|
0
|
|
'';
|
|
|
|
systemd.user.services = let
|
|
confFile = settingsFormat.generate "rslsync.conf" {
|
|
device_name = capitalise hostName;
|
|
storage_path = "~/.cache/rslsync";
|
|
pid_file = "~/.cache/rslsync/rslsync.pid";
|
|
|
|
use_upnp = true;
|
|
|
|
download_limit = 0;
|
|
upload_limit = 0;
|
|
|
|
directory_root = "~";
|
|
|
|
webui.listen = "0.0.0.0:8888";
|
|
};
|
|
in {
|
|
rslsync = {
|
|
Unit = {
|
|
Description = "Resilio Sync per-user service";
|
|
After = "network.target";
|
|
};
|
|
Service = {
|
|
Type = "simple";
|
|
ExecStart =
|
|
"${pkgs.resilio-sync}/bin/rslsync --nodaemon --config ${confFile}";
|
|
Restart = "on-abort";
|
|
};
|
|
Install = { WantedBy = [ "default.target" ]; };
|
|
};
|
|
};
|
|
};
|
|
}
|