nixos/shadowsocks: add test without plugin

Changed files
+32 -12
nixos
modules
services
networking
tests
+1 -1
nixos/modules/services/networking/shadowsocks.nix
···
description = "shadowsocks-libev Daemon";
after = [ "network.target" ];
wantedBy = [ "multi-user.target" ];
-
path = [ pkgs.shadowsocks-libev cfg.plugin ] ++ 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) ''
+1 -1
nixos/tests/all-tests.nix
···
sanoid = handleTest ./sanoid.nix {};
sddm = handleTest ./sddm.nix {};
service-runner = handleTest ./service-runner.nix {};
-
shadowsocks = handleTest ./shadowsocks.nix {};
+
shadowsocks = handleTest ./shadowsocks {};
shattered-pixel-dungeon = handleTest ./shattered-pixel-dungeon.nix {};
shiori = handleTest ./shiori.nix {};
signal-desktop = handleTest ./signal-desktop.nix {};
+14 -10
nixos/tests/shadowsocks.nix nixos/tests/shadowsocks/common.nix
···
-
import ./make-test-python.nix ({ pkgs, lib, ... }: {
-
name = "shadowsocks";
+
{ name
+
, plugin ? null
+
, pluginOpts ? ""
+
}:
+
+
import ../make-test-python.nix ({ pkgs, lib, ... }: {
+
inherit name;
meta = {
maintainers = with lib.maintainers; [ hmenke ];
};
···
port = 8488;
fastOpen = false;
mode = "tcp_and_udp";
-
plugin = "${pkgs.shadowsocks-v2ray-plugin}/bin/v2ray-plugin";
-
pluginOpts = "server;host=nixos.org";
+
} // lib.optionalAttrs (plugin != null) {
+
inherit plugin;
+
pluginOpts = "server;${pluginOpts}";
};
services.nginx = {
enable = true;
···
description = "connect to shadowsocks";
after = [ "network.target" ];
wantedBy = [ "multi-user.target" ];
-
path = with pkgs; [
-
shadowsocks-libev
-
shadowsocks-v2ray-plugin
-
];
+
path = with pkgs; [ shadowsocks-libev ];
script = ''
exec ss-local \
-s 192.168.0.1 \
···
-k 'pa$$w0rd' \
-m chacha20-ietf-poly1305 \
-a nobody \
-
--plugin "${pkgs.shadowsocks-v2ray-plugin}/bin/v2ray-plugin" \
-
--plugin-opts "host=nixos.org"
+
${lib.optionalString (plugin != null) ''
+
--plugin "${plugin}" --plugin-opts "${pluginOpts}"
+
''}
'';
};
};
+16
nixos/tests/shadowsocks/default.nix
···
+
{ system ? builtins.currentSystem
+
, config ? { }
+
, pkgs ? import ../../.. { inherit system config; }
+
}:
+
+
{
+
"basic" = import ./common.nix {
+
name = "basic";
+
};
+
+
"v2ray-plugin" = import ./common.nix {
+
name = "v2ray-plugin";
+
plugin = "${pkgs.shadowsocks-v2ray-plugin}/bin/v2ray-plugin";
+
pluginOpts = "host=nixos.org";
+
};
+
}