I am trying to wrap the jupyter package with LD_PRELOAD of a library to mitigate a bug that occurs on nix-on-droid, which is roughly described in this discussion: Permission denied (src/ip_resolver.cpp:542) · Issue #248 · termux/proot · GitHub. I have added a package for this library and an overlay to add it to my pkgs. I am also able to build the library and when I manually invoke jupyter notebook with LD_PRELOAD set to the resulting library it indeed works and mitigates this bug.
Now I wanted to wrap the jupyter package using wrapProgram
, so that it works automatically, my configuration.nix looks like this:
# configuration.nix
environment.packages = with pkgs; [
(jupyter.overrideAttrs (previousAttrs: {
installPhase = (previousAttrs.installPhase or "") + ''
wrapProgram $out/bin/jupyter --set LD_PRELOAD "${pkgs.skip_getifaddrs}/bin/skip_getifaddrs.so"
'';
}))
];
The definition of the package is as follows:
# pkgs/skip_getifaddrs/default.nix
{
stdenv,
fetchzip,
...
}:
stdenv.mkDerivation {
pname = "skip_getifaddrs";
version = "1.0.0";
src = ./.;
buildPhase = ''
$CC skip_getifaddrs.c -o skip_getifaddrs.so -shared
'';
installPhase = ''
mkdir -p $out/bin
cp skip_getifaddrs.so $out/bin/skip_getifaddrs.so
'';
}
// pkgs/skip_getifaddrs.c
#include <errno.h>
#include <ifaddrs.h>
int getifaddrs(struct ifaddrs **ifap) {
errno = EOPNOTSUPP;
return -1;
}
nix-on-droid builds my configuration and it also contains jupyter notebook, but it does not seem to be wrapped with the correct LD_PRELOAD
, as the kernel does not start, like it is described in the Github discussion I mentioned.
I’ve also tried doing the wrapping in postFixup
and installPhase
, but this doesn’t seem to be the issue. What is a little bit mysterious to me, is where the actual derivation for jupyter is defined, as the package search lists the cpython derivation under source - could this be where the problem is?
As this is my first try at writing a package, my first try of using overlays and also in general pretty early in my Nix-journey I am not sure how to find out what is going wrong here. If you need any other information I would be glad to provide it and I would be happy about any suggestions for how to debug a problem like this or where to learn more about all the different systems involved here. Thanks!