feat: allow using suite on non-nixos systems

This commit is contained in:
FUFSoB committed 2026-09-17 13:27:08 +05:00
1 parent e852bef400
commit 3b568bb54e
63 files changed
+3572 -523

No files matched your search

@@ -25,13 +25,13 @@ lib.optionalString hybridEnabled ''
local batch
batch=$(${jq} -c \
--argjson base "$XRAY_SIDECAR_NEXT_PORT" \
--argjson mark ${toString xraySidecarRoutingMark} '
--argjson mark ${if xraySidecarRoutingMark == null then "null" else toString xraySidecarRoutingMark} '
to_entries | map(
($base + .key) as $port
| ("proxy-suite-xray-" + ($port | tostring)) as $auth
| .value.tag as $tag
| {outbound: (.value
| .streamSettings.sockopt.mark = $mark
${lib.optionalString (xraySidecarRoutingMark != null) "| .streamSettings.sockopt.mark = $mark"}
| .streamSettings.sockopt.domainStrategy = (.streamSettings.sockopt.domainStrategy // "UseIP")),
inbound: {tag: ($tag + "-inbound"), listen: "127.0.0.1", port: $port, protocol: "socks",
settings: {auth: "password", udp: true, accounts: [{user: $auth, pass: $auth}]}},
@@ -160,7 +160,9 @@ let
}
_proxy_suite_parse_xray_url() {
${parse "--backend xray" " --routing-mark ${toString xraySidecarRoutingMark}"}
${parse "--backend xray" (
lib.optionalString (xraySidecarRoutingMark != null) " --routing-mark ${toString xraySidecarRoutingMark}"
)}
}
''
else
@@ -331,7 +333,7 @@ let
# sing-box opens the key as ${constants.serviceUser}, which cannot read a key in a
# home directory: it gets a copy only root and its group can read.
SSH_IDENTITY="$RUNTIME_DIR/ssh-identity"
install -m 0640 -g ${constants.serviceUser} ${lib.escapeShellArg sshProxyCfg.identityFile} "$SSH_IDENTITY"
install -m 0640 ${constants.ifPrivileged "-g ${constants.serviceUser} "}${lib.escapeShellArg sshProxyCfg.identityFile} "$SSH_IDENTITY"
OB_JSON=$(${jq} --arg key "$SSH_IDENTITY" '.private_key_path = $key' <<< "$OB_JSON")
''}
${hostKeyFileBlock}
@@ -357,7 +359,7 @@ let
_proxy_suite_record_tag_source ${lib.escapeShellArg outbound.tag} ${source}
'';
# WARP and "singBox" AmneziaWG profiles run in a tunnel unit, which restarts them when the
# WARP and "singBox" or "userspace" AmneziaWG profiles run in a tunnel unit, which restarts them when the
# handshake stops being answered. Every backend reaches it as a loopback SOCKS hop.
mkTunnelOutboundBlock =
unit: source: tag: port:
@@ -10,6 +10,7 @@
hybridEnabled,
mainBackend,
backend,
stateDir,
runtimeSubscriptionsDir,
jq,
python3,
@@ -21,7 +22,7 @@
let
subscriptionBackend = if hybridEnabled then "hybrid" else mainBackend;
subscriptionBackendArg = "--backend ${subscriptionBackend}";
subscriptionCacheDir = "/var/lib/proxy-suite/subscriptions/${backend}";
subscriptionCacheDir = "${stateDir}/subscriptions/${backend}";
mkSubscriptionUrlSource =
sub: