nixos-config/modules/ipfs.nix

48 lines
1.1 KiB
Nix
Raw Normal View History

2022-02-13 03:41:57 +00:00
{ config, lib, pkgs, ... }:
let
cfg = config.sconfig.ipfs;
2022-02-15 21:20:40 +00:00
modes = {
server = {
Swarm.DisableNatPortMap = true; # Disable UPnP
AutoNAT.ServiceMode = "disabled"; # maybe change this to "enabled" ?
Routing.Type = "dhtclient"; # maybe change this to "dht" ?
Swarm.ConnMgr.HighWater = 900;
Swarm.ConnMgr.LowWater = 600;
};
desktop = {
Swarm.DisableNatPortMap = true; # Disable UPnP
AutoNAT.ServiceMode = "disabled";
Routing.Type = "dhtclient";
Swarm.ConnMgr.HighWater = 300;
Swarm.ConnMgr.LowWater = 50;
};
};
2022-02-13 03:41:57 +00:00
in
{
options.sconfig.ipfs = {
enable = lib.mkEnableOption "Turn on IPFS";
2022-02-15 21:20:40 +00:00
mode = lib.mkOption { type = lib.types.enum [ "server" "desktop" ]; };
2022-02-13 03:41:57 +00:00
};
config = lib.mkIf cfg.enable {
services.ipfs = {
enable = true;
emptyRepo = true;
2022-02-15 21:20:40 +00:00
extraConfig = modes.${cfg.mode};
2022-02-13 03:41:57 +00:00
gatewayAddress = "/ip4/127.0.0.1/tcp/8001";
# Had issues without fdlimit. 65536 value taken from nixpkgs example
serviceFdlimit = 65536;
};
2022-02-15 21:20:40 +00:00
systemd.services.ipfs.postStart = ''
chmod g+r /var/lib/ipfs/config
'';
2022-02-13 03:41:57 +00:00
};
}