Dependency resolution by Nix?

Hello everybody,

With the aim of reducing the size of a container (with nix2container), I am testing direct copying of libraries.
I’m surprised to see that some packages are added when I don’t see any dependencies.
Example :

If i copy file, ceph-18.2.0-lib is added to the container (with all its dependencies).

$ldd /nix/store/*-ceph-18.2.0-lib/lib/ceph/ | awk '{print $1}'

None of these libraries depend on Ceph, of course

If i do the same exercise with file, ceph-18.2.0-lib is not added to the container

$ldd /nix/store/wya455l9sfccbbdqz1l5b51wd708fl3n-ceph-18.2.0-lib/lib/ceph/crypto/ |awk '{print $1}'

The test is very basic :

    cephfs_min = {
        layer = nix2container.buildLayer {
            copyToRoot = pkgs.runCommand "cmd" {} ''
                # cp /nix/store/wya455l9sfccbbdqz1l5b51wd708fl3n-ceph-18.2.0-lib/lib/ceph/ $out
                cp /nix/store/wya455l9sfccbbdqz1l5b51wd708fl3n-ceph-18.2.0-lib/lib/ceph/crypto/ $out

            deps = [ ];
            layers = [ ];
        paths = [ ];

Does Nix use anything other than ELF to identify dependencies?

Thank you for your feedback

If I’m not mistaken, it seems that Nix looks for references directly in the binaries =>

So it may be necessary to compile outside of Nix

Clearly not recommended if the effects/dependencies are not controlled but in fact, a sed on the lib and the dependencies disappear :

# /nix/store/wya455l9sfccbbdqz1l5b51wd708fl3n-ceph-18.2.0-lib/
sed -bi 's/wya455l9sfccbbdqz1l5b51wd708fl3n/aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/g'