summary refs log tree commit diff
path: root/nixos/modules/services/networking
diff options
context:
space:
mode:
authorSilvan Mosberger <contact@infinisil.com>2022-03-24 00:25:35 +0100
committerSilvan Mosberger <contact@infinisil.com>2022-03-24 04:46:26 +0100
commitbc4631d8f0f3f388be3fffb959a893ead997d50a (patch)
tree61241acb81d7fa04f2314365ebb118d51e903ada /nixos/modules/services/networking
parent218fad1f57b01a1714539b98645b4a26aa5013d6 (diff)
downloadnixpkgs-bc4631d8f0f3f388be3fffb959a893ead997d50a.tar
nixpkgs-bc4631d8f0f3f388be3fffb959a893ead997d50a.tar.gz
nixpkgs-bc4631d8f0f3f388be3fffb959a893ead997d50a.tar.bz2
nixpkgs-bc4631d8f0f3f388be3fffb959a893ead997d50a.tar.lz
nixpkgs-bc4631d8f0f3f388be3fffb959a893ead997d50a.tar.xz
nixpkgs-bc4631d8f0f3f388be3fffb959a893ead997d50a.tar.zst
nixpkgs-bc4631d8f0f3f388be3fffb959a893ead997d50a.zip
nixos/syncplay: Add server password support
Diffstat (limited to 'nixos/modules/services/networking')
-rw-r--r--nixos/modules/services/networking/syncplay.nix18
1 files changed, 17 insertions, 1 deletions
diff --git a/nixos/modules/services/networking/syncplay.nix b/nixos/modules/services/networking/syncplay.nix
index b6faf2d3f77..c17426ecced 100644
--- a/nixos/modules/services/networking/syncplay.nix
+++ b/nixos/modules/services/networking/syncplay.nix
@@ -61,6 +61,15 @@ in
           Group to use when running Syncplay.
         '';
       };
+
+      passwordFile = mkOption {
+        type = types.nullOr types.path;
+        default = null;
+        description = ''
+          Path to the file that contains the server password. If
+          <literal>null</literal>, the server doesn't require a password.
+        '';
+      };
     };
   };
 
@@ -71,10 +80,17 @@ in
       after       = [ "network-online.target" ];
 
       serviceConfig = {
-        ExecStart = "${pkgs.syncplay}/bin/syncplay-server ${escapeShellArgs cmdArgs}";
         User = cfg.user;
         Group = cfg.group;
+        LoadCredential = lib.mkIf (cfg.passwordFile != null) "password:${cfg.passwordFile}";
       };
+
+      script = ''
+        ${lib.optionalString (cfg.passwordFile != null) ''
+          export SYNCPLAY_PASSWORD=$(cat "''${CREDENTIALS_DIRECTORY}/password")
+        ''}
+        exec ${pkgs.syncplay}/bin/syncplay-server ${escapeShellArgs cmdArgs}
+      '';
     };
   };
 }