summaryrefslogtreecommitdiff
path: root/modules/i2p.nix
diff options
context:
space:
mode:
Diffstat (limited to 'modules/i2p.nix')
-rw-r--r--modules/i2p.nix81
1 files changed, 81 insertions, 0 deletions
diff --git a/modules/i2p.nix b/modules/i2p.nix
new file mode 100644
index 0000000..5e36c20
--- /dev/null
+++ b/modules/i2p.nix
@@ -0,0 +1,81 @@
+{
+ config,
+ lib,
+ masterDomain,
+ securityTemplates,
+ ...
+}:
+let
+ cfg = config.os.srv.i2p;
+in
+{
+ options.os.srv.i2p = {
+ enable = lib.mkEnableOption "enables a flexible, polymorphic i2pd deployment profile";
+
+ mode = lib.mkOption {
+ type = lib.types.enum [
+ "server"
+ "client"
+ ];
+ default = "client";
+ description = "";
+ };
+ };
+
+ config = lib.mkIf cfg.enable (
+ lib.mkMerge [
+ {
+ services.i2pd = {
+ enable = true;
+ enableIPv6 = true;
+ reseed.verify = true;
+
+ yggdrasil.enable = true;
+
+ proto = {
+ http.enable = true;
+ httpProxy.enable = true;
+ socksProxy = {
+ enable = true;
+ outproxyEnable = true;
+ };
+ sam.enable = true;
+ i2pControl.enable = true;
+ };
+ };
+ }
+
+ (lib.mkIf (cfg.mode == "server") {
+ services.i2pd = {
+ bandwidth = 4096;
+
+ ntcp2.published = true;
+ ssu2.published = true;
+
+ #TODO add address
+ yggdrasil.address = "";
+ };
+
+ os.cluster.nginxProxies."i2p.${masterDomain}" = {
+ enableACME = true;
+ forceSSL = true;
+ locations."/" = {
+ proxyPass = "http://${config.os.core.network.ips.relay-vm}:7070";
+ extraConfig = securityTemplates.restrictToInternal;
+ };
+ };
+ })
+
+ (lib.mkIf (cfg.mode == "client") {
+ services.i2pd = {
+ bandwidth = 512;
+
+ ntcp2.published = false;
+ ssu2.published = false;
+
+ yggdrasil.address = "";
+ };
+ })
+ ]
+ );
+}