diff --git a/docs/quick_start_guide.md b/docs/quick_start_guide.md index ace06216..ef3671b2 100644 --- a/docs/quick_start_guide.md +++ b/docs/quick_start_guide.md @@ -12,15 +12,18 @@ This guide will help you quickly set up a Lightway VPN server and client using t ### Server Requirements -- Linux system (x86_64, arm64, or riscv64) -- Root or sudo access -- The following packages: - - `jq`, `yq` (for parsing server and client config.yaml files) - - `apache2-utils` (htpasswd for user authentication) - - `iproute2` - - `iptables` - -Install dependencies on Debian/Ubuntu: +- Nix user + - use quick start shell + - `nix develop github:expressvpn/lightway#quick-start` +- None Nix user + - Linux system (x86_64, arm64, or riscv64) + - Root or sudo access + - The following packages: + - `jq`, `yq` (for parsing server and client config.yaml files) + - `apache2-utils` (htpasswd for user authentication) + - `iproute2` + - `iptables` + - Install dependencies on Debian/Ubuntu: ```bash sudo apt-get update sudo apt-get install jq yq apache2-utils iproutes2 iptables @@ -45,7 +48,11 @@ chmod +x lightway-server ``` ### 2. Download the Setup Script +- Nix user + - The script is also included in the quick-start shell, you do not need to download it. +- None Nix user + - Download latest script from repository ```bash curl -L -o server_start.sh https://raw.githubusercontent.com/expressvpn/lightway/main/samples/server_start.sh chmod +x server_start.sh @@ -104,6 +111,12 @@ Edit the config to update the database (`user_db`) and certificate paths (`serve Use the provided setup script to start the server: +- Nix user +```bash +sudo server_start server_config.yaml +``` + +- None Nix user ```bash sudo ./server_start.sh server_config.yaml ``` @@ -151,6 +164,12 @@ Edit the config to update `server`, `ca_cert`, `user`, and `password` fields. Run the client to establish a VPN connection to the server: +- Nix user +```bash +sudo nix run github:expressvpn/lightway#lightway-client -- --config-file client_config.yaml +``` + +- None Nix user ```bash sudo ./lightway-client --config-file client_config.yaml ``` diff --git a/flake.nix b/flake.nix index e4305ffc..002f381d 100644 --- a/flake.nix +++ b/flake.nix @@ -80,8 +80,9 @@ }; clientFeatures = [ ] ++ lib.optional pkgs.stdenv.isLinux [ "io-uring" ]; serverFeatures = [ ] ++ lib.optional pkgs.stdenv.isLinux [ "io-uring" ]; + serverStartScript = pkgs.writeShellScriptBin "server_start" (builtins.readFile ./samples/server_start.sh); in - { + rec { _module.args.pkgs = import inputs.nixpkgs { inherit system; overlays = [ inputs.rust-overlay.overlays.default ]; @@ -98,6 +99,23 @@ devShells.stable = mkDevShell pkgs.rust-bin.stable.latest.default; devShells.nightly = mkDevShell pkgs.rust-bin.nightly.latest.default; devShells.msrv = mkDevShell pkgs.rust-bin.stable.${msrv}.default; + devShells.quick-start = pkgs.mkShell { + shellHook = '' + export RUST_SRC_PATH=${pkgs.rustPlatform.rustLibSrc} + ''; + buildInputs = runtimeDeps; + nativeBuildInputs = buildDeps ++ devDeps ++ (with pkgs; [ + apacheHttpd + iproute2 + iptables + jq + openssl + yq + ]) ++ [ + packages.lightway-server + serverStartScript + ]; + }; formatter = pkgs.nixfmt-rfc-style; }; diff --git a/samples/server_start.sh b/samples/server_start.sh index 459c2107..b5d4ed14 100755 --- a/samples/server_start.sh +++ b/samples/server_start.sh @@ -38,7 +38,7 @@ check_dependencies() { exit 1 fi - if [[ ! -f "./lightway-server" ]]; then + if [[ ! -f "./lightway-server" ]] && [[ ! -x "$(command -v lightway-server)" ]]; then echo "Error: lightway-server binary not found in current directory" >&2 exit 1 fi @@ -117,5 +117,5 @@ iptables -P OUTPUT ACCEPT iptables -P FORWARD ACCEPT iptables -t nat -A POSTROUTING -s "${tun_ip_subnet}" -o "${wandev}" -j SNAT --to "${basenet}" -./lightway-server -c "${VPN_SERVER_CONFIG}" "${EXTRA_ARGS[@]}" - +./lightway-server -c "${VPN_SERVER_CONFIG}" "${EXTRA_ARGS[@]}" || + lightway-server -c "${VPN_SERVER_CONFIG}" "${EXTRA_ARGS[@]}"