From 533b7d751253080e7260dd82bcfe94f28dcfcccd Mon Sep 17 00:00:00 2001 From: Yingchi Long Date: Mon, 11 Dec 2023 15:28:16 +0800 Subject: [PATCH] 1 --- nixos/configurations/adrastea/default.nix | 8 + nixos/modules/clash/proxy-groups.json | 187 ++++++++++++++++++++++ nixos/modules/clash/rule.nix | 21 +++ nixos/modules/clash/rule.yaml | 27 +--- 4 files changed, 217 insertions(+), 26 deletions(-) create mode 100644 nixos/modules/clash/proxy-groups.json diff --git a/nixos/configurations/adrastea/default.nix b/nixos/configurations/adrastea/default.nix index 3eee3e0..37fc819 100644 --- a/nixos/configurations/adrastea/default.nix +++ b/nixos/configurations/adrastea/default.nix @@ -84,6 +84,9 @@ chromium libreoffice-qt + + bpftools + libbpf ]); virtualisation.spiceUSBRedirection.enable = true; @@ -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 diff --git a/nixos/modules/clash/proxy-groups.json b/nixos/modules/clash/proxy-groups.json new file mode 100644 index 0000000..3b0f3c4 --- /dev/null +++ b/nixos/modules/clash/proxy-groups.json @@ -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" + ] + } +] diff --git a/nixos/modules/clash/rule.nix b/nixos/modules/clash/rule.nix index 2fd08fc..3087754 100644 --- a/nixos/modules/clash/rule.nix +++ b/nixos/modules/clash/rule.nix @@ -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} ''; diff --git a/nixos/modules/clash/rule.yaml b/nixos/modules/clash/rule.yaml index 38d7078..eb85047 100644 --- a/nixos/modules/clash/rule.yaml +++ b/nixos/modules/clash/rule.yaml @@ -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'