aboutsummaryrefslogtreecommitdiff
path: root/nixpkgs/nixos/modules/services/networking/shadowsocks.nix
diff options
context:
space:
mode:
Diffstat (limited to 'nixpkgs/nixos/modules/services/networking/shadowsocks.nix')
-rw-r--r--nixpkgs/nixos/modules/services/networking/shadowsocks.nix54
1 files changed, 51 insertions, 3 deletions
diff --git a/nixpkgs/nixos/modules/services/networking/shadowsocks.nix b/nixpkgs/nixos/modules/services/networking/shadowsocks.nix
index af12db590f0..d2541f9a6df 100644
--- a/nixpkgs/nixos/modules/services/networking/shadowsocks.nix
+++ b/nixpkgs/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;
+ } // cfg.extraConfig;
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,41 @@ 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
+ '';
+ };
+
+ extraConfig = mkOption {
+ type = types.attrs;
+ default = {};
+ example = ''
+ {
+ nameserver = "8.8.8.8";
+ }
+ '';
+ description = ''
+ Additional configuration for shadowsocks that is not covered by the
+ provided options. The provided attrset will be serialized to JSON and
+ has to contain valid shadowsocks options. Unfortunately most
+ additional options are undocumented but it's easy to find out what is
+ available by looking into the source code of
+ <link xlink:href="https://github.com/shadowsocks/shadowsocks-libev/blob/master/src/jconf.c"/>
+ '';
+ };
};
};
@@ -99,7 +147,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 ] ++ optional (cfg.plugin != null) cfg.plugin ++ optional (cfg.passwordFile != null) pkgs.jq;
serviceConfig.PrivateTmp = true;
script = ''
${optionalString (cfg.passwordFile != null) ''