Install `openvpn` and `openvpn_24` alongside

Hello. I would like to have two links in system path: openvpn and openvpn_24, former working as usual, latter pointing to /nix/store/hash-openvpn_24/bin/openvpn. Is this possible?

IMO you didn’t really specify what you want with it, but e.g.

$ nix-build '<nixpkgs>' -QA openvpn_24

(you may be using nixos as the channel name instead of nixpkgs or whatever you’ve put there)

Ahh, I’m sorry, you wrote you want to have it in system path. In configuration.nix you can do

environment.systemPackages = [ pkgs.openvpn_24 ];

which should be independent of your services.openvpn options. Though I’m still unsure of what you want.

Just putting both on system path won’t help due to them having the same bin/openvpn, so you’d have to use some wrapper that gives them new names or something.

Just putting both on system path won’t help

That’s why I said that I want a link openvpn_24 pointing to /nix/store/hash-openvpn_24/bin/openvpn. I hoped there is a way to overrideAttrs or tweak environment.* to produce a link with different name.
For some reason I didn’t think of creating a wrapper, so thanks for reminding me of that. I guess I’ll go with that.

OK, now I see what you meant. Tested example:

environment.systemPackages = [
  (with pkgs; runCommandNoCCLocal {} ''
    mkdir -p "$out/bin"
    ln -s '${openvpn_24}/bin/openvpn' "$out/bin/openvpn_24"
1 Like

Thank you :slight_smile: I ended up with this:

> cat /etc/nixos/openvpn_24-wrapper.nix
{ runCommandNoCCLocal, openvpn_24 }:
runCommandNoCCLocal "openvpn_24-wrapper" {} ''
  mkdir -p "$out/bin"
  ln -s '${openvpn_24}/bin/openvpn' "$out/bin/openvpn_24"

and (callPackage ./openvpn_24-wrapper.nix {}) in environment.systemPackages.

If not for you, I would use script wrapper, creating indirection. This is better.

Hosted by Flying Circus.