Skip to content

Commit

Permalink
nixos/shadowsocks: add test without plugin
Browse files Browse the repository at this point in the history
  • Loading branch information
hmenke authored and bennofs committed Sep 14, 2020
1 parent e587b5a commit 9d60354
Show file tree
Hide file tree
Showing 4 changed files with 32 additions and 12 deletions.
2 changes: 1 addition & 1 deletion nixos/modules/services/networking/shadowsocks.nix
Expand Up @@ -147,7 +147,7 @@ in
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) ''
Expand Down
2 changes: 1 addition & 1 deletion nixos/tests/all-tests.nix
Expand Up @@ -309,7 +309,7 @@ in
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 {};
Expand Down
24 changes: 14 additions & 10 deletions nixos/tests/shadowsocks.nix → nixos/tests/shadowsocks/common.nix
@@ -1,5 +1,10 @@
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 ];
};
Expand All @@ -22,8 +27,9 @@ import ./make-test-python.nix ({ pkgs, lib, ... }: {
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;
Expand All @@ -42,10 +48,7 @@ import ./make-test-python.nix ({ pkgs, lib, ... }: {
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 \
Expand All @@ -54,8 +57,9 @@ import ./make-test-python.nix ({ pkgs, lib, ... }: {
-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}"
''}
'';
};
};
Expand Down
16 changes: 16 additions & 0 deletions nixos/tests/shadowsocks/default.nix
@@ -0,0 +1,16 @@
{ 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";
};
}

0 comments on commit 9d60354

Please sign in to comment.