2023-08-31 01:55:45 +03:00
|
|
|
{ config, depot, lib, pkgs, ... }:
|
2022-10-20 01:08:12 +03:00
|
|
|
|
|
|
|
let
|
2023-08-31 01:55:45 +03:00
|
|
|
inherit (depot.lib.meta) domain;
|
|
|
|
inherit (depot.lib.nginx) vhosts;
|
2022-10-22 03:29:56 +03:00
|
|
|
cfg = config.services.ipfs-cluster;
|
2022-10-20 01:08:12 +03:00
|
|
|
ipfsCfg = config.services.ipfs;
|
|
|
|
|
|
|
|
apiSocket = "/run/ipfs-cluster/ipfs-cluster-api.sock";
|
|
|
|
pinSvcSocket = "/run/ipfs-cluster/ipfs-pinning-service-api.sock";
|
|
|
|
proxySocket = "/run/ipfs-cluster/ipfs-api-proxy.sock";
|
|
|
|
in {
|
|
|
|
imports = [
|
2023-01-31 23:59:53 +02:00
|
|
|
depot.nixosModules.ipfs-cluster
|
2022-10-20 01:08:12 +03:00
|
|
|
];
|
|
|
|
|
2024-06-04 20:58:54 +03:00
|
|
|
system.ascensions.ipfs-cluster = {
|
|
|
|
requiredBy = [ "ipfs-cluster.service" ];
|
|
|
|
incantations = i: [ ];
|
|
|
|
};
|
|
|
|
|
2022-10-22 03:29:56 +03:00
|
|
|
age.secrets = {
|
|
|
|
ipfs-cluster-secret.file = ./cluster-secret.age;
|
|
|
|
ipfs-cluster-pinsvc-credentials = {
|
|
|
|
file = ./cluster-pinsvc-credentials.age;
|
|
|
|
owner = cfg.user;
|
|
|
|
};
|
2022-10-20 01:08:12 +03:00
|
|
|
};
|
|
|
|
|
|
|
|
services.ipfs-cluster = {
|
|
|
|
enable = true;
|
2023-03-07 02:26:07 +02:00
|
|
|
package = depot.packages.ipfs-cluster;
|
2022-10-20 01:08:12 +03:00
|
|
|
consensus = "crdt";
|
|
|
|
dataDir = "/srv/storage/ipfs/cluster";
|
|
|
|
secretFile = config.age.secrets.ipfs-cluster-secret.path;
|
2022-10-22 03:29:56 +03:00
|
|
|
pinSvcBasicAuthFile = config.age.secrets.ipfs-cluster-pinsvc-credentials.path;
|
2022-10-20 01:08:12 +03:00
|
|
|
openSwarmPort = true;
|
|
|
|
settings = {
|
|
|
|
cluster = {
|
|
|
|
peer_addresses = [
|
|
|
|
"/ip4/95.216.8.12/tcp/9096/p2p/12D3KooWFqccQN24XbpJbguWmtqAJwKarPXxMNqGCz1wSQqKL97D"
|
|
|
|
"/ip4/152.67.79.222/tcp/9096/p2p/12D3KooWC7y9GH5j6zioqGx6354WfWwKCQAKbRMDJY2gJ5j5qLzm"
|
|
|
|
];
|
|
|
|
replication_factor_min = 1;
|
|
|
|
replication_factor_max = 2;
|
|
|
|
};
|
|
|
|
api = {
|
|
|
|
ipfsproxy = {
|
|
|
|
listen_multiaddress = "/unix${proxySocket}";
|
|
|
|
node_multiaddress = ipfsCfg.apiAddress;
|
|
|
|
};
|
|
|
|
pinsvcapi.http_listen_multiaddress = "/unix${pinSvcSocket}";
|
|
|
|
restapi.http_listen_multiaddress = "/unix${apiSocket}";
|
|
|
|
};
|
|
|
|
ipfs_connector.ipfshttp.node_multiaddress = ipfsCfg.apiAddress;
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
systemd.services.ipfs-cluster = {
|
|
|
|
postStart = ''
|
|
|
|
chmod 0660 ${apiSocket} ${pinSvcSocket} ${proxySocket}
|
|
|
|
'';
|
|
|
|
serviceConfig = {
|
2023-12-02 00:12:42 +02:00
|
|
|
TimeoutStartSec = "600s";
|
2022-10-20 01:08:12 +03:00
|
|
|
IPAddressDeny = [
|
|
|
|
"10.0.0.0/8"
|
|
|
|
"100.64.0.0/10"
|
|
|
|
"169.254.0.0/16"
|
|
|
|
"172.16.0.0/12"
|
|
|
|
"192.0.0.0/24"
|
|
|
|
"192.0.2.0/24"
|
|
|
|
"192.168.0.0/16"
|
|
|
|
"198.18.0.0/15"
|
|
|
|
"198.51.100.0/24"
|
|
|
|
"203.0.113.0/24"
|
|
|
|
"240.0.0.0/4"
|
|
|
|
"100::/64"
|
|
|
|
"2001:2::/48"
|
|
|
|
"2001:db8::/32"
|
|
|
|
"fc00::/7"
|
|
|
|
"fe80::/10"
|
|
|
|
];
|
|
|
|
};
|
|
|
|
};
|
2022-10-22 03:29:56 +03:00
|
|
|
|
|
|
|
services.nginx.virtualHosts."pin.${domain}" = vhosts.proxy "http://unix:${pinSvcSocket}";
|
|
|
|
users.users.nginx.extraGroups = [ cfg.group ];
|
|
|
|
security.acme.certs."pin.${domain}" = {
|
2023-12-04 20:31:03 +02:00
|
|
|
dnsProvider = "exec";
|
2022-10-22 03:29:56 +03:00
|
|
|
webroot = lib.mkForce null;
|
|
|
|
};
|
2022-10-20 01:08:12 +03:00
|
|
|
}
|