Skip to content

Commit

Permalink
1
Browse files Browse the repository at this point in the history
  • Loading branch information
inclyc committed Dec 11, 2023
1 parent d9c26ad commit 533b7d7
Show file tree
Hide file tree
Showing 4 changed files with 217 additions and 26 deletions.
8 changes: 8 additions & 0 deletions nixos/configurations/adrastea/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,9 @@
chromium

libreoffice-qt

bpftools
libbpf
]);

virtualisation.spiceUSBRedirection.enable = true;
Expand Down Expand Up @@ -230,6 +233,11 @@
common = {
TIMELINE_CLEANUP = true;
TIMELINE_CREATE = true;
TIMELINE_LIMIT_HOURLY = "3";
TIMELINE_LIMIT_DAILY = "3";
TIMELINE_LIMIT_WEEKLY = "2";
TIMELINE_LIMIT_MONTHLY = "2";
TIMELINE_LIMIT_YEARLY = "2";
};
mkTimeline = a: a // common;
in
Expand Down
187 changes: 187 additions & 0 deletions nixos/modules/clash/proxy-groups.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,187 @@
[
{
"name": "Domestic",
"type": "select",
"proxies": [
"DIRECT",
"Proxy"
]
},
{
"name": "Others",
"type": "select",
"proxies": [
"Proxy",
"DIRECT"
]
},
{
"name": "AdBlock",
"type": "select",
"proxies": [
"REJECT",
"DIRECT",
"Proxy"
]
},
{
"name": "Anti IP",
"type": "select",
"proxies": [
"DIRECT",
"Proxy"
]
},
{
"name": "Netflix",
"type": "select",
"proxies": [
"Proxy",
"DIRECT"
]
},
{
"name": "Disney",
"type": "select",
"proxies": [
"Proxy",
"DIRECT"
]
},
{
"name": "YouTube",
"type": "select",
"proxies": [
"Proxy",
"DIRECT"
]
},
{
"name": "Spotify",
"type": "select",
"proxies": [
"Proxy",
"DIRECT"
]
},
{
"name": "Asian TV",
"type": "select",
"proxies": [
"DIRECT",
"Proxy"
]
},
{
"name": "Global TV",
"type": "select",
"proxies": [
"Proxy",
"DIRECT"
]
},
{
"name": "Apple",
"type": "select",
"proxies": [
"DIRECT",
"Proxy"
]
},
{
"name": "Apple TV",
"type": "select",
"proxies": [
"Proxy",
"DIRECT"
]
},
{
"name": "Telegram",
"type": "select",
"proxies": [
"Proxy",
"DIRECT"
]
},
{
"name": "Google FCM",
"type": "select",
"proxies": [
"Proxy",
"DIRECT"
]
},
{
"name": "Crypto",
"type": "select",
"proxies": [
"Proxy",
"DIRECT"
]
},
{
"name": "Discord",
"type": "select",
"proxies": [
"Proxy",
"DIRECT"
]
},
{
"name": "Microsoft",
"type": "select",
"proxies": [
"Proxy",
"DIRECT"
]
},
{
"name": "OpenAI",
"type": "select",
"proxies": [
"Proxy",
"DIRECT"
]
},
{
"name": "PayPal",
"type": "select",
"proxies": [
"DIRECT",
"Proxy"
]
},
{
"name": "Scholar",
"type": "select",
"proxies": [
"DIRECT",
"Proxy"
]
},
{
"name": "Speedtest",
"type": "select",
"proxies": [
"Proxy",
"DIRECT"
]
},
{
"name": "Steam",
"type": "select",
"proxies": [
"Proxy",
"DIRECT"
]
},
{
"name": "miHoYo",
"type": "select",
"proxies": [
"DIRECT",
"Proxy"
]
}
]
21 changes: 21 additions & 0 deletions nixos/modules/clash/rule.nix
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,31 @@ let
};

proxyProviders = lib.genAttrs providers mkProvider;

proxyGroups = [
{
name = "Proxy";
type = "select";
use = providers;
proxies = [
"Auto"
"DIRECT"
];
}
{
name = "Auto";
type = "url-test";
use = providers;
proxies = [ "DIRECT" ];
url = "http://cp.cloudflare.com/generate_204";
interval = "3600";
}
] ++ builtins.fromJSON (builtins.readFile ./proxy-groups.json);
in
{
sops.secrets = lib.attrsets.mergeAttrsList (map mkSecret providers);
sops.templates."clash-config.yaml".content = builtins.readFile ./rule.yaml + ''
proxy-groups: ${builtins.toJSON proxyGroups}
proxy-providers: ${builtins.toJSON proxyProviders}
'';

Expand Down
27 changes: 1 addition & 26 deletions nixos/modules/clash/rule.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -115,32 +115,7 @@ dns:
- +.googleapis.com
- +.gvt1.com

proxy-groups:
- { name: Proxy, type: select, proxies: ['Auto - UrlTest', DIRECT] }
- { name: Domestic, type: select, proxies: [DIRECT, Proxy] }
- { name: Others, type: select, proxies: [Proxy, DIRECT] }
- { name: AdBlock, type: select, proxies: [REJECT, DIRECT, Proxy] }
- { name: 'Anti IP', type: select, proxies: [DIRECT, Proxy] }
- { name: Netflix, type: select, proxies: [Proxy, DIRECT] }
- { name: Disney, type: select, proxies: [Proxy, DIRECT] }
- { name: YouTube, type: select, proxies: [Proxy, DIRECT] }
- { name: Spotify, type: select, proxies: [Proxy, DIRECT] }
- { name: 'Asian TV', type: select, proxies: [DIRECT, Proxy] }
- { name: 'Global TV', type: select, proxies: [Proxy, DIRECT] }
- { name: Apple, type: select, proxies: [DIRECT, Proxy] }
- { name: 'Apple TV', type: select, proxies: [Proxy, DIRECT] }
- { name: Telegram, type: select, proxies: [Proxy, DIRECT] }
- { name: 'Google FCM', type: select, proxies: [Proxy, DIRECT] }
- { name: Crypto, type: select, proxies: [Proxy, DIRECT] }
- { name: Discord, type: select, proxies: [Proxy, DIRECT] }
- { name: Microsoft, type: select, proxies: [Proxy, DIRECT] }
- { name: OpenAI, type: select, proxies: [Proxy, DIRECT] }
- { name: PayPal, type: select, proxies: [DIRECT, Proxy] }
- { name: Scholar, type: select, proxies: [DIRECT, Proxy] }
- { name: Speedtest, type: select, proxies: [Proxy, DIRECT] }
- { name: Steam, type: select, proxies: [Proxy, DIRECT] }
- { name: miHoYo, type: select, proxies: [DIRECT, Proxy] }
- { name: 'Auto - UrlTest', type: url-test, use: [ "dler", "mielink", "bywave" ], url: 'http://cp.cloudflare.com/generate_204', interval: '3600' }

rules:
- 'RULE-SET, Reject, AdBlock'
- 'RULE-SET, Special, DIRECT'
Expand Down

0 comments on commit 533b7d7

Please sign in to comment.