{ config, lib, pkgs, ... }: with lib; let cfg = config.services.syncthing.autoRegister; localpkgs = import ../. { inherit pkgs; }; register-script = pkgs.writeShellScript "syncthing-autoregister-script" '' ${localpkgs.syncthing-set-id}/bin/syncthing-set-id /tmp/syncthing-auto-register-test-device-ids.nix ''; in { options = { services.syncthing.autoRegister = { enable = mkEnableOption '' Automatically write the local syncthing device id to /tmp/syncthing-auto-register-test-device-ids.nix ''; }; }; config = mkIf cfg.enable { systemd.services.syncthing-autoregister = { after = [ "syncthing.service" "syncthing-init.service" ]; wantedBy = [ "multi-user.target" ]; environment.NIX_PATH = config.environment.variables.NIX_PATH; serviceConfig = { User = config.services.syncthing.user; RemainAfterExit = true; Type = "oneshot"; ExecStart = register-script; }; }; }; }