lol

nixos/shadowsocks: add test without plugin

authored by

Henri Menke and committed by
Benno Fünfstück
9d60354f e587b5a8

+32 -12
+1 -1
nixos/modules/services/networking/shadowsocks.nix
··· 147 147 description = "shadowsocks-libev Daemon"; 148 148 after = [ "network.target" ]; 149 149 wantedBy = [ "multi-user.target" ]; 150 - path = [ pkgs.shadowsocks-libev cfg.plugin ] ++ optional (cfg.passwordFile != null) pkgs.jq; 150 + path = [ pkgs.shadowsocks-libev ] ++ optional (cfg.plugin != null) cfg.plugin ++ optional (cfg.passwordFile != null) pkgs.jq; 151 151 serviceConfig.PrivateTmp = true; 152 152 script = '' 153 153 ${optionalString (cfg.passwordFile != null) ''
+1 -1
nixos/tests/all-tests.nix
··· 309 309 sanoid = handleTest ./sanoid.nix {}; 310 310 sddm = handleTest ./sddm.nix {}; 311 311 service-runner = handleTest ./service-runner.nix {}; 312 - shadowsocks = handleTest ./shadowsocks.nix {}; 312 + shadowsocks = handleTest ./shadowsocks {}; 313 313 shattered-pixel-dungeon = handleTest ./shattered-pixel-dungeon.nix {}; 314 314 shiori = handleTest ./shiori.nix {}; 315 315 signal-desktop = handleTest ./signal-desktop.nix {};
+14 -10
nixos/tests/shadowsocks.nix nixos/tests/shadowsocks/common.nix
··· 1 - import ./make-test-python.nix ({ pkgs, lib, ... }: { 2 - name = "shadowsocks"; 1 + { name 2 + , plugin ? null 3 + , pluginOpts ? "" 4 + }: 5 + 6 + import ../make-test-python.nix ({ pkgs, lib, ... }: { 7 + inherit name; 3 8 meta = { 4 9 maintainers = with lib.maintainers; [ hmenke ]; 5 10 }; ··· 22 27 port = 8488; 23 28 fastOpen = false; 24 29 mode = "tcp_and_udp"; 25 - plugin = "${pkgs.shadowsocks-v2ray-plugin}/bin/v2ray-plugin"; 26 - pluginOpts = "server;host=nixos.org"; 30 + } // lib.optionalAttrs (plugin != null) { 31 + inherit plugin; 32 + pluginOpts = "server;${pluginOpts}"; 27 33 }; 28 34 services.nginx = { 29 35 enable = true; ··· 42 48 description = "connect to shadowsocks"; 43 49 after = [ "network.target" ]; 44 50 wantedBy = [ "multi-user.target" ]; 45 - path = with pkgs; [ 46 - shadowsocks-libev 47 - shadowsocks-v2ray-plugin 48 - ]; 51 + path = with pkgs; [ shadowsocks-libev ]; 49 52 script = '' 50 53 exec ss-local \ 51 54 -s 192.168.0.1 \ ··· 54 57 -k 'pa$$w0rd' \ 55 58 -m chacha20-ietf-poly1305 \ 56 59 -a nobody \ 57 - --plugin "${pkgs.shadowsocks-v2ray-plugin}/bin/v2ray-plugin" \ 58 - --plugin-opts "host=nixos.org" 60 + ${lib.optionalString (plugin != null) '' 61 + --plugin "${plugin}" --plugin-opts "${pluginOpts}" 62 + ''} 59 63 ''; 60 64 }; 61 65 };
+16
nixos/tests/shadowsocks/default.nix
··· 1 + { system ? builtins.currentSystem 2 + , config ? { } 3 + , pkgs ? import ../../.. { inherit system config; } 4 + }: 5 + 6 + { 7 + "basic" = import ./common.nix { 8 + name = "basic"; 9 + }; 10 + 11 + "v2ray-plugin" = import ./common.nix { 12 + name = "v2ray-plugin"; 13 + plugin = "${pkgs.shadowsocks-v2ray-plugin}/bin/v2ray-plugin"; 14 + pluginOpts = "host=nixos.org"; 15 + }; 16 + }