X-Git-Url: http://git.scottworley.com/syncthing-autoregister/blobdiff_plain/320df2769f2068a8f4d0119682530db89d1f8c91..refs/heads/master:/modules/syncthing-autoregister.nix diff --git a/modules/syncthing-autoregister.nix b/modules/syncthing-autoregister.nix index 6276352..710c7a4 100644 --- a/modules/syncthing-autoregister.nix +++ b/modules/syncthing-autoregister.nix @@ -17,11 +17,10 @@ in { ''; path = mkOption { type = types.path; - default = "/tmp/syncthing-auto-register-test-device-ids.nix"; description = '' Path of nix module file to write our syncthing device id into. It will be written into - services.syncthing.declarative.devices..id. This file + services.syncthing.devices..id. This file can be imported as a NixOS module. We recommend using a separate file just for this purpose. I.e., @@ -46,6 +45,20 @@ in { ExecStart = register-script; }; }; + systemd.services.syncthing-reregister = { + after = [ "syncthing-autoregister.service" ]; + script = '' + ${pkgs.coreutils}/bin/sleep 1 + ${pkgs.systemd}/bin/systemctl restart syncthing-autoregister + ''; + serviceConfig = { + Type = "oneshot"; + }; + }; + systemd.paths.syncthing-reregister = { + pathConfig.PathChanged = cfg.path; + wantedBy = [ "multi-user.target" ]; + }; }; }