Patchelf called with dontPatchElf flag set

I’m trying to make an expression that fetches two statically linked binaries and I want to avoid messing with the executables. Setting the dontPatchElf option removes calls to patchelf in the post-installation fixup stage, but there’s still another call (per file) at a later point:

unpacking source archive /build/jotta-cli-0.6.18626_linux_x86.tar.gz
building '/nix/store/0q7dmmal48fr8gcrgb141szxid65ndcc-jotta-cli-0.6.18626.drv'...
unpacking sources
unpacking source archive /nix/store/17k1y2j9m0w17n0z9vf70m40d9kbckyh-source
source root is source
patching sources
no configure script, doing nothing
no Makefile, doing nothing
post-installation fixup
strip is /nix/store/sc8xmj2am32c8zvc4f7572g8r5cyxw91-binutils-2.31.1/bin/strip
stripping (with command strip and flags -S) in /nix/store/if895x3bvlx2wmvc8wzwr8gjfb6xndh9-jotta-cli-0.6.18626/bin
patching script interpreter paths in /nix/store/if895x3bvlx2wmvc8wzwr8gjfb6xndh9-jotta-cli-0.6.18626
checking for references to /build/ in /nix/store/if895x3bvlx2wmvc8wzwr8gjfb6xndh9-jotta-cli-0.6.18626...
patchelf: cannot find section '.dynamic'. The input file is most likely statically linked
patchelf: cannot find section '.dynamic'. The input file is most likely statically linked

This doesn’t break the build nor change the binaries (I assume), but it’s noisy and misleading (with respect to the dontPatchElf option). Does anyone know what stage this is, whether or not it is intentional, and how I may go about fixing it?

Expression used to produce the output above:

{ stdenv, fetchzip }:

  arch = "x86";
stdenv.mkDerivation rec {
  pname = "jotta-cli";
  version = "0.6.18626";
  src =
    fetchzip {
      url = "${arch}/jotta-cli-${version}_linux_${arch}.tar.gz";
      sha256 = "0jmkjrcac1z1lnyxwqfhvhb6df0xma5famcjdhjnhv96cq70iv3q";
      stripRoot = false;

  installPhase = ''
    install -D usr/bin/jotta-cli usr/bin/jottad -t $out/bin/

  dontPatchELF = true;

  meta = with stdenv.lib; {
    description  = "Jottacloud CLI";
    homepage     =;
    downloadPage =;
    maintainers  = with maintainers; [ evenbrenden ];
    license      = licenses.unfree;
    platforms    = [ "i686-linux" ];

I’m using Nix 2.2.2.

1 Like

It isn’t actually trying to patch the ELF. It’s coming from auditTmpdir, which just tries to examine the RPATH.

You can verify that yourself, by setting noAuditTmpdir = true in your derivation. Then the warning should be gone.

1 Like

Thanks! Sounds like I should leave this as is and just ignore the warnings, then?


Otherwise the best solution would be to add a --silent flag to ignore the error in patchelf and use that in auditTmpdir.

1 Like

Thanks, I opened an issue for this.