From 7fb4d1f85e27666395edc10125520358375cf2fe Mon Sep 17 00:00:00 2001 From: sund3RRR Date: Tue, 24 Dec 2024 20:18:32 +0300 Subject: [PATCH] amneziaVPN: init at 4.8.2.3; nixos/programs/amneziaVPN: init --- nixos/modules/module-list.nix | 1 + nixos/modules/programs/amneziaVPN.nix | 37 ++++++++++ pkgs/by-name/am/amneziaVPN/package.nix | 94 ++++++++++++++++++++++++++ 3 files changed, 132 insertions(+) create mode 100644 nixos/modules/programs/amneziaVPN.nix create mode 100644 pkgs/by-name/am/amneziaVPN/package.nix diff --git a/nixos/modules/module-list.nix b/nixos/modules/module-list.nix index 9fe8e3be6477d..7162f51c69467 100644 --- a/nixos/modules/module-list.nix +++ b/nixos/modules/module-list.nix @@ -149,6 +149,7 @@ ./programs/_1password.nix ./programs/adb.nix ./programs/alvr.nix + ./programs/amneziaVPN.nix ./programs/appgate-sdp.nix ./programs/appimage.nix ./programs/arp-scan.nix diff --git a/nixos/modules/programs/amneziaVPN.nix b/nixos/modules/programs/amneziaVPN.nix new file mode 100644 index 0000000000000..c97c0dcb522b3 --- /dev/null +++ b/nixos/modules/programs/amneziaVPN.nix @@ -0,0 +1,37 @@ +{ + config, + lib, + pkgs, + ... +}: +let + cfg = config.programs.amneziaVPN; +in +{ + options.programs.amneziaVPN = { + enable = lib.mkEnableOption "The AmneziaVPN client"; + }; + + config = lib.mkIf cfg.enable { + environment.systemPackages = [ pkgs.amneziaVPN ]; + + services.dbus.packages = [ pkgs.amneziaVPN ]; + + systemd = { + services.amneziaVPN = { + description = "AmneziaVPN Service"; + after = [ "network.target" ]; + startLimitIntervalSec = 0; + serviceConfig = { + Type = "simple"; + Restart = "always"; + RestartSec = 1; + ExecStart = "${pkgs.amneziaVPN}/bin/AmneziaVPN-service"; + }; + wantedBy = [ "multi-user.target" ]; + }; + }; + }; + + meta.maintainers = with lib.maintainers; [ sund3RRR ]; +} diff --git a/pkgs/by-name/am/amneziaVPN/package.nix b/pkgs/by-name/am/amneziaVPN/package.nix new file mode 100644 index 0000000000000..59f434a3bd626 --- /dev/null +++ b/pkgs/by-name/am/amneziaVPN/package.nix @@ -0,0 +1,94 @@ +{ + lib, + stdenv, + fetchFromGitHub, + cmake, + pkg-config, + kdePackages, + qt6, + libsecret, + xdg-utils, + amneziawg-go, + tun2socks, + xray, + openvpn, + shadowsocks-rust, + cloak-pt, +}: +let + amneziaEnv = [ amneziawg-go tun2socks xray shadowsocks-rust openvpn cloak-pt ]; +in +stdenv.mkDerivation (finalAttrs: { + pname = "amnezia-vpn"; + version = "4.8.2.3"; + + src = fetchFromGitHub { + owner = "amnezia-vpn"; + repo = "amnezia-client"; + rev = "refs/tags/${finalAttrs.version}"; + hash = "sha256-bCWPyRW2xnnopcwfPHgQrdP85Ct0CDufJRQ1PvCAiDE="; + fetchSubmodules = true; + }; + + postPatch = '' + substituteInPlace deploy/installer/config/AmneziaVPN.desktop.in \ + --replace-fail '#!/usr/bin/env xdg-open' '#!${xdg-utils}/bin/xdg-open' + + substituteInPlace client/platforms/linux/daemon/wireguardutilslinux.cpp \ + --replace-fail 'm_tunnel.start(appPath.filePath("../../client/bin/wireguard-go"), wgArgs);' 'm_tunnel.start("${amneziawg-go}/bin/amneziawg-go", wgArgs);' + + substituteInPlace service/server/router_linux.cpp \ + --replace-fail '|| QFileInfo::exists("/usr/lib/systemd/system/nscd.service"))' '|| QFileInfo::exists("/run/systemd/propagate/nscd.service"))' + ''; + + strictDeps = true; + + nativeBuildInputs = [ + cmake + pkg-config + qt6.wrapQtAppsHook + ]; + + buildInputs = [ + libsecret + qt6.qtbase + qt6.qttools + kdePackages.qtremoteobjects + kdePackages.qtsvg + kdePackages.qt5compat + ]; + + qtWrapperArgs = [ + "--prefix PATH : ${ lib.makeBinPath amneziaEnv }" + ]; + + postInstall = '' + # install AmneziaVPN and AmneziaVPN-service + mkdir -p $out/bin + cp client/AmneziaVPN $out/bin/ + cp service/server/AmneziaVPN-service $out/bin/ + + # install .desktop item + mkdir -p $out/share/applications + cp ../AppDir/AmneziaVPN.desktop $out/share/applications/ + + # install icon + mkdir -p $out/share/pixmaps/ + cp ../deploy/data/linux/AmneziaVPN.png $out/share/pixmaps/ + ''; + + preFixup = '' + substituteInPlace $out/share/applications/AmneziaVPN.desktop \ + --replace-fail "Icon=/usr/share/pixmaps/AmneziaVPN.png" "Icon=$out/share/pixmaps/AmneziaVPN.png" + ''; + + meta = with lib; { + description = "Amnezia VPN Client"; + downloadPage = "https://amnezia.org/en/downloads"; + homepage = "https://amnezia.org/en"; + license = licenses.gpl3; + mainProgram = "AmneziaVPN"; + maintainers = with maintainers; [ sund3RRR ]; + platforms = platforms.unix; + }; +})