From 389becf9700d3dee7f09073ce4d235fc7c30b5c8 Mon Sep 17 00:00:00 2001 From: Azat Bahawi Date: Sun, 5 May 2024 14:28:31 +0300 Subject: 2024-05-05 --- modules/ipfs.nix | 32 ++++++++++++++++++++++++++++---- 1 file changed, 28 insertions(+), 4 deletions(-) (limited to 'modules/ipfs.nix') diff --git a/modules/ipfs.nix b/modules/ipfs.nix index cd28372..1dad6a6 100644 --- a/modules/ipfs.nix +++ b/modules/ipfs.nix @@ -1,5 +1,6 @@ { config, + inputs, lib, libNginx, this, @@ -23,12 +24,22 @@ in default = "ipfs.${config.networking.fqdn}"; }; + gatewayBind = mkOption { + description = "Gateway bind."; + type = with types; str; + default = "127.0.0.1"; + }; gatewayPort = mkOption { description = "Gateway port."; type = with types; port; default = if this.isHeadless then gatewayDefaultPort + 990 else gatewayDefaultPort; }; + apiBind = mkOption { + description = "API bind."; + type = with types; str; + default = "127.0.0.1"; + }; apiPort = mkOption { description = "API port."; type = with types; port; @@ -85,8 +96,8 @@ in in { Addresses = { - API = "/ip4/127.0.0.1/tcp/${toString cfg.apiPort}"; - Gateway = "/ip4/127.0.0.1/tcp/${toString cfg.gatewayPort}"; + API = "/ip4/${cfg.apiBind}/tcp/${toString cfg.apiPort}"; + Gateway = "/ip4/${cfg.gatewayBind}/tcp/${toString cfg.gatewayPort}"; Swarm = let port = toString cfg.swarmPort; @@ -118,13 +129,24 @@ in allowedTCPPorts = [ swarmDefaultPort ]; allowedUDPPorts = allowedTCPPorts; }; + + topology = with cfg; { + nodes.${this.hostname}.services.ipfs-kubo = { + name = "IPFS Kubo"; + icon = "${inputs.homelab-svg-assets}/assets/ipfs.svg"; + details.listen.text = '' + ${gatewayBind}:${toString gatewayPort} + ${apiBind}:${toString apiPort} + ''; + }; + }; } (mkIf this.isHeadless { nixfiles.modules.nginx = { enable = true; upstreams = with cfg; { - kubo_gateway.servers."127.0.0.1:${toString gatewayPort}" = { }; - kubo_api.servers."127.0.0.1:${toString apiPort}" = { }; + kubo_gateway.servers."${gatewayBind}:${toString gatewayPort}" = { }; + kubo_api.servers."${apiBind}:${toString apiPort}" = { }; }; virtualHosts = { ${cfg.domain} = { @@ -140,6 +162,8 @@ in }; }; }; + + topology.nodes.${this.hostname}.services.ipfs-kubo.info = cfg.domain; }) ]); } -- cgit v1.2.3