summary refs log tree commit diff
path: root/nixos/modules/services/networking/spacecookie.nix
diff options
context:
space:
mode:
authorsternenseemann <0rpkxez4ksa01gb3typccl0i@systemli.org>2021-03-10 22:07:27 +0100
committersterni <sternenseemann@systemli.org>2021-04-10 15:44:19 +0200
commitb74821f31b468d8a302b07e528bcce16c24e4b06 (patch)
tree0d12b9b685e45d2e4e887daf7727cec36c92e511 /nixos/modules/services/networking/spacecookie.nix
parentd1f57cbaf02be1ea3434563446c417ef98748568 (diff)
downloadnixpkgs-b74821f31b468d8a302b07e528bcce16c24e4b06.tar
nixpkgs-b74821f31b468d8a302b07e528bcce16c24e4b06.tar.gz
nixpkgs-b74821f31b468d8a302b07e528bcce16c24e4b06.tar.bz2
nixpkgs-b74821f31b468d8a302b07e528bcce16c24e4b06.tar.lz
nixpkgs-b74821f31b468d8a302b07e528bcce16c24e4b06.tar.xz
nixpkgs-b74821f31b468d8a302b07e528bcce16c24e4b06.tar.zst
nixpkgs-b74821f31b468d8a302b07e528bcce16c24e4b06.zip
nixos/spacecookie: add address option customizing listen address
This configuration option reflects a new feature from the unreleased
spacecookie version allowing to customize the address spacecookie will
listen on (e. g. "::1" to bind on link-local addresses only). We will
not use this feature in the future, since the configuration option of
spacecookie naturally only has an effect if we don't use socket
activation (and spacecookie sets up its own socket), but having the same
functionality in the service seems like a good idea.

We can luckily emulate this behavior with socket activation as well.
Diffstat (limited to 'nixos/modules/services/networking/spacecookie.nix')
-rw-r--r--nixos/modules/services/networking/spacecookie.nix12
1 files changed, 11 insertions, 1 deletions
diff --git a/nixos/modules/services/networking/spacecookie.nix b/nixos/modules/services/networking/spacecookie.nix
index adba0fbfbf2..4b908eee054 100644
--- a/nixos/modules/services/networking/spacecookie.nix
+++ b/nixos/modules/services/networking/spacecookie.nix
@@ -60,6 +60,16 @@ in {
           The root directory spacecookie serves via gopher.
         '';
       };
+
+      address = mkOption {
+        type = types.str;
+        default = "[::]";
+        description = ''
+          Address to listen on. Must be in the
+          <literal>ListenStream=</literal> syntax of
+          <link xlink:href="https://www.freedesktop.org/software/systemd/man/systemd.socket.html">systemd.socket(5)</link>.
+        '';
+      };
     };
   };
 
@@ -68,7 +78,7 @@ in {
     systemd.sockets.spacecookie = {
       description = "Socket for the Spacecookie Gopher Server";
       wantedBy = [ "sockets.target" ];
-      listenStreams = [ "[::]:${toString cfg.port}" ];
+      listenStreams = [ "${cfg.address}:${toString cfg.port}" ];
       socketConfig = {
         BindIPv6Only = "both";
       };