git.iko.soy/typeable/nixpkgs
on master help sign in
Merge pull request #95220 from obsidiansystems/ipfs-quic-socket-activated

nixos/ipfs: Allow QUIC connections to socket activate too

commit6fffd50623b6d6e707bbe3dd83be498a0963946a authorMatthew Bauer <mjbauer95@gmail.com> dateWed 12 Aug 2020, 13:47 (6 years ago) parent07f111ee6fe9ab
3 files changed+28−3
nixos/modules/services/network-filesystems/ipfs.nix+17−3 nixos/modules/system/boot/systemd-unit-options.nix+10 nixos/modules/system/boot/systemd.nix+1
nixos/modules/services/network-filesystems/ipfs.nix+17−3
@@ -25,6 +25,15 @@ let
2525 then "/${lib.concatStringsSep "/" (lib.tail addr)}"
2626 else null; # not valid for listen stream, skip
2727
28+ multiaddrToListenDatagram = addrRaw: let
29+ addr = splitMulitaddr addrRaw;
30+ s = builtins.elemAt addr;
31+ in if s 0 == "ip4" && s 2 == "udp"
32+ then "${s 1}:${s 3}"
33+ else if s 0 == "ip6" && s 2 == "udp"
34+ then "[${s 1}]:${s 3}"
35+ else null; # not valid for listen datagram, skip
36+
2837in {
2938
3039 ###### interface
@@ -268,9 +277,14 @@ in {
268277
269278 systemd.sockets.ipfs-gateway = {
270279 wantedBy = [ "sockets.target" ];
271− socketConfig.ListenStream = let
272− fromCfg = multiaddrToListenStream cfg.gatewayAddress;
273− in [ "" ] ++ lib.optional (fromCfg != null) fromCfg;
280+ socketConfig = {
281+ ListenStream = let
282+ fromCfg = multiaddrToListenStream cfg.gatewayAddress;
283+ in [ "" ] ++ lib.optional (fromCfg != null) fromCfg;
284+ ListenDatagram = let
285+ fromCfg = multiaddrToListenDatagram cfg.gatewayAddress;
286+ in [ "" ] ++ lib.optional (fromCfg != null) fromCfg;
287+ };
274288 };
275289
276290 systemd.sockets.ipfs-api = {
nixos/modules/system/boot/systemd-unit-options.nix+10
@@ -379,6 +379,16 @@ in rec {
379379 '';
380380 };
381381
382+ listenDatagrams = mkOption {
383+ default = [];
384+ type = types.listOf types.str;
385+ example = [ "0.0.0.0:993" "/run/my-socket" ];
386+ description = ''
387+ For each item in this list, a <literal>ListenDatagram</literal>
388+ option in the <literal>[Socket]</literal> section will be created.
389+ '';
390+ };
391+
382392 socketConfig = mkOption {
383393 default = {};
384394 example = { ListenStream = "/run/my-socket"; };
nixos/modules/system/boot/systemd.nix+1
@@ -354,6 +354,7 @@ let
354354 [Socket]
355355 ${attrsToSection def.socketConfig}
356356 ${concatStringsSep "\n" (map (s: "ListenStream=${s}") def.listenStreams)}
357+ ${concatStringsSep "\n" (map (s: "ListenDatagram=${s}") def.listenDatagrams)}
357358 '';
358359 };
359360