[GH-ISSUE #676] Packaging for NixOS #175

Open
opened 2026-10-13 20:14:28 +00:00 by bsakaguchi · 23 comments
Owner

Originally created by @spl3g on GitHub (Mar 7, 2024).
Original GitHub issue: https://github.com/amnezia-vpn/amnezia-client/issues/676

Desktop (please complete the following information):

  • OS: NixOS
  • Version 24.05

Additional context
I am trying to package amnezia-client for NixOS. But there's no cqtdeployer there so the build script wouldn't have worked.
I think i figured out the dependencies and i built the AmneziaVPN and AmneziaVPN-service binaries that kind of work but when i try to connect to the server i get this error:

2024-03-07 23:45:38 debug Amnezia "WireguardUtilsLinux" "Tunnel process encountered an error: QProcess::FailedToStart"
2024-03-07 23:45:38 debug Amnezia "WireguardUtilsLinux" "Unable to start tunnel process due to timeout"
2024-03-07 23:45:38 debug Amnezia "Daemon" "Interface creation failed."
2024-03-07 23:45:38 debug Amnezia "DaemonLocalServerConnection" "Failed to activate the interface"

There's my package so far:

{ stdenv
, lib
, fetchFromGitHub
, cmake
, pkg-config
, libsecret
, libgcrypt
, openssl
, openvpn
, tun2socks
, cloak
, shadowsocks-libev
, wireguard-go
, xray
, qtbase
, wrapQtAppsHook
, qtremoteobjects
, qtsvg
, qttools
, qt5compat
, qtkeychain
}:

stdenv.mkDerivation rec {
  pname = "amnezia-client";
  version = "4.4.0.0";
  
  src = fetchFromGitHub {
    repo = "${pname}";
    owner = "amnezia-vpn";

    rev = "${version}";
    sha256 = "0k0sjf1c8iqg9crq4sfzdg4cczaq5pbk5j2873yzsw88rps0awac";
    fetchSubmodules = true;
  };
  
  nativeBuildInputs = [
    cmake
    wrapQtAppsHook
    pkg-config
  ];

  buildInputs = [
    qtbase
    qtremoteobjects
    qtsvg
    qttools
    qt5compat
    qtkeychain
    libsecret
    libgcrypt
    openssl
    openvpn
    tun2socks
    cloak
    shadowsocks-libev
    wireguard-go
    xray
  ];

  installPhase = ''
  runHook preInstall
  make install
  mkdir $out/bin
  mkdir -p $out/usr/share/{pixmaps,applications}
  cp client/AmneziaVPN $out/bin/
  cp service/server/AmneziaVPN-service $out/bin/
  runHook postInstall
  '';
}

I am not very familiar with cmake, c++ and qt so i think i am doing something wrong.

Originally created by @spl3g on GitHub (Mar 7, 2024). Original GitHub issue: https://github.com/amnezia-vpn/amnezia-client/issues/676 **Desktop (please complete the following information):** - OS: NixOS - Version 24.05 **Additional context** I am trying to package amnezia-client for NixOS. But there's no cqtdeployer there so the build script wouldn't have worked. I think i figured out the dependencies and i built the AmneziaVPN and AmneziaVPN-service binaries that kind of work but when i try to connect to the server i get this error: ``` 2024-03-07 23:45:38 debug Amnezia "WireguardUtilsLinux" "Tunnel process encountered an error: QProcess::FailedToStart" 2024-03-07 23:45:38 debug Amnezia "WireguardUtilsLinux" "Unable to start tunnel process due to timeout" 2024-03-07 23:45:38 debug Amnezia "Daemon" "Interface creation failed." 2024-03-07 23:45:38 debug Amnezia "DaemonLocalServerConnection" "Failed to activate the interface" ``` There's my package so far: ```nix { stdenv , lib , fetchFromGitHub , cmake , pkg-config , libsecret , libgcrypt , openssl , openvpn , tun2socks , cloak , shadowsocks-libev , wireguard-go , xray , qtbase , wrapQtAppsHook , qtremoteobjects , qtsvg , qttools , qt5compat , qtkeychain }: stdenv.mkDerivation rec { pname = "amnezia-client"; version = "4.4.0.0"; src = fetchFromGitHub { repo = "${pname}"; owner = "amnezia-vpn"; rev = "${version}"; sha256 = "0k0sjf1c8iqg9crq4sfzdg4cczaq5pbk5j2873yzsw88rps0awac"; fetchSubmodules = true; }; nativeBuildInputs = [ cmake wrapQtAppsHook pkg-config ]; buildInputs = [ qtbase qtremoteobjects qtsvg qttools qt5compat qtkeychain libsecret libgcrypt openssl openvpn tun2socks cloak shadowsocks-libev wireguard-go xray ]; installPhase = '' runHook preInstall make install mkdir $out/bin mkdir -p $out/usr/share/{pixmaps,applications} cp client/AmneziaVPN $out/bin/ cp service/server/AmneziaVPN-service $out/bin/ runHook postInstall ''; } ``` I am not very familiar with cmake, c++ and qt so i think i am doing something wrong.
Author
Owner

@chekoopa commented on GitHub (Apr 21, 2024):

I'll bump this issue, as I am NixOS user and going to try Amnezia, so the client is cruical for me. Maybe I'll also look into it.

There also is a possible OS integration issue, as there are two components of the error message: fail to start tunnel process (due to some error yet to explore), and interface creation fail (which is also something to explore i.e. through dmesg).

<!-- gh-comment-id:2068121265 --> @chekoopa commented on GitHub (Apr 21, 2024): I'll bump this issue, as I am NixOS user and going to try Amnezia, so the client is cruical for me. Maybe I'll also look into it. There also is a possible OS integration issue, as there are two components of the error message: fail to start tunnel process (due to some error yet to explore), and interface creation fail (which is also something to explore i.e. through dmesg).
Author
Owner

@pokamest commented on GitHub (Apr 22, 2024):

Hi!
Does AmneziaVPN-service has enough privileges to create tun devices in your package?
It's running with sudo privileges when installed by installer.

<!-- gh-comment-id:2068283660 --> @pokamest commented on GitHub (Apr 22, 2024): Hi! Does AmneziaVPN-service has enough privileges to create tun devices in your package? It's running with sudo privileges when installed by installer.
Author
Owner

@Askodon commented on GitHub (Jul 19, 2024):

any progress?

<!-- gh-comment-id:2238155403 --> @Askodon commented on GitHub (Jul 19, 2024): any progress?
Author
Owner

@PRESFIL commented on GitHub (Jul 29, 2024):

Apparently the package names have changed since march, I updated default.nix so
that it builds on the current version of nixpkgs:

--- /tmp/default.nix
+++ /tmp/amnezia/default.nix
@@ -12,13 +12,8 @@
 , shadowsocks-libev
 , wireguard-go
 , xray
-, qtbase
-, wrapQtAppsHook
-, qtremoteobjects
-, qtsvg
-, qttools
-, qt5compat
-, qtkeychain
+, qt6
+, libsForQt5
 }:

 stdenv.mkDerivation rec {
@@ -36,17 +31,17 @@

   nativeBuildInputs = [
     cmake
-    wrapQtAppsHook
+    qt6.wrapQtAppsHook
     pkg-config
   ];

   buildInputs = [
-    qtbase
-    qtremoteobjects
-    qtsvg
-    qttools
-    qt5compat
-    qtkeychain
+    qt6.qtbase
+    qt6.qtremoteobjects
+    qt6.qtsvg
+    qt6.qttools
+    qt6.qt5compat
+    libsForQt5.qtkeychain
     libsecret
     libgcrypt
     openssl
`default.nix`
{ stdenv
, lib
, fetchFromGitHub
, cmake
, pkg-config
, libsecret
, libgcrypt
, openssl
, openvpn
, tun2socks
, cloak
, shadowsocks-libev
, wireguard-go
, xray
, qt6
, libsForQt5
}:

stdenv.mkDerivation rec {
  pname = "amnezia-client";
  version = "4.4.0.0";
  
  src = fetchFromGitHub {
    repo = "${pname}";
    owner = "amnezia-vpn";

    rev = "${version}";
    sha256 = "0k0sjf1c8iqg9crq4sfzdg4cczaq5pbk5j2873yzsw88rps0awac";
    fetchSubmodules = true;
  };
  
  nativeBuildInputs = [
    cmake
    qt6.wrapQtAppsHook
    pkg-config
  ];

  buildInputs = [
    qt6.qtbase
    qt6.qtremoteobjects
    qt6.qtsvg
    qt6.qttools
    qt6.qt5compat
    libsForQt5.qtkeychain
    libsecret
    libgcrypt
    openssl
    openvpn
    tun2socks
    cloak
    shadowsocks-libev
    wireguard-go
    xray
  ];

  installPhase = ''
  runHook preInstall
  make install
  mkdir $out/bin
  mkdir -p $out/usr/share/{pixmaps,applications}
  cp client/AmneziaVPN $out/bin/
  cp service/server/AmneziaVPN-service $out/bin/
  runHook postInstall
  '';
}

I noticed several obvious problems in the current version of default.nix,
which is why it will not be accepted in nixpkgs, (besides the fact that
tunnels are not being created), which I don't know how to fix yet:

  1. Extra directories, at least /usr in NixOS were abandoned:
tree /nix/store/964sfqdd47k92yxjbaa924szjijxmby8-amnezia-client-4.4.0.0
/nix/store/964sfqdd47k92yxjbaa924szjijxmby8-amnezia-client-4.4.0.0
├── bin
│   ├── AmneziaVPN
│   └── AmneziaVPN-service
├── include                                             # maybe should be excluded (or linked)
│   └── qt6keychain
│       ├── keychain.h
│       └── qkeychain_export.h
├── lib                                                 # maybe should be excluded (or linked)
│   ├── cmake
│   │   └── Qt6Keychain
│   │       ├── Qt6KeychainConfig.cmake
│   │       ├── Qt6KeychainConfigVersion.cmake
│   │       ├── Qt6KeychainLibraryDepends.cmake
│   │       └── Qt6KeychainLibraryDepends-release.cmake
│   └── libqt6keychain.a
├── mkspecs                                             # maybe should be excluded (or linked)
│   └── modules
│       └── qt_Qt6Keychain.pri
└── usr                                                 # no /usr on NixOS
    └── share
        ├── applications                                # empty!
        └── pixmaps                                     # empty!

13 directories, 10 files
  1. Apparently, bin/AmneziaVPN-service should be run with privileges, but there
    is no systemd service-file in the assembled package

I ran the built package on user profile and regular Linux with the nix package
manager installed, not on a full-fledged NixOS installation, so I can't write a
definition of the systemd-service and check it's working as expected.

Command to build a package (default.nix in ${CWD}) with a specific version
of nixpkgs (for reproducibility):

nix-build -I nixpkgs=https://github.com/NixOS/nixpkgs/archive/6921160271c969939bdd82c46969ac9877ba9827.tar.gz  -E 'with import <nixpkgs> {}; callPackage ./default.nix {}'
<!-- gh-comment-id:2255612078 --> @PRESFIL commented on GitHub (Jul 29, 2024): Apparently the package names have changed since march, I updated `default.nix` so that it builds on the current version of `nixpkgs`: ```diff --- /tmp/default.nix +++ /tmp/amnezia/default.nix @@ -12,13 +12,8 @@ , shadowsocks-libev , wireguard-go , xray -, qtbase -, wrapQtAppsHook -, qtremoteobjects -, qtsvg -, qttools -, qt5compat -, qtkeychain +, qt6 +, libsForQt5 }: stdenv.mkDerivation rec { @@ -36,17 +31,17 @@ nativeBuildInputs = [ cmake - wrapQtAppsHook + qt6.wrapQtAppsHook pkg-config ]; buildInputs = [ - qtbase - qtremoteobjects - qtsvg - qttools - qt5compat - qtkeychain + qt6.qtbase + qt6.qtremoteobjects + qt6.qtsvg + qt6.qttools + qt6.qt5compat + libsForQt5.qtkeychain libsecret libgcrypt openssl ``` <details> <summary>`default.nix`</summary> ```nix { stdenv , lib , fetchFromGitHub , cmake , pkg-config , libsecret , libgcrypt , openssl , openvpn , tun2socks , cloak , shadowsocks-libev , wireguard-go , xray , qt6 , libsForQt5 }: stdenv.mkDerivation rec { pname = "amnezia-client"; version = "4.4.0.0"; src = fetchFromGitHub { repo = "${pname}"; owner = "amnezia-vpn"; rev = "${version}"; sha256 = "0k0sjf1c8iqg9crq4sfzdg4cczaq5pbk5j2873yzsw88rps0awac"; fetchSubmodules = true; }; nativeBuildInputs = [ cmake qt6.wrapQtAppsHook pkg-config ]; buildInputs = [ qt6.qtbase qt6.qtremoteobjects qt6.qtsvg qt6.qttools qt6.qt5compat libsForQt5.qtkeychain libsecret libgcrypt openssl openvpn tun2socks cloak shadowsocks-libev wireguard-go xray ]; installPhase = '' runHook preInstall make install mkdir $out/bin mkdir -p $out/usr/share/{pixmaps,applications} cp client/AmneziaVPN $out/bin/ cp service/server/AmneziaVPN-service $out/bin/ runHook postInstall ''; } ``` </details> I noticed several obvious problems in the current version of `default.nix`, which is why it will not be accepted in `nixpkgs`, (besides the fact that tunnels are not being created), which I don't know how to fix yet: 1. Extra directories, at least `/usr` in NixOS were abandoned: ```sh tree /nix/store/964sfqdd47k92yxjbaa924szjijxmby8-amnezia-client-4.4.0.0 ``` ``` /nix/store/964sfqdd47k92yxjbaa924szjijxmby8-amnezia-client-4.4.0.0 ├── bin │   ├── AmneziaVPN │   └── AmneziaVPN-service ├── include # maybe should be excluded (or linked) │   └── qt6keychain │   ├── keychain.h │   └── qkeychain_export.h ├── lib # maybe should be excluded (or linked) │   ├── cmake │   │   └── Qt6Keychain │   │   ├── Qt6KeychainConfig.cmake │   │   ├── Qt6KeychainConfigVersion.cmake │   │   ├── Qt6KeychainLibraryDepends.cmake │   │   └── Qt6KeychainLibraryDepends-release.cmake │   └── libqt6keychain.a ├── mkspecs # maybe should be excluded (or linked) │   └── modules │   └── qt_Qt6Keychain.pri └── usr # no /usr on NixOS └── share ├── applications # empty! └── pixmaps # empty! 13 directories, 10 files ``` 2. Apparently, `bin/AmneziaVPN-service` should be run with privileges, but there is no systemd service-file in the assembled package I ran the built package on user profile and regular Linux with the `nix` package manager installed, not on a full-fledged NixOS installation, so I can't write a definition of the systemd-service and check it's working as expected. Command to build a package (`default.nix` in `${CWD}`) with a specific version of `nixpkgs` (for reproducibility): ```sh nix-build -I nixpkgs=https://github.com/NixOS/nixpkgs/archive/6921160271c969939bdd82c46969ac9877ba9827.tar.gz -E 'with import <nixpkgs> {}; callPackage ./default.nix {}' ```
Author
Owner

@PRESFIL commented on GitHub (Jul 31, 2024):

Made a few more changes:

  1. cloak is not the same cloak for hide service, cbeuw/cloak isn't
    packaged for NixOS, wireguard-go is not an Amnesia-WG (maybe in march yet
    there was no Amnesia-WG). Both of these dependencies are removed and taken
    from deploy-prebuilt (although it might be better if they were built as
    separate packages)

  2. Moved share/ from usr/ to the root

  3. Added desktop file, icon, service-file and files from deploy-prebuilt/*/bin

  4. The breakpointHook is convenient to use for debugging

The final diff:

diff -u a/default.nix b/default.nix
--- default.nix
+++ default.nix
@@ -8,17 +8,20 @@
 , openssl
 , openvpn
 , tun2socks
-, cloak
+# , cloak # not the same one
+# only packaged on AUR https://github.com/amnezia-vpn/amnezia-client/issues/120
+# usage of prebuilt binaries!
 , shadowsocks-libev
-, wireguard-go
+# , wireguard-go # not the same one
 , xray
 , qt6
 , libsForQt5
+, breakpointHook
 }:
 
 stdenv.mkDerivation rec {
   pname = "amnezia-client";
-  version = "4.4.0.0";
+  version = "4.6.0.3";
   
   src = fetchFromGitHub {
     repo = "${pname}";
@@ -33,6 +36,7 @@
     cmake
     qt6.wrapQtAppsHook
     pkg-config
+    breakpointHook
   ];
 
   buildInputs = [
@@ -47,9 +51,9 @@
     openssl
     openvpn
     tun2socks
-    cloak
+#    cloak # not the same one
     shadowsocks-libev
-    wireguard-go
+#    wireguard-go # not the same one
     xray
   ];
 
@@ -57,9 +61,18 @@
   runHook preInstall
   make install
   mkdir $out/bin
-  mkdir -p $out/usr/share/{pixmaps,applications}
+  mkdir -p $out/share/{pixmaps,applications}
+  mkdir -p $out/share/systemd/system/
   cp client/AmneziaVPN $out/bin/
   cp service/server/AmneziaVPN-service $out/bin/
+  cp ../deploy/data/linux/client/bin/update-resolv-conf.sh $out/bin/
+  cp ../deploy/data/linux/AmneziaVPN.png $out/share/pixmaps/
+  cp ../deploy/data/linux/AmneziaVPN.service $out/share/systemd/system/
+  cp ../deploy/data/deploy-prebuilt/linux/client/bin/ck-client $out/bin/
+  cp ../deploy/data/deploy-prebuilt/linux/client/bin/geoip.dat $out/bin/
+  cp ../deploy/data/deploy-prebuilt/linux/client/bin/geosite.dat $out/bin/
+  cp ../deploy/data/deploy-prebuilt/linux/client/bin/wireguard-go $out/bin/
+  cp ../AppDir/AmneziaVPN.desktop $out/share/applications/
   runHook postInstall
   '';
-}
\ No newline
+}
`default.nix`
{ stdenv
, lib
, fetchFromGitHub
, cmake
, pkg-config
, libsecret
, libgcrypt
, openssl
, openvpn
, tun2socks
# , cloak # not the same one
# only packaged on AUR https://github.com/amnezia-vpn/amnezia-client/issues/120
# usage of prebuilt binaries!
, shadowsocks-libev
# , wireguard-go # not the same one
, xray
, qt6
, libsForQt5
, breakpointHook
}:

stdenv.mkDerivation rec {
  pname = "amnezia-client";
  version = "4.6.0.3";
  
  src = fetchFromGitHub {
    repo = "${pname}";
    owner = "amnezia-vpn";

    rev = "${version}";
    sha256 = "0k0sjf1c8iqg9crq4sfzdg4cczaq5pbk5j2873yzsw88rps0awac";
    fetchSubmodules = true;
  };
  
  nativeBuildInputs = [
    cmake
    qt6.wrapQtAppsHook
    pkg-config
    breakpointHook
  ];

  buildInputs = [
    qt6.qtbase
    qt6.qtremoteobjects
    qt6.qtsvg
    qt6.qttools
    qt6.qt5compat
    libsForQt5.qtkeychain
    libsecret
    libgcrypt
    openssl
    openvpn
    tun2socks
#    cloak # not the same one
    shadowsocks-libev
#    wireguard-go # not the same one
    xray
  ];

  installPhase = ''
  runHook preInstall
  make install
  mkdir $out/bin
  mkdir -p $out/share/{pixmaps,applications}
  mkdir -p $out/share/systemd/system/
  cp client/AmneziaVPN $out/bin/
  cp service/server/AmneziaVPN-service $out/bin/
  cp ../deploy/data/linux/client/bin/update-resolv-conf.sh $out/bin/
  cp ../deploy/data/linux/AmneziaVPN.png $out/share/pixmaps/
  cp ../deploy/data/linux/AmneziaVPN.service $out/share/systemd/system/
  cp ../deploy/data/deploy-prebuilt/linux/client/bin/ck-client $out/bin/
  cp ../deploy/data/deploy-prebuilt/linux/client/bin/geoip.dat $out/bin/
  cp ../deploy/data/deploy-prebuilt/linux/client/bin/geosite.dat $out/bin/
  cp ../deploy/data/deploy-prebuilt/linux/client/bin/wireguard-go $out/bin/
  cp ../AppDir/AmneziaVPN.desktop $out/share/applications/
  runHook postInstall
  '';
}

But the connection still fails😃 Amnezia-client is too heavily tied to
/usr, /opt and its prebuilt dependencies in /opt (see
client/utilities.cpp, maybe other places).

I assume that update-resolv-conf.sh cannot be put in bin/, I'm not sure if
the Amnezia-client will find it, maybe this is the reason why nothing
works. Perhaps the best way to store all these files is in share/ or lib/
but with the current implementation, Amnezia will not find them.

A complete list of dependencies is needed to make it clear which of them are
optional and which are mandatory. The wide variety of ways to install Amnezia
without good documentation is confusing.

This issue cannot be fixed without the help of the main developers.

<!-- gh-comment-id:2261523911 --> @PRESFIL commented on GitHub (Jul 31, 2024): Made a few more changes: 1. `cloak` is not the same `cloak` for hide service, `cbeuw/cloak` isn't packaged for NixOS, `wireguard-go` is not an Amnesia-WG (maybe in march yet there was no Amnesia-WG). Both of these dependencies are removed and taken from deploy-prebuilt (although it might be better if they were built as separate packages) 2. Moved `share/` from `usr/` to the root 3. Added desktop file, icon, service-file and files from `deploy-prebuilt/*/bin` 4. The `breakpointHook` is convenient to use for debugging The final diff: ```diff diff -u a/default.nix b/default.nix --- default.nix +++ default.nix @@ -8,17 +8,20 @@ , openssl , openvpn , tun2socks -, cloak +# , cloak # not the same one +# only packaged on AUR https://github.com/amnezia-vpn/amnezia-client/issues/120 +# usage of prebuilt binaries! , shadowsocks-libev -, wireguard-go +# , wireguard-go # not the same one , xray , qt6 , libsForQt5 +, breakpointHook }: stdenv.mkDerivation rec { pname = "amnezia-client"; - version = "4.4.0.0"; + version = "4.6.0.3"; src = fetchFromGitHub { repo = "${pname}"; @@ -33,6 +36,7 @@ cmake qt6.wrapQtAppsHook pkg-config + breakpointHook ]; buildInputs = [ @@ -47,9 +51,9 @@ openssl openvpn tun2socks - cloak +# cloak # not the same one shadowsocks-libev - wireguard-go +# wireguard-go # not the same one xray ]; @@ -57,9 +61,18 @@ runHook preInstall make install mkdir $out/bin - mkdir -p $out/usr/share/{pixmaps,applications} + mkdir -p $out/share/{pixmaps,applications} + mkdir -p $out/share/systemd/system/ cp client/AmneziaVPN $out/bin/ cp service/server/AmneziaVPN-service $out/bin/ + cp ../deploy/data/linux/client/bin/update-resolv-conf.sh $out/bin/ + cp ../deploy/data/linux/AmneziaVPN.png $out/share/pixmaps/ + cp ../deploy/data/linux/AmneziaVPN.service $out/share/systemd/system/ + cp ../deploy/data/deploy-prebuilt/linux/client/bin/ck-client $out/bin/ + cp ../deploy/data/deploy-prebuilt/linux/client/bin/geoip.dat $out/bin/ + cp ../deploy/data/deploy-prebuilt/linux/client/bin/geosite.dat $out/bin/ + cp ../deploy/data/deploy-prebuilt/linux/client/bin/wireguard-go $out/bin/ + cp ../AppDir/AmneziaVPN.desktop $out/share/applications/ runHook postInstall ''; -} \ No newline +} ``` <details> <summary>`default.nix`</summary> ```nix { stdenv , lib , fetchFromGitHub , cmake , pkg-config , libsecret , libgcrypt , openssl , openvpn , tun2socks # , cloak # not the same one # only packaged on AUR https://github.com/amnezia-vpn/amnezia-client/issues/120 # usage of prebuilt binaries! , shadowsocks-libev # , wireguard-go # not the same one , xray , qt6 , libsForQt5 , breakpointHook }: stdenv.mkDerivation rec { pname = "amnezia-client"; version = "4.6.0.3"; src = fetchFromGitHub { repo = "${pname}"; owner = "amnezia-vpn"; rev = "${version}"; sha256 = "0k0sjf1c8iqg9crq4sfzdg4cczaq5pbk5j2873yzsw88rps0awac"; fetchSubmodules = true; }; nativeBuildInputs = [ cmake qt6.wrapQtAppsHook pkg-config breakpointHook ]; buildInputs = [ qt6.qtbase qt6.qtremoteobjects qt6.qtsvg qt6.qttools qt6.qt5compat libsForQt5.qtkeychain libsecret libgcrypt openssl openvpn tun2socks # cloak # not the same one shadowsocks-libev # wireguard-go # not the same one xray ]; installPhase = '' runHook preInstall make install mkdir $out/bin mkdir -p $out/share/{pixmaps,applications} mkdir -p $out/share/systemd/system/ cp client/AmneziaVPN $out/bin/ cp service/server/AmneziaVPN-service $out/bin/ cp ../deploy/data/linux/client/bin/update-resolv-conf.sh $out/bin/ cp ../deploy/data/linux/AmneziaVPN.png $out/share/pixmaps/ cp ../deploy/data/linux/AmneziaVPN.service $out/share/systemd/system/ cp ../deploy/data/deploy-prebuilt/linux/client/bin/ck-client $out/bin/ cp ../deploy/data/deploy-prebuilt/linux/client/bin/geoip.dat $out/bin/ cp ../deploy/data/deploy-prebuilt/linux/client/bin/geosite.dat $out/bin/ cp ../deploy/data/deploy-prebuilt/linux/client/bin/wireguard-go $out/bin/ cp ../AppDir/AmneziaVPN.desktop $out/share/applications/ runHook postInstall ''; } ``` </details> But the connection still fails:smiley: Amnezia-client is too heavily tied to `/usr`, `/opt` and its prebuilt dependencies in `/opt` (see [client/utilities.cpp][1], maybe other places). I assume that `update-resolv-conf.sh` cannot be put in `bin/`, I'm not sure if the Amnezia-client will find it, maybe this is the reason why nothing works. Perhaps the best way to store all these files is in `share/` or `lib/` but with the current implementation, Amnezia will not find them. A complete list of dependencies is needed to make it clear which of them are optional and which are mandatory. The wide variety of ways to install Amnezia without good documentation is confusing. This issue cannot be fixed without the help of the main developers. [1]: https://github.com/amnezia-vpn/amnezia-client/blob/dev/client/utilities.cpp
Author
Owner

@chekoopa commented on GitHub (Aug 1, 2024):

Considering executable dependencies, we may add a patch to replace these calls with /usr/bin/env <basename>. It probably would make some effect (and even start connecting). But it may be pretty unsafe, however, like for name squatting.

github.com/amnezia-vpn/amnezia-client@ffe2314d47/client/utilities.cpp (L117-L123)

resolv.conf editing is nasty in NixOS, as it is almost always symlinked. However, I suppose it is needed for Amnezia VPN, which is useful, however is not on the critical path.

<!-- gh-comment-id:2263470624 --> @chekoopa commented on GitHub (Aug 1, 2024): Considering executable dependencies, we may add a patch to replace these calls with `/usr/bin/env <basename>`. It probably would make some effect (and even start connecting). But it may be pretty unsafe, however, like for name squatting. https://github.com/amnezia-vpn/amnezia-client/blob/ffe2314d476849395506622d0df516310d19b980/client/utilities.cpp#L117-L123 `resolv.conf` editing is nasty in NixOS, as it is almost always symlinked. However, I suppose it is needed for Amnezia VPN, which is useful, however is not on the critical path.
Author
Owner

@chekoopa commented on GitHub (Aug 1, 2024):

Yes, I've made a little research on Nixpkgs and found a few nice examples of path replacement patches:

github.com/NixOS/nixpkgs@affeca17c0/pkgs/kde/plasma/plasma-nm

github.com/NixOS/nixpkgs@affeca17c0/pkgs/tools/virtualization/google-guest-configs

<!-- gh-comment-id:2263481438 --> @chekoopa commented on GitHub (Aug 1, 2024): Yes, I've made a little research on Nixpkgs and found a few nice examples of path replacement patches: https://github.com/NixOS/nixpkgs/tree/affeca17c005add89347d9bdfbc2c8bba4728aa9/pkgs/kde/plasma/plasma-nm https://github.com/NixOS/nixpkgs/tree/affeca17c005add89347d9bdfbc2c8bba4728aa9/pkgs/tools/virtualization/google-guest-configs
Author
Owner

@AveryanAlex commented on GitHub (Sep 16, 2024):

If someone interested, I packaged kernel module, amneziawg-tools, amneziawg-go and updated wg-quick nixos module.

<!-- gh-comment-id:2352317200 --> @AveryanAlex commented on GitHub (Sep 16, 2024): If someone interested, I packaged [kernel module](https://github.com/NixOS/nixpkgs/pull/331598), [amneziawg-tools](https://github.com/NixOS/nixpkgs/pull/331582), [amneziawg-go](https://github.com/NixOS/nixpkgs/pull/331574) and updated [wg-quick nixos module](https://github.com/NixOS/nixpkgs/pull/341663).
Author
Owner

@BANanaD3V commented on GitHub (Oct 9, 2024):

  1. cloak is not the same cloak for hide service, cbeuw/cloak

If you're still interested, I've packaged cloak as cloak-pt. Already in nixpkgs for quite some time.

<!-- gh-comment-id:2401320362 --> @BANanaD3V commented on GitHub (Oct 9, 2024): > 1. `cloak` is not the same `cloak` for hide service, `cbeuw/cloak` If you're still interested, I've packaged cloak as `cloak-pt`. Already in nixpkgs for quite some time.
Author
Owner

@alexrosette commented on GitHub (Nov 25, 2024):

Sorry, I would like to know about the promotion of AmneziaVPN-client. It still cannot be packaged for nixos?

<!-- gh-comment-id:2497160810 --> @alexrosette commented on GitHub (Nov 25, 2024): Sorry, I would like to know about the promotion of AmneziaVPN-client. It still cannot be packaged for nixos?
Author
Owner

@adrianopol commented on GitHub (Nov 25, 2024):

Hello, @ritascarlet , I assume it is already in unstable branch: https://search.nixos.org/packages?channel=unstable&sort=relevance&type=packages&query=amnezia

<!-- gh-comment-id:2499099361 --> @adrianopol commented on GitHub (Nov 25, 2024): Hello, @ritascarlet , I assume it is already in unstable branch: https://search.nixos.org/packages?channel=unstable&sort=relevance&type=packages&query=amnezia
Author
Owner

@AveryanAlex commented on GitHub (Nov 25, 2024):

Hello, @ritascarlet , I assume it is already in unstable branch: https://search.nixos.org/packages?channel=unstable&sort=relevance&type=packages&query=amnezia

Yes, but this is a CLI clients, the GUI client is not packaged yet

<!-- gh-comment-id:2499102236 --> @AveryanAlex commented on GitHub (Nov 25, 2024): > Hello, @ritascarlet , I assume it is already in unstable branch: https://search.nixos.org/packages?channel=unstable&sort=relevance&type=packages&query=amnezia Yes, but this is a CLI clients, the GUI client is not packaged yet
Author
Owner

@alexrosette commented on GitHub (Nov 25, 2024):

Да, но это CLI-клиент, GUI-клиент еще не упакован

If it's not difficult for you, then can you tell me how to use the clients currently in the repository correctly? I'm completely new to NixOs, Therefore, I do not understand what packages to install for my kernel (linux nixos 6.6.62)

<!-- gh-comment-id:2499109893 --> @alexrosette commented on GitHub (Nov 25, 2024): > Да, но это CLI-клиент, GUI-клиент еще не упакован If it's not difficult for you, then can you tell me how to use the clients currently in the repository correctly? I'm completely new to NixOs, Therefore, I do not understand what packages to install for my kernel (linux nixos 6.6.62)
Author
Owner

@AveryanAlex commented on GitHub (Nov 25, 2024):

Да, но это CLI-клиент, GUI-клиент еще не упакован

If it's not difficult for you, then can you tell me how to use the clients currently in the repository correctly? I'm completely new to NixOs, Therefore, I do not understand what packages to install for my kernel (linux nixos 6.6.62)

I think you should wait for https://github.com/NixOS/nixpkgs/pull/341663. Or, if you want to use it right now, you can switch to unstable branch, add amneziawg tools to system packages, and add amneziawg to kernel packages. Then just use awg-quick cli tool.

<!-- gh-comment-id:2499114947 --> @AveryanAlex commented on GitHub (Nov 25, 2024): > > > Да, но это CLI-клиент, GUI-клиент еще не упакован > > If it's not difficult for you, then can you tell me how to use the clients currently in the repository correctly? I'm completely new to NixOs, Therefore, I do not understand what packages to install for my kernel (linux nixos 6.6.62) > > I think you should wait for https://github.com/NixOS/nixpkgs/pull/341663. Or, if you want to use it right now, you can switch to unstable branch, add amneziawg tools to system packages, and add amneziawg to kernel packages. Then just use awg-quick cli tool.
Author
Owner

@alexrosette commented on GitHub (Nov 25, 2024):

I think you should wait for NixOS/nixpkgs#341663. Or, if you want to use it right now, you can switch to unstable branch, add amneziawg tools to system packages, and add amneziawg to kernel packages. Then just use awg-quick cli tool.

Great, I will try to do everything as you said, I will definitely wait for the client’s packaging. Thank you very much!

<!-- gh-comment-id:2499120201 --> @alexrosette commented on GitHub (Nov 25, 2024): > I think you should wait for [NixOS/nixpkgs#341663](https://github.com/NixOS/nixpkgs/pull/341663). Or, if you want to use it right now, you can switch to unstable branch, add amneziawg tools to system packages, and add amneziawg to kernel packages. Then just use awg-quick cli tool. Great, I will try to do everything as you said, I will definitely wait for the client’s packaging. Thank you very much!
Author
Owner

@PRESFIL commented on GitHub (Dec 19, 2024):

There is also this PR NixOS/nixpkgs#360866 .

<!-- gh-comment-id:2555696155 --> @PRESFIL commented on GitHub (Dec 19, 2024): There is also this PR NixOS/nixpkgs#360866 .
Author
Owner

@sund3RRR commented on GitHub (Dec 23, 2024):

I got it working https://github.com/NixOS/nixpkgs/issues/338380#issuecomment-2560157601
I can start making a PR or help someone, who wants to maintain the package

<!-- gh-comment-id:2560164521 --> @sund3RRR commented on GitHub (Dec 23, 2024): I got it working https://github.com/NixOS/nixpkgs/issues/338380#issuecomment-2560157601 I can start making a PR or help someone, who wants to maintain the package
Author
Owner

@ismay-tue commented on GitHub (Mar 15, 2026):

I got it working NixOS/nixpkgs#338380 (comment) I can start making a PR or help someone, who wants to maintain the package

@sund3RRR Could you share how you got it to work? Because I can get a connection working just fine with awg-quick on nixos (or with mobile clients on android), but with the same server and the amnezia vpn client it's not working.

Connects according to the GUI, but the daemon logs show that the handshake isn't happening, and there is no connectivity. It also seems to be adding a ton of custom routes, compared to what awg-quick does, which I suspect is the cause of the problems.

<!-- gh-comment-id:4063225483 --> @ismay-tue commented on GitHub (Mar 15, 2026): > I got it working [NixOS/nixpkgs#338380 (comment)](https://github.com/NixOS/nixpkgs/issues/338380#issuecomment-2560157601) I can start making a PR or help someone, who wants to maintain the package @sund3RRR Could you share how you got it to work? Because I can get a connection working just fine with awg-quick on nixos (or with mobile clients on android), but with the same server and the amnezia vpn client it's not working. Connects according to the GUI, but the daemon logs show that the handshake isn't happening, and there is no connectivity. It also seems to be adding a ton of custom routes, compared to what awg-quick does, which I suspect is the cause of the problems.
Author
Owner

@borisiua commented on GitHub (Apr 26, 2026):

I got it working NixOS/nixpkgs#338380 (comment) I can start making a PR or help someone, who wants to maintain the package

@sund3RRR Could you share how you got it to work? Because I can get a connection working just fine with awg-quick on nixos (or with mobile clients on android), but with the same server and the amnezia vpn client it's not working.

Connects according to the GUI, but the daemon logs show that the handshake isn't happening, and there is no connectivity. It also seems to be adding a ton of custom routes, compared to what awg-quick does, which I suspect is the cause of the problems.

@ismay-tue Could anyone please make awg-quick setup guide for nixos? Unfortunately there is no info anywhere, and only found that this is the only way currently to make amnezia client work on nixos, since the main gui client is broken at this moment

<!-- gh-comment-id:4322353523 --> @borisiua commented on GitHub (Apr 26, 2026): > > I got it working [NixOS/nixpkgs#338380 (comment)](https://github.com/NixOS/nixpkgs/issues/338380#issuecomment-2560157601) I can start making a PR or help someone, who wants to maintain the package > > [@sund3RRR](https://github.com/sund3RRR) Could you share how you got it to work? Because I can get a connection working just fine with awg-quick on nixos (or with mobile clients on android), but with the same server and the amnezia vpn client it's not working. > > Connects according to the GUI, but the daemon logs show that the handshake isn't happening, and there is no connectivity. It also seems to be adding a ton of custom routes, compared to what awg-quick does, which I suspect is the cause of the problems. @ismay-tue Could anyone please make `awg-quick` setup guide for nixos? Unfortunately there is no info anywhere, and only found that this is the only way currently to make amnezia client work on nixos, since the main gui client is broken at this moment
Author
Owner

@ismay-tue commented on GitHub (Apr 26, 2026):

@ismay-tue Could anyone please make awg-quick setup guide for nixos? Unfortunately there is no info anywhere, and only found that this is the only way currently to make amnezia client work on nixos, since the main gui client is broken at this moment

I've moved to https://github.com/ClusterM/wg-obfuscator. I recommend using that. Much simpler, more stable and works out of the box with nixos.

<!-- gh-comment-id:4322625690 --> @ismay-tue commented on GitHub (Apr 26, 2026): > [@ismay-tue](https://github.com/ismay-tue) Could anyone please make `awg-quick` setup guide for nixos? Unfortunately there is no info anywhere, and only found that this is the only way currently to make amnezia client work on nixos, since the main gui client is broken at this moment I've moved to https://github.com/ClusterM/wg-obfuscator. I recommend using that. Much simpler, more stable and works out of the box with nixos.
Author
Owner

@borisiua commented on GitHub (Apr 26, 2026):

@ismay-tue Could anyone please make awg-quick setup guide for nixos? Unfortunately there is no info anywhere, and only found that this is the only way currently to make amnezia client work on nixos, since the main gui client is broken at this moment

I've moved to https://github.com/ClusterM/wg-obfuscator. I recommend using that. Much simpler, more stable and works out of the box with nixos.

@ismay-tue thank you, will see it too! actually just found main gui amnezia client working for me! it failed before just because imported by config as AmneziaWG Legacy, and not AmneziaWG Version 2, as other clients do by default. Once switched to v2, everything works well. Wrote more in https://github.com/NixOS/nixpkgs/issues/474746 , maybe will cover your case too!

<!-- gh-comment-id:4322849698 --> @borisiua commented on GitHub (Apr 26, 2026): > > [@ismay-tue](https://github.com/ismay-tue) Could anyone please make `awg-quick` setup guide for nixos? Unfortunately there is no info anywhere, and only found that this is the only way currently to make amnezia client work on nixos, since the main gui client is broken at this moment > > I've moved to https://github.com/ClusterM/wg-obfuscator. I recommend using that. Much simpler, more stable and works out of the box with nixos. @ismay-tue thank you, will see it too! actually just found main gui amnezia client working for me! it failed before just because imported by config as AmneziaWG Legacy, and not AmneziaWG Version 2, as other clients do by default. Once switched to v2, everything works well. Wrote more in https://github.com/NixOS/nixpkgs/issues/474746 , maybe will cover your case too!
Author
Owner

@borisiua commented on GitHub (Apr 26, 2026):

@ismay-tue Could anyone please make awg-quick setup guide for nixos? Unfortunately there is no info anywhere, and only found that this is the only way currently to make amnezia client work on nixos, since the main gui client is broken at this moment

I've moved to https://github.com/ClusterM/wg-obfuscator. I recommend using that. Much simpler, more stable and works out of the box with nixos.

@ismay-tue sorry for bothering, if not that hard to you, could you please write just few sentences on how to make it work in nixos practically? to get the high level overview and be able to go deeper with ai. do i understand correctly it is not another vpn solution, but rather just a linux client we can use for amneziawg2?

<!-- gh-comment-id:4322884050 --> @borisiua commented on GitHub (Apr 26, 2026): > > [@ismay-tue](https://github.com/ismay-tue) Could anyone please make `awg-quick` setup guide for nixos? Unfortunately there is no info anywhere, and only found that this is the only way currently to make amnezia client work on nixos, since the main gui client is broken at this moment > > I've moved to https://github.com/ClusterM/wg-obfuscator. I recommend using that. Much simpler, more stable and works out of the box with nixos. @ismay-tue sorry for bothering, if not that hard to you, could you please write just few sentences on how to make it work in nixos practically? to get the high level overview and be able to go deeper with ai. do i understand correctly it is not another vpn solution, but rather just a linux client we can use for amneziawg2?
Author
Owner

@ismay-tue commented on GitHub (Apr 27, 2026):

No worries, not a bother. But to be honest, I don't know anymore how I got it running. But basically it's the same as wg-quick. So follow the setup guide for that, and add the extra parameters that amnezia expects in your config. Other than that, not sure, sorry.

<!-- gh-comment-id:4326574846 --> @ismay-tue commented on GitHub (Apr 27, 2026): No worries, not a bother. But to be honest, I don't know anymore how I got it running. But basically it's the same as wg-quick. So follow the setup guide for that, and add the extra parameters that amnezia expects in your config. Other than that, not sure, sorry.
Sign in to join this conversation.
No labels
pull-request
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
amnezia-vpn/amnezia-client#175
No description provided.