mirror of
https://github.com/buckley310/nixos-config.git
synced 2024-12-21 19:24:15 +00:00
ipfs: add "modes"
This commit is contained in:
parent
263ca88d61
commit
e1880e476e
1 changed files with 23 additions and 14 deletions
|
@ -1,17 +1,30 @@
|
||||||
{ config, lib, pkgs, ... }:
|
{ config, lib, pkgs, ... }:
|
||||||
let
|
let
|
||||||
cfg = config.sconfig.ipfs;
|
cfg = config.sconfig.ipfs;
|
||||||
|
|
||||||
|
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;
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
in
|
in
|
||||||
{
|
{
|
||||||
options.sconfig.ipfs = {
|
options.sconfig.ipfs = {
|
||||||
|
|
||||||
enable = lib.mkEnableOption "Turn on IPFS";
|
enable = lib.mkEnableOption "Turn on IPFS";
|
||||||
|
mode = lib.mkOption { type = lib.types.enum [ "server" "desktop" ]; };
|
||||||
lowpower = lib.mkOption {
|
|
||||||
type = lib.types.bool;
|
|
||||||
default = false;
|
|
||||||
description = "enable the 'lowpower' profile in IPFS.";
|
|
||||||
};
|
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -20,19 +33,15 @@ in
|
||||||
services.ipfs = {
|
services.ipfs = {
|
||||||
enable = true;
|
enable = true;
|
||||||
emptyRepo = true;
|
emptyRepo = true;
|
||||||
|
extraConfig = modes.${cfg.mode};
|
||||||
gatewayAddress = "/ip4/127.0.0.1/tcp/8001";
|
gatewayAddress = "/ip4/127.0.0.1/tcp/8001";
|
||||||
# Had issues without fdlimit. 65536 value taken from nixpkgs example
|
# Had issues without fdlimit. 65536 value taken from nixpkgs example
|
||||||
serviceFdlimit = 65536;
|
serviceFdlimit = 65536;
|
||||||
};
|
};
|
||||||
|
|
||||||
systemd.services.ipfs = {
|
systemd.services.ipfs.postStart = ''
|
||||||
preStart = lib.mkAfter (lib.optionalString cfg.lowpower ''
|
|
||||||
ipfs --offline config profile apply lowpower
|
|
||||||
'');
|
|
||||||
postStart = ''
|
|
||||||
chmod g+r /var/lib/ipfs/config
|
chmod g+r /var/lib/ipfs/config
|
||||||
'';
|
'';
|
||||||
};
|
|
||||||
|
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue