Hi All,
Forgive me if this is supposed to be on r/nix (let me know if i should post this there) but I have recently installed NixOS and was hoping to get help on this topic.
First i just want to say that I have been reading the Nix and NixOS manuals but the learning curve is steep and Linux for me is just a hobby.
Basically I have been trying to recreate my previous Linux environment in NixOS. But I am getting tripped up when I try to install NordVPN onto my machine. I was able to find a mention of it on GitHub (https://github.com/NixOS/nixpkgs/pull/220616/files) so it looks like it will be added soon.
But I was wondering if there was any way that I could get this installed sooner instead of waiting for it to be released on a channel. Based on what I have read so far I would have thought that I would be able to download the NordVPN nix file and then build it myself and begin using it on my system. But I cant seem to find the NordVPN nix file in https://github.com/NixOS/nixpkgs and am not even sure if this is the right procedure.
I just want to understand if you were trying to deploy NordVPN (or any software where there is active work on the nixpkgs) then what is the correct procedure to follow?
Thanks
The mentioned PR has both the NixOS module (that allows you to configure the software) as well as the package definition (that allows you and the build farm to build/package the software). So until that is merged, you’re on your own.
There is however nothing preventing you from simply forking nixpkgs, applying that change and then build against that or using an overlay to apply the patch.
EDIT: another way to get it going - doesn’t nordvpn simply use openvpn and/or wireguard which we do have direct support for in NixOS. If you don’t necessarily need their GUI which that depends on your use-case(s), you might be able to get it going using either of those directly.
Hi, I’m the author of the PR
I uploaded it to NUR precisely so that it would be available sooner. However, as I wrote in the thread yesterday, as of this PR one of the components the package was relying on was deprecated. I’m still trying to make it work again using the new buildFHSEnv. However, if you’re running 22.11 or haven’t updated your local version of nixpkgs beyond that PR, it should still work.
P.S., you can still make it work with just the PR code, at least if you’re using flakes. clone nixpkgs, checkout the branch, export the module in flake.nix and add it as a flake input in your /etc/nixos. you can then import the module
Thanks for responding. I think Ill need to learn a bit more (about git as well) before I begin forking nixpkgs
Re using wg directly I think this is referring to installing NordLynx on a seperate machine, collecting the public and private keys and then using the wg-client on NixOS? Its a good idea but I dont really have a seperate linux machine so it would be a bit of a hassle to collect this info I think.
Nevertheless the first option is a good suggestion so Ill start reading up on it more.
Hey Luis,
Yes, I have actually been following your progress on github the past few days. Thanks for implementing this 
Im still quite new to nixos and just going through the manuals now so only really heard of flakes at this point. But Ill certainly be looking to implement this soon
Thanks again!
Hey Luis,
I finally got around to implementing the NUR on my machine. But I still cannot get this to work.
Your nur package runs fine but when I try to connect I get the following error
root@lenovo:/home/andrew/ > nordvpn login
Whoops! /run/nordvpn/nordvpnd.sock not found.
root@lenovo:/home/andrew/ >
As expected the nordvpnd.service is not running. When I try to run nordvpnd from the terminal (not sure if i can do that) I get the following
2023/05/06 22:14:21 Technology set to: NORDLYNX
NordVPN App Connection Settings:
Technology: NORDLYNX
Meshnet: disabled
Protocol: UDP
Firewall: enabled
KillSwitch: disabled
Obfuscate: disabled
ThreatProtectionLite: disabled
DNS:
IPv6: disabled
Notify: enabled
Auto-connect: disabled
2023/05/06 22:14:22 Error on listening to UNIX domain socket: listen unix /run/nordvpn/nordvpnd.sock: bind: no such file or directory
Im not really sure what I am supposed to do. Can you help to advise?
Thanks
So there’s a bunch of different questions here - let me break them down:
- how to run another distribution in addition to NixOS when I don’t have another machine
a. you could run it in a VM (both libvirt and virtualbox are in NixOS)
b. you can run OS container (using podman, systemd-nspawn or one of the other container projects)
c. you could spin up a VM for a few dollars a month with a cloud provider
- how do I extract a package intended for another distribution (such as a .deb or .rpm) in order to get to the files?
a. you can do nix-shell -p dpkg
and then invoke dpkg
to extract files from a downloaded package. There is also rpmextract
for rpms. 7zz might also do the trick.
And lastly, you mention NordLynx which after a quick google seems to be their custom protocol. This will not work out of the box without their software. What you need is the definition files for either wireguard or openvpn connections. I don’t use nordvpn so I don’t know what they provide but judging from the PR you linked to, it seems like they do distribute the files.
Once you have the connection files, you can:
- either invoke wireguard/openvpn manually using the files, or
- configure the wireguard/openvpn NixOS settings by looking at the connection files
Hello, I only saw this message this afternoon, sorry. Yeah, apparently this error is happening again… I tried today to fix it, but it will take a little more time than that. Probably this week or by the weekend. I’ll keep you updated 
Cheers, thanks for taking the time to respond. Ill look into this more
No worries mate, Im still new to NixOS so going through those Nix expressions helps me to understand.
Thanks again
Hey so, I finally fixed the bug, it should theoretically work, at the very least in nixos-unstable
(I’m using it right now). try it if you want. I may have got a bit too excited since this is the first FOSS thing I do that actually has users lmao
Cheers mate, Im still trying to just wrap my head around Nix the language so your contribution is appreciated.
Besides the Nix manuals did you use something in particular that you used to learn this environment?
Hey Mate,
Where is it in nixos-unstable?
I checked in https://search.nixos.org/ but was not able to find it with the unstable button. I also could not find it at https://github.com/NixOS/nixpkgs.
Im not sure if maybe Im searching in the wrong location?
Thanks
Oh, it’s not on unstable yet. I meant in NUR. Come to think of it, it shouldn’t matter whether you’re using unstable or 22.11 (which is what I meant by that), since the nixpkgs dependency is in the flake of the nur repo haha
EDIT: obvs if you’re not using flakes, your local probably matters.
Hey Mate,
Sorry, I must be doing something wrong because I still cannot get this to work.
My configuration.nix inclues the following
nixpkgs.config = {
packageOverrides = pkgs: {
nur = import (builtins.fetchTarball "https://github.com/nix-community/NUR/archive/master.tar.gz") {
inherit pkgs;
};
};
}; ... environment.systemPackages = with pkgs; { ... nur.repos.LuisChDev.nordvpn }
And i run nixos-rebuild switch --upgrade
(which I think is all that I need to do)
When I run nordvpn login I get the message ‘Whoops! /run/nordvpn.nordvpnd.sock not found.’
I try systemctl status nordvpnd but I get a service cannot be found.
When I run nordvpnd from the command i get the following
2023/05/13 12:02:25 error retrieving nameservers: cdn api: X-Accept-
Before UNIX value is lower than current local time
2023/05/13 12:02:25 group: unknown group nordvpn 2023/05/13 12:02:25 \
\[Warning\] moose: init was successful 2023/05/13 12:02:25 \[Warning\] loading country data: open /var/lib/nordvpn/data/countries.dat: no such file or directory 2023/05/13 12:02:25 Error on listening to UNIX domain socket: listen unix /run/nordvpn/nordvpnd.sock: bind: no such file or directory
Im using the nur package from https://github.com/nix-community/nur-combined/blob/master/repos/LuisChDev/pkgs/nordvpn/default.nix#L88 and I checked and confirm that when i run nordvpn --version it matches the version in your nix.
Am I doing something wrong here?
Thanks
EDIT - Im certianly no expert but it may not be this implementation at all. It just looks liek that nameserver cdn issue is the error. But I dont understand what it is referring to.
I tried adjusting the following but nothing seemed to work
- Changing my default DNS server to googles IP
- Changing my timezone to America/New_York
- Changing to ntpd (network time protocol)
I jsut cant figure out wnat the issue is here.
you shouldn’t need to change DNS settings or timezone - the DNS is set by nordvpn automatically. Ohhhhh I think I know what is the problem. You need to enable the nordVPN module as well. According to the NUR repo, you have to import
nur without the pkgs
argument again, and then add the module to configuration.nix
’s imports like this:
{ config, pkgs, ... }:
let
nur-no-pkgs = import (builtins.fetchTarball "https://github.com/nix-community/NUR/archive/master.tar.gz") {};
in {
# ...the rest of your configuration.nix
imports = [
nur-no-pkgs.repos.LuisChDev.modules.nordvpn
];
services.nordvpn.enable = true;
}
And another thing. The module makes the package available in environment.systemPackages
, but for that it needs the package the already be in nixpkgs
. so you need to add it directly to packageOverrides
. It would look somewhat like this:
{ config, pkgs, ... }:
let
nur-no-pkgs = import (builtins.fetchTarball "https://github.com/nix-community/NUR/archive/master.tar.gz") {};
in {
# ...the rest of your configuration.nix
imports = [
nur-no-pkgs.repos.LuisChDev.modules.nordvpn
];
services.nordvpn.enable = true;
nixpkgs.config.packageOverrides = pkgs: {
nordvpn = import (builtins.fetchTarball "https://github.com/nix-community/NUR/archive/master.tar.gz") {
inherit pkgs;
}.repos.LuisChDev.nordvpn;
};
}
The description of the NixOS module includes a few extra things you need to do for the service to work correctly. Hopefully it makes sense (and works, of course
). Damn, that is really quite a lot. I’m adding it all to the README file of my nur repo. Thanks for helping me unbreak the package 
Hi Luis,
Sorry, Its been a while but I really only get time to come back to this on the weekends.
Thanks for the instructions above. I was eventually able to get NordVPN working but did have some difficulty. Im not sure if it was something that I did wrong or if it is something you can update your package with.
nix-rebulid switch produces error: attribute ‘repos’ missing
I get the error above when I run the following in my configuration.nix
nixpkgs.config.packageOverrides = pkgs: {
nordvpn = import (builtins.fetchTarball "https://github.com/nix-community/NUR/archive/master.tar.gz") {
inherit pkgs;
}.repos.LuisChDev.nordvpn;
If I update to the following it works without error
nixpkgs.config.packageOverrides = pkgs: rec {
nur = import (builtins.fetchTarball "https://github.com/nix-community/NUR/archive/master.tar.gz") {
inherit pkgs;
};
nordvpn = nur.repos.LuisChDev.nordvpn;
};
nordvpn login does not work
I think this has more to do with nordvpn (or my setup) and not your package but I wanted to document it in case anyone else comes across the same issue.
To login successfully to nordvpn perform the following instructions
- `nordvpn login` will return a url
- Open the url and log into your nord account
- Copy the link of the ‘Continue’ button
- Go back to the terminal and connect to nord with the command `nordvpn login --callback “PASTE URL HERE”`
nordvpn is looking for the header key in /var/lib/nordvpn
After logging I could not connect because it was looking for the id_rsa key in /var/lib/nordvpn. But it was stored in /nix/store/…nordvpn-3.16.2/var/lib/nordvpn.
I dont understand and to correct this path so to resolve this I just copied the content from /nix/store and pasted it to /var/lib/nordvpn. I was able to connect find after this.
And finally after the past couple of weeks Reddit may now think I am posting from South Africa!
PS - Again thanks for your help on this. I hope to become more familiar with NixOS in the comining months / years.
Hello again 9mH0q7ar4Z. I’m happy it’s finally working for you
Yeah, the login issue seems to be part of the package, it also happened to me. Regarding the missing file, hmm, it was supposed to be copied to that location automatically… I’ll test it again soon.
thanks man! You really are a hero! I hope that this process can be simplified in the future, but you really helped me out here.
Btw, when I run `nordvpn connect` now I cannot send or recieve any data through the internet anymore. `ping 8.8.8.8` just becomes unresponsive. I regain internet access when I run `nordvpn disconnect`.
EDIT: I found a way to solve the “`nordvpn connect` stops internet” problem. I copied over this file into my nixos config: https://github.com/kessejones/dotfiles-nixos/blob/543756de674b4ad7e27f02991d171eb8d0956c10/hosts/desktop/modules/networking.nix (kessejones/dotfiles-nixos on github > hosts/desktop/modules/networking.nix)