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

+11 -1
View File
@@ -30,9 +30,19 @@ in
description = "AWG 3.1 userspace implementation used when the kernel interface is unavailable.";
};
wireproxyPackage = mkOption {
type = types.package;
default = awgPackages.wireproxy;
description = "wireproxy build with AWG 3.1 and FwMark, which runs profiles with asOutbound = \"userspace\".";
};
kernelModulePackage = mkOption {
type = types.nullOr types.package;
default = awgPackages.kernelModule config.boot.kernelPackages;
default =
let
kernelPackages = config.services.proxy-suite.host.kernelPackages;
in
if kernelPackages == null then null else awgPackages.kernelModule kernelPackages;
description = "AWG 3.1 kernel module package. Set null to use userspace-only fallback.";
};
+1
View File
@@ -21,6 +21,7 @@
./tray.nix
./tui.nix
./user-control.nix
./host.nix
];
options.services.proxy-suite.enable = lib.mkEnableOption "proxy-suite";
+74
View File
@@ -0,0 +1,74 @@
# What the host adapter (modules/proxy-suite/hosts/*.nix) tells the core about the
# host, and what the core hands back for the adapter to turn into host settings.
# Nothing here is user-facing.
{ lib, pkgs, ... }:
let
inherit (lib) mkOption types;
unitType = import ./types/unit.nix { inherit lib; };
internalOption =
type: default:
mkOption {
inherit type default;
internal = true;
visible = false;
};
units = internalOption (types.attrsOf unitType) { };
in
{
options.services.proxy-suite.host = {
kind = internalOption (types.enum [
"nixos"
"system-manager"
"home-manager"
"nix-on-droid"
]) "nixos";
# Whether the services run as root and may program routing, firewalls and interfaces.
privileged = internalOption types.bool true;
# Persistent state; units name the proxy-suite subdirectory of their host's state dir.
stateDir = internalOption types.str "/var/lib/proxy-suite";
# Parent of the per-unit runtime directories (proxy-suite-socks, …).
runtimeDir = internalOption types.str "/run";
# Which manager runs the units: proxy-ctl and the control scripts talk to it.
serviceManager = internalOption (types.enum [
"systemd"
"systemd-user"
"supervisor"
]) "systemd";
# The commands that manage the units and show their logs, without a --user of their own.
systemctl = internalOption types.str "${pkgs.systemd}/bin/systemctl";
journalctl = internalOption types.str "journalctl";
# Host facts a few option defaults read.
enableIPv6 = internalOption types.bool true;
kernelPackages = internalOption (types.nullOr types.raw) null;
firewallPackage = internalOption (types.nullOr types.package) null;
resolvconfPackage = internalOption (types.nullOr types.package) null;
};
options.services.proxy-suite.internal = {
# systemd-shaped unit declarations; the adapter installs or converts them.
services = units;
userServices = units;
timers = units;
paths = units;
tmpfiles = internalOption (types.listOf types.str) [ ];
packages = internalOption (types.listOf types.package) [ ];
# Ahead of the host's own packages (zapret's binaries shadow same-named ones).
earlyPackages = internalOption (types.listOf types.package) [ ];
systemUsers = internalOption (types.listOf types.str) [ ];
groups = internalOption (types.listOf types.str) [ ];
polkit = {
enable = internalOption types.bool false;
pkexecWrapper = internalOption types.bool false;
rules = internalOption types.lines "";
};
nftables = internalOption types.bool false;
firewall = {
allowedTCPPorts = internalOption (types.listOf types.port) [ ];
allowedUDPPorts = internalOption (types.listOf types.port) [ ];
extraReversePathFilterRules = internalOption types.lines "";
};
kernelModulePackages = internalOption (types.listOf types.package) [ ];
};
}
+1 -1
View File
@@ -49,7 +49,7 @@ in
ipv6 = mkOption {
type = types.bool;
default = config.networking.enableIPv6;
default = config.services.proxy-suite.host.enableIPv6;
defaultText = literalExpression "config.networking.enableIPv6";
description = ''
Carry IPv6 in the transparent modes: TProxy through a second listener on ::1, the TUNs
@@ -273,6 +273,7 @@ let
type = types.nullOr (
types.enum [
"singBox"
"userspace"
"interface"
]
);
@@ -283,6 +284,11 @@ let
`proxy-ctl awg`. Requires proxy.enable.
- "singBox": a WireGuard endpoint in its own sing-box process, reached as a loopback SOCKS
hop. sing-box speaks plain WireGuard: AmneziaWG obfuscation is dropped with a warning.
- "userspace": the same hop served by wireproxy on AmneziaWG's userspace implementation, so
obfuscation works. It needs no interface or root: the only AmneziaWG mode on
home-manager and nix-on-droid. A declared or profile ListenPort is used as is. An
Endpoint hostname resolves through the system resolver: give an address where that
resolver cannot reach the name.
- "interface": the AmneziaWG interface comes up without routes (Table = off), and the
outbound binds to it, so obfuscation works. With the sing-box backend its DNS goes
through the interface too (proxy.dns.remote); XRay resolves as usual.
@@ -0,0 +1,84 @@
# The subset of NixOS's systemd unit options proxy-suite declares units with, merged
# the same way, so hosts without NixOS's systemd module can read them back.
{ lib }:
let
inherit (lib) mkOption types;
# As nixos/lib/systemd-lib.nix: lists concatenate, anything else must agree.
unitOption = lib.mkOptionType {
name = "systemd option";
merge =
loc: defs:
let
defs' = lib.filterOverrides defs;
in
if lib.any (def: lib.isList def.value) defs' then
lib.concatMap (def: lib.toList def.value) defs'
else
lib.mergeEqualOption loc defs';
};
list = mkOption {
type = types.listOf types.str;
default = [ ];
};
lines = mkOption {
type = types.lines;
default = "";
};
section = mkOption {
type = types.attrsOf unitOption;
default = { };
};
in
types.submodule {
options = {
enable = mkOption {
type = types.bool;
default = true;
};
description = mkOption {
type = types.str;
default = "";
};
after = list;
before = list;
wants = list;
requires = list;
bindsTo = list;
partOf = list;
conflicts = list;
wantedBy = list;
requiredBy = list;
path = mkOption {
type = types.listOf (types.either types.package types.str);
default = [ ];
};
environment = mkOption {
type = types.attrsOf (
types.nullOr (
types.oneOf [
types.str
types.path
types.package
]
)
);
default = { };
};
script = lines;
preStart = lines;
postStart = lines;
preStop = lines;
postStop = lines;
startLimitIntervalSec = mkOption {
type = types.nullOr types.int;
default = null;
};
unitConfig = section;
serviceConfig = section;
timerConfig = section;
pathConfig = section;
};
}
+3
View File
@@ -39,6 +39,7 @@ in
type = types.nullOr (
types.enum [
"singBox"
"userspace"
"interface"
]
);
@@ -49,6 +50,8 @@ in
endpoint on 127.0.0.1:18538, as the proxy-suite-daemon user. The tunnel starts again on a
new source port when WARP does not answer within 15 seconds of a start, or misses three
probes later on, unless the uplink itself is down.
- "userspace": an AmneziaWG profile named "warp" with asOutbound = "userspace", which honours
the AmneziaWG lines of the profile without an interface or root. Requires amneziaWg.enable.
- "interface": an AmneziaWG profile named "warp" with asOutbound = "interface", which honours
the AmneziaWG lines of the profile. Requires amneziaWg.enable.
'';