]> git.scottworley.com Git - syncthing-autoregister/commitdiff
Enable option for auto-registration
authorScott Worley <scottworley@scottworley.com>
Mon, 27 Jul 2020 20:58:29 +0000 (13:58 -0700)
committerScott Worley <scottworley@scottworley.com>
Mon, 27 Jul 2020 20:58:29 +0000 (13:58 -0700)
modules/syncthing-autoregister.nix
tests/automatic-enrollment.nix

index d1f0a7ce117f01bc2217bf93522490a6124f2d86..158cd520f5c2d787c6168fa0990fc2f1c5d657b2 100644 (file)
@@ -1,11 +1,20 @@
 { config, lib, pkgs, ... }:
 { config, lib, pkgs, ... }:
+with lib;
 let
 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 {
   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 {
-  config = {
+  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" ];
     systemd.services.syncthing-autoregister = {
       after = [ "syncthing.service" "syncthing-init.service" ];
       wantedBy = [ "multi-user.target" ];
index cac1b28ba83956bea3ea77f67fbe355ea4b81411..9577510d0a1eab9201379f2cec86043cf6bd3971 100644 (file)
@@ -9,6 +9,9 @@ import <nixpkgs/nixos/tests/make-test-python.nix> ({ pkgs, lib, ... }:
         services.syncthing = {
           enable = true;
           openDefaultPorts = true;
         services.syncthing = {
           enable = true;
           openDefaultPorts = true;
+          autoRegister = {
+            enable = true;
+          };
         };
         environment.systemPackages = with pkgs; [ nix ];
       }
         };
         environment.systemPackages = with pkgs; [ nix ];
       }