summaryrefslogtreecommitdiff
path: root/modules/ipfs.nix
diff options
context:
space:
mode:
authorAzat Bahawi <azat@bahawi.net>2024-05-05 14:28:31 +0300
committerAzat Bahawi <azat@bahawi.net>2024-05-05 14:28:31 +0300
commit389becf9700d3dee7f09073ce4d235fc7c30b5c8 (patch)
tree3db9d75bd5275614fc904184c97b3133f38bc3d0 /modules/ipfs.nix
parent3cd3233f7eaf2a8a715d587820d6d4577a24d958 (diff)
2024-05-05
Diffstat (limited to 'modules/ipfs.nix')
-rw-r--r--modules/ipfs.nix32
1 files changed, 28 insertions, 4 deletions
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;
})
]);
}