]>
Commit | Line | Data |
---|---|---|
b00b144b | 1 | { config, lib, pkgs, ... }: |
7fb0951b | 2 | with lib; |
b00b144b | 3 | let |
7fb0951b | 4 | cfg = config.services.syncthing.autoRegister; |
b00b144b SW |
5 | localpkgs = import ../. { inherit pkgs; }; |
6 | register-script = pkgs.writeShellScript "syncthing-autoregister-script" '' | |
7 | ${localpkgs.syncthing-set-id}/bin/syncthing-set-id /tmp/syncthing-auto-register-test-device-ids.nix | |
8 | ''; | |
9 | in { | |
7fb0951b SW |
10 | options = { |
11 | services.syncthing.autoRegister = { | |
12 | enable = mkEnableOption '' | |
13 | Automatically write the local syncthing device id to /tmp/syncthing-auto-register-test-device-ids.nix | |
14 | ''; | |
15 | }; | |
16 | }; | |
17 | config = mkIf cfg.enable { | |
b00b144b SW |
18 | systemd.services.syncthing-autoregister = { |
19 | after = [ "syncthing.service" "syncthing-init.service" ]; | |
20 | wantedBy = [ "multi-user.target" ]; | |
21 | environment.NIX_PATH = config.environment.variables.NIX_PATH; | |
22 | serviceConfig = { | |
23 | User = config.services.syncthing.user; | |
24 | RemainAfterExit = true; | |
25 | Type = "oneshot"; | |
26 | ExecStart = register-script; | |
27 | }; | |
28 | }; | |
29 | }; | |
30 | } | |
31 |