From 263ca88d61024b799dd4a993ab88b3f758f2fca7 Mon Sep 17 00:00:00 2001 From: Sean Buckley Date: Sat, 12 Feb 2022 22:41:57 -0500 Subject: [PATCH] add IFPS module --- modules/ipfs.nix | 38 ++++++++++++++++++++++++++++++++++++++ modules/sean.nix | 11 ++++++++++- 2 files changed, 48 insertions(+), 1 deletion(-) create mode 100644 modules/ipfs.nix diff --git a/modules/ipfs.nix b/modules/ipfs.nix new file mode 100644 index 0000000..5bbbb31 --- /dev/null +++ b/modules/ipfs.nix @@ -0,0 +1,38 @@ +{ config, lib, pkgs, ... }: +let + cfg = config.sconfig.ipfs; +in +{ + options.sconfig.ipfs = { + + enable = lib.mkEnableOption "Turn on IPFS"; + + lowpower = lib.mkOption { + type = lib.types.bool; + default = false; + description = "enable the 'lowpower' profile in IPFS."; + }; + + }; + + config = lib.mkIf cfg.enable { + + services.ipfs = { + enable = true; + emptyRepo = true; + gatewayAddress = "/ip4/127.0.0.1/tcp/8001"; + # Had issues without fdlimit. 65536 value taken from nixpkgs example + serviceFdlimit = 65536; + }; + + systemd.services.ipfs = { + preStart = lib.mkAfter (lib.optionalString cfg.lowpower '' + ipfs --offline config profile apply lowpower + ''); + postStart = '' + chmod g+r /var/lib/ipfs/config + ''; + }; + + }; +} diff --git a/modules/sean.nix b/modules/sean.nix index a6bc7de..c11a86b 100644 --- a/modules/sean.nix +++ b/modules/sean.nix @@ -12,7 +12,16 @@ in users.users.sean = { isNormalUser = true; - extraGroups = [ "wheel" "audio" "video" "networkmanager" "dialout" "input" "wireshark" ]; + extraGroups = [ + "audio" + "dialout" + "input" + "networkmanager" + "video" + "wheel" + "wireshark" + config.services.ipfs.group + ]; openssh.authorizedKeys = { inherit keys; }; };