back

by elesiuta·3y ago·view on hn ↗
I have had a similar experience packaging a simple python program, coming from zero packaging experience. PKGBUILD was the first I did and by far the easiest, deb was about 3x more time and effort, and rpm was a bit more time and effort still, despite now having experience with the other two. I wanted to package for nix next, but got stuck due to the program daemonizing and can no longer import its dependencies.
1 comments
What's the program you wanted to package for Nix? I'd like to know more about what you mean about daemonizing being a problem.
It's picosnitch, if you know what I'm doing wrong/how to fix it that'd be great! It depends on bcc and psutil, and I am able to build and run it from a .nix file using python3.pkgs.fetchPypi with

  nix-build -E 'with import <nixpkgs> {}; callPackage ./picosnitch.nix {}'
  sudo -E ./result/bin/picosnitch start-no-daemon
However, when I run it with just start, it can no longer find psutil and bcc. It uses a daemon class here [1].

I also encounter the same issue when running it without sudo, since it will re-execute itself here [2].

It can also use systemd, but I didn't get around to figuring out how to use systemd and install the service file on nix (I've never used nix before and know very little).

[1] https://github.com/elesiuta/picosnitch/blob/master/picosnitc...

[2] https://github.com/elesiuta/picosnitch/blob/master/picosnitc...

All nix packages are self-contained ("portable" in Windows parlance), programs don't get a default working PATH. You need to craft PATH yourself, usually using wrapProgram.
Thanks! I didn't know about wrapProgram, that sounds exactly like what I need.
If you run into new issues with the package in trying to leverage wrapProgram, feel free to open a thread on discourse.nixos.org and also to @ me there!

Picosnitch seems like a nifty utility and it's awesome that you've taken up that packaging effort to make your work more available for users of so many distros. :)

Thank you for the kind words and your offer! I did run into some new issues so I'll be taking you up on it shortly.