summary refs log tree commit diff
path: root/nixos/modules/services/networking/shadowsocks.nix
diff options
context:
space:
mode:
authorHenri Menke <henrimenke@gmail.com>2020-06-24 10:36:36 +1200
committerHenri Menke <henrimenke@gmail.com>2020-08-26 14:01:41 +1200
commitd35cb151534861162478079877818e71e6838ac1 (patch)
tree02d1dd06b80f38ea690ad87c3ad9fece406062ab /nixos/modules/services/networking/shadowsocks.nix
parente23ed2f21c800701f28a322bd1f007eb2ada934c (diff)
downloadnixpkgs-d35cb151534861162478079877818e71e6838ac1.tar
nixpkgs-d35cb151534861162478079877818e71e6838ac1.tar.gz
nixpkgs-d35cb151534861162478079877818e71e6838ac1.tar.bz2
nixpkgs-d35cb151534861162478079877818e71e6838ac1.tar.lz
nixpkgs-d35cb151534861162478079877818e71e6838ac1.tar.xz
nixpkgs-d35cb151534861162478079877818e71e6838ac1.tar.zst
nixpkgs-d35cb151534861162478079877818e71e6838ac1.zip
nixos/shadowsocks: support plugins
Diffstat (limited to 'nixos/modules/services/networking/shadowsocks.nix')
-rw-r--r--nixos/modules/services/networking/shadowsocks.nix36
1 files changed, 33 insertions, 3 deletions
diff --git a/nixos/modules/services/networking/shadowsocks.nix b/nixos/modules/services/networking/shadowsocks.nix
index af12db590f0..4fd988297f6 100644
--- a/nixos/modules/services/networking/shadowsocks.nix
+++ b/nixos/modules/services/networking/shadowsocks.nix
@@ -11,8 +11,13 @@ let
     method = cfg.encryptionMethod;
     mode = cfg.mode;
     user = "nobody";
-    fast_open = true;
-  } // optionalAttrs (cfg.password != null) { password = cfg.password; };
+    fast_open = cfg.fastOpen;
+  } // optionalAttrs (cfg.plugin != null) {
+    plugin = cfg.plugin;
+    plugin_opts = cfg.pluginOpts;
+  } // optionalAttrs (cfg.password != null) {
+    password = cfg.password;
+  };
 
   configFile = pkgs.writeText "shadowsocks.json" (builtins.toJSON opts);
 
@@ -74,6 +79,14 @@ in
         '';
       };
 
+      fastOpen = mkOption {
+        type = types.bool;
+        default = true;
+        description = ''
+          use TCP fast-open
+        '';
+      };
+
       encryptionMethod = mkOption {
         type = types.str;
         default = "chacha20-ietf-poly1305";
@@ -82,6 +95,23 @@ in
         '';
       };
 
+      plugin = mkOption {
+        type = types.nullOr types.str;
+        default = null;
+        example = "\${pkgs.shadowsocks-v2ray-plugin}/bin/v2ray-plugin";
+        description = ''
+          SIP003 plugin for shadowsocks
+        '';
+      };
+
+      pluginOpts = mkOption {
+        type = types.str;
+        default = "";
+        example = "server;host=example.com";
+        description = ''
+          Options to pass to the plugin if one was specified
+        '';
+      };
     };
 
   };
@@ -99,7 +129,7 @@ in
       description = "shadowsocks-libev Daemon";
       after = [ "network.target" ];
       wantedBy = [ "multi-user.target" ];
-      path = [ pkgs.shadowsocks-libev ] ++ optional (cfg.passwordFile != null) pkgs.jq;
+      path = [ pkgs.shadowsocks-libev cfg.plugin ] ++ optional (cfg.passwordFile != null) pkgs.jq;
       serviceConfig.PrivateTmp = true;
       script = ''
         ${optionalString (cfg.passwordFile != null) ''