{ description = "NixOS proxy suite - SingBox, XRay, AmneziaWG 3.1, zapret, tg-ws-proxy, Tor"; inputs = { nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable"; zapret = { url = "github:kartavkun/zapret-discord-youtube"; inputs.nixpkgs.follows = "nixpkgs"; }; nfqws2-keenetic = { url = "github:nfqws/nfqws2-keenetic"; flake = false; }; z2k = { url = "github:necronicle/z2k/z2k-enhanced"; flake = false; }; disko = { url = "github:nix-community/disko"; inputs.nixpkgs.follows = "nixpkgs"; }; }; outputs = { self, nixpkgs, zapret, nfqws2-keenetic, z2k, disko, }: let systems = [ "x86_64-linux" "aarch64-linux" ]; forAll = nixpkgs.lib.genAttrs systems; pkgsFor = system: import nixpkgs { inherit system; }; proxySuiteModules = import ./modules/proxy-suite { inherit zapret nixpkgs nfqws2-keenetic z2k ; }; proxySuiteModule = proxySuiteModules.nixos; mkOptionsDoc = import ./nix/options-doc.nix { inherit nixpkgs pkgsFor proxySuiteModule; }; mkReadmeDoc = import ./nix/readme-doc.nix { inherit nixpkgs pkgsFor proxySuiteModule zapret ; }; in { # Main module – bakes in the zapret flake so consumers don't need it as a separate input. nixosModules.default = proxySuiteModule; # A single-user VPS: VLESS REALITY, TLS and WS inbounds, ACME and SSH. Includes default. nixosModules.server = import ./deploy/server-module.nix { inherit proxySuiteModule; diskoModule = disko.nixosModules.disko; }; # Rootless, in the user's systemd manager: the local proxy, inbounds on ports from 1024 # up, and what else needs no root. homeManagerModules.default = proxySuiteModules.homeManager; # For numtide/system-manager on other distributions: everything NixOS has, with the # firewall and kernel modules left to the host. systemManagerModules.default = proxySuiteModules.systemManager; # nix-on-droid, where proxy-suitectl supervises the services: what home-manager gets, # without the GUI. nixOnDroidModules.default = proxySuiteModules.nixOnDroid; # Proxy variables and wrapEnv from an address alone: for a proxy this config does not # run, or on system-manager and nix-on-droid, which have no config.lib. # `proxy-suite.lib.proxyHelpers { inherit pkgs; port = 1080; }`. On NixOS and # home-manager the module has the full set as config.lib.proxy-suite. lib.proxyHelpers = args: import ./modules/proxy-suite/helpers.nix ( { inherit (args.pkgs) lib; } // args ); # Re-export zapret standalone for users who want just that. nixosModules.zapret = zapret.nixosModules.default; overlays.default = final: prev: { # From prev: these override the nixpkgs packages of the same name. inherit (import ./pkgs/default.nix { pkgs = prev; }) amneziawg-tools amneziawg-go ; inherit (import ./pkgs/default.nix { pkgs = final; }) mkProxyCtl mkTgWsProxy tg-ws-proxy whitelist-bypass wireproxy-awg zapret2 ; # Replaced by Proxy Suite GUI, which mkProxyCtl builds as `.gui`. proxy-suite-tray = throw "proxy-suite-tray was replaced by Proxy Suite GUI: set services.proxy-suite.gui.enable"; mkProxySuiteTray = throw "mkProxySuiteTray was replaced by Proxy Suite GUI: set services.proxy-suite.gui.enable"; }; # `nix fmt`; the nix-format check holds the tree to it. The usage snippets are # generated, and the usage-docs check wants them as their Markdown has them. formatter = forAll ( system: (pkgsFor system).nixfmt-tree.override { settings.global.excludes = [ "docs/usage/.snippets/*" ]; } ); packages = forAll ( system: let pkgs = pkgsFor system; suitePkgs = import ./pkgs/default.nix { inherit pkgs; }; updateDocs = pkgs.writeShellApplication { name = "update-docs"; runtimeInputs = [ pkgs.coreutils pkgs.git pkgs.nix ]; text = builtins.readFile ./nix/update-docs.sh; }; in { inherit (suitePkgs) amneziawg-tools amneziawg-go tg-ws-proxy whitelist-bypass wireproxy-awg zapret2 ; xray = import ./pkgs/xray.nix { inherit pkgs; }; # Console installer for a proxy-suite VPS (deploy/iso.nix). installer-iso = (nixpkgs.lib.nixosSystem { modules = [ (import ./deploy/iso.nix { inherit self; serverModule = self.nixosModules.server; }) { nixpkgs.hostPlatform = system; } ]; }).config.system.build.installerIso; optionsDoc = mkOptionsDoc system; usageSnippets = pkgs.runCommand "proxy-suite-usage-snippets" { } ( '' mkdir "$out" '' + pkgs.lib.concatMapStrings (snippet: '' cp ${pkgs.writeText snippet.file snippet.text} "$out"/${snippet.file} '') (import ./nix/usage-snippets.nix { inherit (pkgs) lib; }).snippets ); readmeDoc = mkReadmeDoc system; update-docs = updateDocs; update-options-doc = pkgs.writeShellApplication { name = "update-options-doc"; runtimeInputs = [ updateDocs ]; text = '' exec ${updateDocs}/bin/update-docs "$@" ''; }; } ); apps = forAll (system: { update-docs = { type = "app"; program = "${self.packages.${system}.update-docs}/bin/update-docs"; meta.description = "Update generated docs and README help from current NixOS module outputs"; }; update-options-doc = { type = "app"; program = "${self.packages.${system}.update-options-doc}/bin/update-options-doc"; meta.description = "Compatibility alias for update-docs"; }; }); checks = forAll ( system: import ./nix/checks.nix { inherit system nixpkgs proxySuiteModule proxySuiteModules zapret ; serverModule = self.nixosModules.server; generatedOptionsDoc = mkOptionsDoc system; generatedReadmeDoc = mkReadmeDoc system; } ); }; }