main
 1{den, ...}: {
 2  den.aspects.services.mihomo.proxies = {
 3    nixos = {config, ...}: let
 4      allHosts = builtins.concatMap builtins.attrValues (builtins.attrValues den.hosts);
 5      hyacine = builtins.head (builtins.filter (h: h.name == "hyacine") allHosts);
 6    in {
 7      services.mihomo = {
 8        config = {
 9          proxy-providers = let
10            providerParam = {
11              type = "http";
12              interval = 86400;
13              health-check = {
14                enable = true;
15                url = "https://cp.cloudflare.com";
16                interval = 300;
17              };
18            };
19          in {
20            mo_jie =
21              providerParam
22              // {
23                url._secret = config.vaultix.secrets.mihomo-providers-mo_jie.path;
24                path = "./proxy_provider/providers-mo_jie.yaml";
25                override.additional-prefix = "[MJ]";
26              };
27            hong_xing =
28              providerParam
29              // {
30                url._secret = config.vaultix.secrets.mihomo-providers-hong_xing.path;
31                path = "./proxy_provider/providers-hong_xing.yaml";
32                override.additional-prefix = "[HX]";
33              };
34          };
35          proxies = [
36            {
37              name = "[Self]${hyacine.location}-Hyacine";
38              type = "vless";
39              server._secret = config.vaultix.secrets.${hyacine.address.ipv4.secret.name}.path;
40              port = 443;
41              uuid._secret = config.vaultix.secrets.hyacine-xray-uuid.path;
42              network = "tcp";
43              udp = true;
44              tls = true;
45              flow = "xtls-rprx-vision";
46              servername._secret = config.vaultix.secrets.hyacine-xray-reality-site.path;
47              client-fingerprint = "chrome";
48              reality-opts = {
49                public-key._secret = config.vaultix.secrets.hyacine-xray-pub-key.path;
50                short-id = "";
51                support-x25519mlkem768 = true; # xray 26.9.9 need this
52              };
53            }
54          ];
55        };
56      };
57
58      vaultix.secrets = {
59        mihomo-providers-mo_jie = {
60          file = ./providers-mo_jie.age;
61          owner = "mihomo";
62          group = "mihomo";
63        };
64        mihomo-providers-hong_xing = {
65          file = ./providers-hong_xing.age;
66          owner = "mihomo";
67          group = "mihomo";
68        };
69
70        hyacine-xray-uuid = {
71          file = hyacine.settings.services.xray.uuidFileAged;
72          owner = "mihomo";
73          group = "mihomo";
74        };
75        hyacine-xray-pub-key = {
76          file = hyacine.settings.services.xray.pubKeyFileAged;
77          owner = "mihomo";
78          group = "mihomo";
79        };
80        hyacine-xray-reality-site = {
81          file = hyacine.settings.services.xray.realitySiteFileAged;
82          owner = "mihomo";
83          group = "mihomo";
84        };
85      };
86    };
87  };
88}