Mic92
January 27, 2021, 10:42pm
1
Many projects have shell scripts with shebangs to absolute executables i.e. /usr/bin/python
.
Patching all those instances can be tedious and annoying.
That’s why I build envfs fuse filesystem.
envfs is mounted to /usr/bin and returns for symlinks based on what is the process PATH environment variable:
$ ls -l /usr/bin/{bash,python}
lr----x--t 0 root 1 Jan 1970 /usr/bin/bash -> /nix/store/j37555sj2w3xsql3f8qrwbaim7pv67hg-bash-interactive-4.4-p23/bin/bash
lr----x--t 0 root 1 Jan 1970 /usr/bin/python -> /home/joerg/.nix-profile/bin/python
$ cat > foo.py <<EOF
#!/usr/bin/python
print("hello world")
EOF
$ chmod +x ./foo.py
$ ./foo.py
hello world
Set up instruction are on the project page.
Cheers!
23 Likes
Atry
November 3, 2023, 12:00am
2
Looks interesting! I wonder if it could also support customized environment variables, not only PATH
, so that we can build a /usr/lib
to solve Any way for LD_LIBRARY_PATH to *not* break nix-env's absolute paths for dynamic libs · Issue #902 · NixOS/nix · GitHub
Essentially it can be used to implement LD_FALLBACK_PATH
like glibc: implement `LD_FALLBACK_PATH` environment variable by oxij · Pull Request #248547 · NixOS/nixpkgs · GitHub while not having to patch glibc
Mic92
November 8, 2023, 8:48am
3
nix-ld is solving this gap for me.
Atry
November 11, 2023, 5:19am
4
Mic92
November 12, 2023, 8:14am
5
Try out nix-ld-rs , which doesn’t pollute child processes with LD_LIBRARY_PATH
1 Like