Runtime alternative to `patchelf --set-interpreter`

     system.activationScripts.ldso = lib.stringAfter [ "usrbinenv" ] ''                       
       mkdir -m 0755 -p /lib64                                                                
       ln -sfn ${pkgs.glibc.out}/lib64/ld-linux-x86-64.so.2 /lib64/ld-linux-x86-64.so.2.tmp   
       mv -f /lib64/ld-linux-x86-64.so.2.tmp /lib64/ld-linux-x86-64.so.2 # atomically replace 
     '';                                                                                      

does the trick, making /lib64/ld-linux-x86-64.so.2 the third FHS exception after /bin/sh and /usr/bin/env
Currently I see no better solution

2 Likes