-
-
Notifications
You must be signed in to change notification settings - Fork 14.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[package request]: NordVPN #101864
Comments
I have no idea what I am doing but following a blog post over at reflexivereflection.com and the nixos wiki about deb packages in nixos lead me to nordvpn.nix and builder.sh
|
I was able to run the nordvpn service by running it in a bubblewrap environment... This makes nordvpnd find the stuff it expects under
Here is the code.
Maybe anyone else has a tip how to circumvent this issue? |
I have been playing around with this for the last day and it seems to be a very interesting thing to try and package for nix. The .deb only adds a GPG key and the location of the nordvpn repository to your apt package manager, so you can then download and update the package through apt normally. This means that one cannot use the same style of packaging as we see in other .deb packages like opera, skype, or teams. |
Currently trying to see if there is a compiled binary somewhere on their repository and try packaging that directly, but probably will run into an issue of needing the GPG key. |
Disclaimer: I've only recently started using nix. I've been working on this a little bit and I think I've narrowed down exactly where the issue lies. First I've updated the nordvpn version to the latest because it will complain if it isn't the latest. Here is my first file
So if you take that file and place it somewhere and execute
It looks like they've updated the located of the socket so you will have to
If you run it mutliple times you might also run into:
in which case you can you can just remove
Where
After that you can run
You can just copy the file manually like so:
and then re-run the |
I'm still new to NixOS, so I don't know how to go about implementing this..
I'm still not sure how to test this derivation locally.. I was not able to run the daemon like described in the comments above: ./result/usr/sbin/nordvpnd
2020/12/31 20:14:17 [Info] Daemon has started
2020/12/31 20:14:17 Error on listening to UNIX domain socket: listen unix /run/nordvpn/nordvpnd.sock: bind: no such file or directory and ./result/usr/bin/nordvpn status
Whoops! /run/nordvpn/nordvpnd.sock not found which basically means that systemd does not create socket.. I've tried linking service and socket files manually, but it seems that I'm unable to do so.. sudo systemctl link result/usr/lib/systemd/system/*
Failed to link unit: File /etc/systemd/system/nordvpnd.service: Read-only file system Here is how my current derivation looks like. cat default.nix
{ pkgs ? import <nixpkgs> {} }:
with pkgs;
stdenv.mkDerivation {
name = "nordvpn";
src = fetchurl {
url = "https://repo.nordvpn.com/deb/nordvpn/debian/pool/main/nordvpn_3.8.9_amd64.deb";
sha256 = "7af59ef35c0f9c6bda3ad8cab1d962b340a7a030725e857413b28f9458c950b7";
};
nativeBuildInputs = [ dpkg ];
phases = [ "unpackPhase" "installPhase" "fixupPhase" "distPhase" ];
unpackPhase = "dpkg -x $src unpacked";
installPhase = ''
mkdir -p $out/usr
cp -r unpacked/* $out/
patchelf --set-interpreter "$(cat $NIX_CC/nix-support/dynamic-linker)" $out/usr/bin/nordvpn
patchelf --set-interpreter "$(cat $NIX_CC/nix-support/dynamic-linker)" $out/usr/sbin/nordvpnd
'';
dontPatchShebangs = true;
dontStrip = true;
dontPatchELF = true;
dontAutoPatchelf = true;
} |
Today I've tried following Nixpkgs documentation: https://nixos.org/manual/nixpkgs/stable/#submitting-changes-making-patches My fork of Nixpkgs: https://github.com/domust/nixpkgs/commit/b92e6875c33b6ff9d217c8cb23be33a0efddad70 I've added the following lines to my nixpkgs.config.allowUnfree = true;
environment.systemPackages = with pkgs; [
nordvpn
]; and executed the following command: sudo nixos-rebuild switch -I /home/-/devel/nixpkgs
building Nix...
building the system configuration...
error: undefined variable 'nordvpn' at /etc/nixos/configuration.nix:52:5
(use '--show-trace' to show detailed location information) Am I missing something? I don't understand the reason behind this error, because I've added the package here: https://github.com/domust/nixpkgs/commit/b92e6875c33b6ff9d217c8cb23be33a0efddad70#diff-ab5748dc9567516fefba8344056b51ec1866adeace380f46e58a7af3d619ea22R15498 |
I think I have made significant progress today. I needed to define service module, which handles systemd services. This article helped tremendously: https://nixos.wiki/wiki/NixOS:extend_NixOS |
I managed to make some progress using your (@domust) fork as an overlay with some additional modifications:
The first two are due to Nix in general (as well as your service) assuming that With these modifications, the CLI tool and service run, but the next obstacle to solve would be |
@domust you can replace both the |
I have made changes according to @chuahou and @aanderse comments. The resulting code is here: https://github.com/domust/nixpkgs/commit/4a0edd7145826d5fdeea6aa60c63c1368b6e03c4 But unlike @chuahou, I'm still unable to run the app and verify my changes. I'm testing them using {config, pkgs, ...}:
{
# You need to configure a root filesytem
fileSystems."/".label = "vmdisk";
# The test vm name is based on the hostname, so it's nice to set one
networking.hostName = "vmhost";
# Add nordvpn group
users.groups.nordvpn = {};
# Add a test user who can sudo to the root account for debugging
users.extraUsers.vm = {
password = "vm";
shell = "${pkgs.bash}/bin/bash";
group = "wheel";
extraGroups = [ "nordvpn" ];
};
security.sudo = {
enable = true;
wheelNeedsPassword = false;
};
nixpkgs.config.allowUnfree = true;
# Enable your new service!
services.nordvpn.enable = true;
} I'm building vm with the following command while at the root of nixpkgs repository: NIXOS_CONFIG=`pwd`/vmtest.nix nixos-rebuild -I nixpkgs=`pwd` -I nixos=`pwd`/nixos/ build-vm When I run a resulting vm with |
@domust I'm not overly familiar with the correct way in NixOS yet, but I believe you need to also have
Lastly, I should probably clarify that I managed to get the service and CLI tool to run (start and produce output), but not to run correctly, as they still produce errors I unfortunately haven't been able to try fixing yet. |
@chuahou I was under impression that writing service like this allows to have one line install just like in the docker example above, especially when the software is designed to be run as a service and stand alone package is not that useful on its own. I've also added |
@domust If I'm not wrong that will install the systemd units and the software the units run (i.e. For example, for blueman these lines show adding the user executables, the DBus configuration and the systemd units respectively. |
It seems that I've hit this issue: #97305 Deleting the qcow2 image solves the problem. |
I think I know why service is dead: @chuahou Would it be possible to change the value of { fetchurl, dpkg, patchelf, stdenv
}:
let drv = stdenv.mkDerivation rec {
pname = "nordvpn";
version = "3.8.10";
src = fetchurl {
url = "https://repo.nordvpn.com/deb/nordvpn/debian/pool/main/${pname}_${version}_amd64.deb";
sha256 = "e27ba637dffc766b99161805f525b87716c8d36186d09abea61f6094af87a9fe";
};
nativeBuildInputs = [
dpkg
patchelf
];
phases = [ "unpackPhase" "installPhase" "fixupPhase" ];
unpackPhase = "dpkg -x $src unpacked";
installPhase = ''
mkdir -p $out
cp -r unpacked/* $out/
mv $out/usr/* $out
rmdir $out/usr
'';
fixupPhase = ''
patchelf --set-interpreter "$(cat $NIX_CC/nix-support/dynamic-linker)" $out/bin/nordvpn
patchelf --set-interpreter "$(cat $NIX_CC/nix-support/dynamic-linker)" $out/sbin/nordvpnd
patchelf --set-interpreter "$(cat $NIX_CC/nix-support/dynamic-linker)" $out/var/lib/nordvpn/openvpn
sed '/ExecStart/c\ExecStart=${drv}/sbin/nordvpnd' -i $out/lib/systemd/system/nordvpnd.service
'';
meta = with stdenv.lib; {
homepage = "https://nordvpn.com";
description = "Client for NordVPN";
changelog = "https://repo.nordvpn.com/deb/nordvpn/debian/pool/main/${pname}_${version}_amd64.changelog";
license = licenses.unfree;
platforms = [ "x86_64-linux" ];
};
}; in drv but got this error: I could probably avoid this problem by moving this to service derivation, but I'm not sure if it has anything like |
Right, that is because in order to evaluate |
@jtojnar's solution worked. I was able to run the service, but new problems appeared:
|
I was able to get the code at the end of my last post working by disabling the built in firewall:
and then adding |
@thornycrackers if I understand correctly, patching ELF is error prone and due to new path being longer than original, patching would require binary padding. On the other hand, using mount namespaces with FHS is easier(which is what bubblewrap can do). What I don't understand about bubblewrap is how you've managed to connect, because their README clearly states that:
Iptables should not work at all. 😕 |
The bash script that does the bind mounting won't work in it's current implementation for nordvpn. You can see my post for an explanation. Nordvpn needs write access for
This will get you a Frankenstein version of Nordvpn working, it's ugly but I haven't seen any other way to get NordLynx working on NixOS. |
@thornycrackers I think I know how to get around problem number 4. https://www.freedesktop.org/software/systemd/man/systemd.exec.html#WorkingDirectory= In short, we need a way to manage mutable application data, which for most Linux applications is stored in |
all the mainstream VPN providers expect their users to install CLOSED SOURCE software all that the client must do is login and download keys for crypto (two http requests) i recommend https://www.privateinternetaccess.com/ as VPN provider they offer multiple open source clients to get wireguard working, see #110197 |
will make a draft PR in a bit |
Today I found out, that NordVPN actually supports OpenVpn. Be aware that ipv6 is not supported and thus may leak if you connect via ipv6. I tried to disable ipv6 with |
@SrTobi could you expand on your comment? I'm asking because I just migrated into a fresh nixOS setup, and I need to mix a nordvpn and wireguard (ipv6) tunnels. |
@bernardoaraujor as far as I understand it, NordVPN (as most VPN provider) does not offer vpn support for ipv6. This would mean that when your computer determines to use ipv6 for a certain connection (like a tcp connection for a http request/response), this connection would not go through your VPN but just directly. It can chose to use ipv6 in situations where your computer, your isp, the dns server, and the targeted server all support ipv6. You can check your ipv6 status here for example: https://test-ipv6.com/. Because this would not be great for your anonymity, the NordVPN software "goes the extra mile" and blocks ipv6 (I think directly in the network interface) when the vpn is active. In that way they ensure that your whole traffic goes over ipv4 and thus over the vpn. you can read about their leak protection here. But if you are just using the normal openvpn software with a specific nordvpn server, no one is blocking your ipv6 interface and thus some connections might chose to bypass the VPN. To avoid this, I am disabling ipv6 in my wlan connection at the moment, but I think Hope that helped |
@SrTobi yea quite helpful thanks 🙏 |
regarding firewall: the UDP (source) port 51820 needs to be enabled - not sure yet how to configure it in the nixpkgs for the package though
Note: this rule may still be unstable as I hadn't tested it for a long time |
Any update on this? Would love to see this packaged. |
@Spaxly I am using the work done by the ppl in the above comments: https://github.com/svalaskevicius/nixpkgs/blob/master/pkgs/tools/networking/nordvpn/default.nix (possibly updated version) afaik, the few steps missing are:
Unfortunately, I don't think I have enough time currently to figure out how to do all that in the nixpkg - help would be appreciated! :) |
Oh alright, thanks! |
OT but working alternative to packaging the non-free app:
wgnord writes a wg-quick target to /etc/wireguard, which can be added to
See the GitHub repo for more information: https://github.com/phirecc/wgnord |
Nord released the client in source form (GPL3) at the start of the year. I'm having partial success getting it to build (Go compiler errors), but chipping away at it. That would get us a native build. |
Randomly found this on a reddit thread. Works out of the box. https://gist.github.com/myypo/31c52196f7987ef62f54092cb07aefd7 |
I managed to compile it from source here if anyone is interested: NordSecurity/nordvpn-linux#355 (comment) |
Project description
NordVPN's native app is the only way to access some of their VPN features. They provide .deb and .rpm packages, which are compatible with various Debian-based and RHEL-based systems, however I don't know enough about nix/nixpkgs to know whether we can use these in NixOS.
Metadata
The text was updated successfully, but these errors were encountered: