packages improvement
This commit is contained in:
11 files changed
+227
-98
No files matched your search
@@ -11,6 +11,7 @@
|
||||
|
||||
let
|
||||
cfg = config.services.proxy-suite;
|
||||
packages = import ../../pkgs/default.nix { inherit pkgs; };
|
||||
nftr = import ./nftables.nix { inherit lib pkgs cfg; };
|
||||
in
|
||||
{
|
||||
@@ -43,6 +44,7 @@ in
|
||||
config
|
||||
lib
|
||||
pkgs
|
||||
packages
|
||||
cfg
|
||||
;
|
||||
inherit (configs) tproxyFile tunFile perAppTunFile;
|
||||
@@ -61,7 +63,11 @@ in
|
||||
}
|
||||
))
|
||||
|
||||
(lib.mkIf cfg.tgWsProxy.enable (import ./tg-ws-proxy.nix { inherit lib pkgs cfg; }))
|
||||
(lib.mkIf cfg.tgWsProxy.enable (
|
||||
import ./tg-ws-proxy.nix {
|
||||
inherit lib pkgs packages cfg;
|
||||
}
|
||||
))
|
||||
|
||||
(lib.mkIf cfg.tray.enable (
|
||||
import ./tray.nix {
|
||||
@@ -69,6 +75,7 @@ in
|
||||
config
|
||||
lib
|
||||
pkgs
|
||||
packages
|
||||
cfg
|
||||
;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,98 @@
|
||||
# Shared service-layer assembly used by runtime module and docs generation.
|
||||
{
|
||||
lib,
|
||||
pkgs,
|
||||
packages,
|
||||
cfg,
|
||||
tproxyFile,
|
||||
tunFile,
|
||||
perAppTunFile,
|
||||
perAppTunChainFile,
|
||||
perAppTproxyRulesFile,
|
||||
perAppZapretRulesFile,
|
||||
ip,
|
||||
nft,
|
||||
}:
|
||||
|
||||
let
|
||||
singBoxCfg = cfg.singBox;
|
||||
perAppRoutingCfg = cfg.perAppRouting;
|
||||
globalTun = singBoxCfg.tun;
|
||||
globalTproxy = singBoxCfg.tproxy;
|
||||
perAppRoutingTun = singBoxCfg.tun.perApp;
|
||||
perAppRoutingTproxy = singBoxCfg.tproxy.perApp;
|
||||
perAppZapretCfg = cfg.zapret.perApp;
|
||||
userControlCfg = cfg.userControl;
|
||||
|
||||
builtinTags = [ "proxy" "direct" "block" ];
|
||||
outboundTags = map (ob: ob.tag) singBoxCfg.outbounds;
|
||||
invalidRoutingTargets = lib.unique (
|
||||
map (rule: rule.outbound) (
|
||||
builtins.filter (rule: !builtins.elem rule.outbound (builtinTags ++ outboundTags)) singBoxCfg.routing.rules
|
||||
)
|
||||
);
|
||||
|
||||
# Tool paths – defined once here and passed into sub-modules as needed.
|
||||
jq = "${pkgs.jq}/bin/jq";
|
||||
python3 = "${pkgs.python3}/bin/python3";
|
||||
singBox = "${pkgs.sing-box}/bin/sing-box";
|
||||
grepBin = "${pkgs.gnugrep}/bin/grep";
|
||||
awk = "${pkgs.gawk}/bin/awk";
|
||||
sleepBin = "${pkgs.coreutils}/bin/sleep";
|
||||
headBin = "${pkgs.coreutils}/bin/head";
|
||||
seqBin = "${pkgs.coreutils}/bin/seq";
|
||||
findBin = "${pkgs.findutils}/bin/find";
|
||||
|
||||
proxySuiteScriptsDir = ../../../scripts;
|
||||
parserScriptsPythonPath = proxySuiteScriptsDir;
|
||||
buildOutboundPy = "${proxySuiteScriptsDir}/build-outbound.py";
|
||||
fetchSubscriptionPy = "${proxySuiteScriptsDir}/fetch-subscription.py";
|
||||
|
||||
polkit = import ./polkit.nix {
|
||||
inherit lib cfg userControlCfg;
|
||||
};
|
||||
|
||||
scripts = import ./scripts.nix {
|
||||
inherit lib pkgs singBoxCfg perAppRoutingTun;
|
||||
inherit jq python3 singBox parserScriptsPythonPath buildOutboundPy fetchSubscriptionPy;
|
||||
inherit tproxyFile tunFile perAppTunFile;
|
||||
};
|
||||
|
||||
perAppRouting = import ./per-app-routing.nix {
|
||||
inherit lib pkgs cfg singBoxCfg perAppRoutingCfg perAppRoutingTun perAppRoutingTproxy;
|
||||
perAppZapretCfg = perAppZapretCfg;
|
||||
inherit perAppTunChainFile perAppTproxyRulesFile perAppZapretRulesFile;
|
||||
inherit ip nft;
|
||||
inherit awk grepBin findBin headBin seqBin sleepBin;
|
||||
};
|
||||
|
||||
control = import ./control.nix {
|
||||
inherit packages singBoxCfg perAppRoutingCfg perAppRoutingTun perAppRoutingTproxy perAppZapretCfg;
|
||||
zapretEnabled = cfg.zapret.enable;
|
||||
inherit (scripts) subscriptionTagsList;
|
||||
inherit (perAppRouting)
|
||||
perAppRoutingProfilesFile
|
||||
proxychainsConfigFile
|
||||
proxychainsQuietArg
|
||||
;
|
||||
};
|
||||
in
|
||||
{
|
||||
inherit
|
||||
singBoxCfg
|
||||
perAppRoutingCfg
|
||||
globalTun
|
||||
globalTproxy
|
||||
perAppRoutingTun
|
||||
perAppRoutingTproxy
|
||||
perAppZapretCfg
|
||||
userControlCfg
|
||||
builtinTags
|
||||
outboundTags
|
||||
invalidRoutingTargets
|
||||
polkit
|
||||
scripts
|
||||
perAppRouting
|
||||
control
|
||||
;
|
||||
}
|
||||
@@ -1,7 +1,6 @@
|
||||
# Builds proxy-ctl from global proxy-suite state and per-app routing metadata.
|
||||
{
|
||||
lib,
|
||||
pkgs,
|
||||
packages,
|
||||
singBoxCfg,
|
||||
perAppRoutingCfg,
|
||||
perAppRoutingTun,
|
||||
@@ -13,14 +12,8 @@
|
||||
proxychainsConfigFile,
|
||||
proxychainsQuietArg,
|
||||
}:
|
||||
|
||||
let
|
||||
mkProxyCtl = import ../../../pkgs/proxy-ctl.nix {
|
||||
inherit lib pkgs;
|
||||
};
|
||||
in
|
||||
{
|
||||
proxyCtl = mkProxyCtl {
|
||||
proxyCtl = packages.mkProxyCtl {
|
||||
clashApi = "http://127.0.0.1:${toString singBoxCfg.clashApiPort}";
|
||||
selection = singBoxCfg.selection;
|
||||
inherit
|
||||
|
||||
@@ -3,6 +3,7 @@
|
||||
config,
|
||||
lib,
|
||||
pkgs,
|
||||
packages,
|
||||
cfg,
|
||||
tproxyFile,
|
||||
tunFile,
|
||||
@@ -16,67 +17,40 @@
|
||||
}:
|
||||
|
||||
let
|
||||
singBoxCfg = cfg.singBox;
|
||||
perAppRoutingCfg = cfg.perAppRouting;
|
||||
globalTun = singBoxCfg.tun;
|
||||
globalTproxy = singBoxCfg.tproxy;
|
||||
perAppRoutingTun = singBoxCfg.tun.perApp;
|
||||
perAppRoutingTproxy = singBoxCfg.tproxy.perApp;
|
||||
perAppZapretCfg = cfg.zapret.perApp;
|
||||
userControlCfg = cfg.userControl;
|
||||
|
||||
builtinTags = [ "proxy" "direct" "block" ];
|
||||
outboundTags = map (ob: ob.tag) singBoxCfg.outbounds;
|
||||
invalidRoutingTargets = lib.unique (
|
||||
map (rule: rule.outbound) (
|
||||
builtins.filter (rule: !builtins.elem rule.outbound (builtinTags ++ outboundTags)) singBoxCfg.routing.rules
|
||||
)
|
||||
);
|
||||
|
||||
# Tool paths – defined once here and passed into sub-modules as needed.
|
||||
jq = "${pkgs.jq}/bin/jq";
|
||||
python3 = "${pkgs.python3}/bin/python3";
|
||||
singBox = "${pkgs.sing-box}/bin/sing-box";
|
||||
grepBin = "${pkgs.gnugrep}/bin/grep";
|
||||
awk = "${pkgs.gawk}/bin/awk";
|
||||
sleepBin = "${pkgs.coreutils}/bin/sleep";
|
||||
headBin = "${pkgs.coreutils}/bin/head";
|
||||
seqBin = "${pkgs.coreutils}/bin/seq";
|
||||
findBin = "${pkgs.findutils}/bin/find";
|
||||
|
||||
proxySuiteScriptsDir = ../../../scripts;
|
||||
parserScriptsPythonPath = proxySuiteScriptsDir;
|
||||
buildOutboundPy = "${proxySuiteScriptsDir}/build-outbound.py";
|
||||
fetchSubscriptionPy = "${proxySuiteScriptsDir}/fetch-subscription.py";
|
||||
|
||||
polkit = import ./polkit.nix {
|
||||
inherit lib cfg userControlCfg;
|
||||
};
|
||||
|
||||
scripts = import ./scripts.nix {
|
||||
inherit lib pkgs singBoxCfg perAppRoutingTun;
|
||||
inherit jq python3 singBox parserScriptsPythonPath buildOutboundPy fetchSubscriptionPy;
|
||||
inherit tproxyFile tunFile perAppTunFile;
|
||||
};
|
||||
|
||||
perAppRouting = import ./per-app-routing.nix {
|
||||
inherit lib pkgs cfg singBoxCfg perAppRoutingCfg perAppRoutingTun perAppRoutingTproxy;
|
||||
perAppZapretCfg = perAppZapretCfg;
|
||||
inherit perAppTunChainFile perAppTproxyRulesFile perAppZapretRulesFile;
|
||||
inherit ip nft;
|
||||
inherit awk grepBin findBin headBin seqBin sleepBin;
|
||||
};
|
||||
|
||||
control = import ./control.nix {
|
||||
inherit lib pkgs singBoxCfg perAppRoutingCfg perAppRoutingTun perAppRoutingTproxy perAppZapretCfg;
|
||||
zapretEnabled = cfg.zapret.enable;
|
||||
inherit (scripts) subscriptionTagsList;
|
||||
inherit (perAppRouting)
|
||||
perAppRoutingProfilesFile
|
||||
proxychainsConfigFile
|
||||
proxychainsQuietArg
|
||||
context = import ./context.nix {
|
||||
inherit
|
||||
lib
|
||||
pkgs
|
||||
packages
|
||||
cfg
|
||||
tproxyFile
|
||||
tunFile
|
||||
perAppTunFile
|
||||
perAppTunChainFile
|
||||
perAppTproxyRulesFile
|
||||
perAppZapretRulesFile
|
||||
ip
|
||||
nft
|
||||
;
|
||||
};
|
||||
|
||||
inherit (context)
|
||||
singBoxCfg
|
||||
perAppRoutingCfg
|
||||
globalTun
|
||||
globalTproxy
|
||||
perAppRoutingTun
|
||||
perAppRoutingTproxy
|
||||
perAppZapretCfg
|
||||
userControlCfg
|
||||
builtinTags
|
||||
outboundTags
|
||||
invalidRoutingTargets
|
||||
polkit
|
||||
scripts
|
||||
perAppRouting
|
||||
control
|
||||
;
|
||||
in
|
||||
{
|
||||
environment.systemPackages = [ control.proxyCtl ];
|
||||
|
||||
@@ -2,12 +2,13 @@
|
||||
{
|
||||
lib,
|
||||
pkgs,
|
||||
packages,
|
||||
cfg,
|
||||
}:
|
||||
|
||||
let
|
||||
t = cfg.tgWsProxy;
|
||||
tgPkg = import ../../pkgs/tg-ws-proxy.nix { inherit pkgs; };
|
||||
tgPkg = packages.tg-ws-proxy;
|
||||
|
||||
dcArgs = lib.concatMapStrings (id: " --dc-ip=${id}:${t.dcIps.${id}}") (builtins.attrNames t.dcIps);
|
||||
startScript = pkgs.writeShellScript "proxy-suite-tg-ws-proxy-start" ''
|
||||
|
||||
@@ -3,14 +3,14 @@
|
||||
config,
|
||||
lib,
|
||||
pkgs,
|
||||
packages,
|
||||
cfg,
|
||||
}:
|
||||
|
||||
let
|
||||
tray = cfg.tray;
|
||||
|
||||
proxyTray = import ../../pkgs/proxy-suite-tray.nix {
|
||||
inherit pkgs;
|
||||
proxyTray = packages.mkProxySuiteTray {
|
||||
pollInterval = tray.pollInterval;
|
||||
};
|
||||
|
||||
|
||||
Reference in new issue
Block a user