I’ve been trying to build the netclient go package (part of netmaker). See here for previous unanswered question: Go package builds but gives errors in nix-shell: failed to create symbolic link
I brought the package into my configuration.nix and it works just fine:
let
netclient = pkgs.callPackage /path/to/netmaker/netclient {};
in {
environment.systemPackages = with pkgs; [
netclient
wireguard-tools
]
};
The wireguard-tools is a runtime dependency. I’d like to mark that as such in the build so that it automatically gets installed instead of manually as I did above. After doing some googling I came up with this additional build step:
postInstall = ''
# set runtime dependencies
wrapProgram $out/bin/netclient \
--set PATH ${lib.makeBinPath [
wireguard-tools
]}
'';
but that causes errors when trying to run:
# netclient
2022/05/25 22:30:08 error running command: id -u
2022/05/25 22:30:08
2022/05/25 22:30:08 exec: "id": executable file not found in $PATH
I’m sure this is not the right way to declare it, but I don’t see any clear documentation or links on how to accomplish this.
You’re doing the right thing, I think. It’s probably trying to run the id
command from the coreutils
package. You could try supplying that. It’s not easy to search for “id” in a codebase, but it might be coming from https://github.com/gravitl/netmaker/blob/c147cc2eb92b1b3e419b0640ce4025d8ae0b1d2d/netclient/ncutils/netclientutils.go#L521
A quick search for the same function, RunCmd
, suggests there will be more of these: https://github.com/gravitl/netmaker/search?q=RunCmd
I see some things in there that’ll be parts of the system outside of Nix, so you may have to just prefix the PATH and let some of those things leak in. (You may want to do that last, though, since it’ll make it harder to find missing dependencies.)
The strange thing is that id is already working on a base system with none of these packages installed. The error also doesn’t come up if I manually install wireguard-tools.
You could try supplying that. It’s not easy to search for “id” in a codebase, but it might be coming from netmaker/netclientutils.go at c147cc2eb92b1b3e419b0640ce4025d8ae0b1d2d · gravitl/netmaker · GitHub
Nice! I had tried searching for that in the code and came up empty. I’ll try adding coreutils, and others as I trace out the remaining packages it’s trying to call manually.
I was able to find another 5 packages that needed to be added by backtracking all of the commands it calls out to and putting them into nix-store -q --tree $(readlink $(which cmd))
, where cmd was the command in question. I am happy to report that I now have a working build. Next I will integrate options for configuring the client and propose a PR to nixpkgs to help clean up what I’m sure will be a messy first timer build contribution.
1 Like