1
0
Fork 0
mirror of https://github.com/NixOS/nixpkgs.git synced 2025-06-21 08:59:20 +03:00

Merge pull request #287966 from Guanran928/clash-meta

nixos/mihomo: init
This commit is contained in:
Doron Behar 2024-03-21 10:40:10 +02:00 committed by GitHub
commit 2897be360b
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
6 changed files with 172 additions and 0 deletions

View file

@ -529,6 +529,7 @@ in {
memcached = handleTest ./memcached.nix {};
merecat = handleTest ./merecat.nix {};
metabase = handleTest ./metabase.nix {};
mihomo = handleTest ./mihomo.nix {};
mindustry = handleTest ./mindustry.nix {};
minecraft = handleTest ./minecraft.nix {};
minecraft-server = handleTest ./minecraft-server.nix {};

44
nixos/tests/mihomo.nix Normal file
View file

@ -0,0 +1,44 @@
import ./make-test-python.nix ({ pkgs, ... }: {
name = "mihomo";
meta.maintainers = with pkgs.lib.maintainers; [ Guanran928 ];
nodes.machine = {
environment.systemPackages = [ pkgs.curl ];
services.nginx = {
enable = true;
statusPage = true;
};
services.mihomo = {
enable = true;
configFile = pkgs.writeTextFile {
name = "config.yaml";
text = ''
mixed-port: 7890
external-controller: 127.0.0.1:9090
authentication:
- "user:supersecret"
'';
};
};
};
testScript = ''
# Wait until it starts
machine.wait_for_unit("nginx.service")
machine.wait_for_unit("mihomo.service")
machine.wait_for_open_port(80)
machine.wait_for_open_port(7890)
machine.wait_for_open_port(9090)
# Proxy
machine.succeed("curl --fail --max-time 10 --proxy http://user:supersecret@localhost:7890 http://localhost")
machine.succeed("curl --fail --max-time 10 --proxy socks5://user:supersecret@localhost:7890 http://localhost")
machine.fail("curl --fail --max-time 10 --proxy http://user:supervillain@localhost:7890 http://localhost")
machine.fail("curl --fail --max-time 10 --proxy socks5://user:supervillain@localhost:7890 http://localhost")
# Web UI
machine.succeed("curl --fail http://localhost:9090") == '{"hello":"clash"}'
'';
})