Debuild could not work on nixos

It prompts that the ‘dpkg-architecture -f’ could not be executed, anyone met this issue before? Thanks!

$ debuild -uc -us -b
Can’t exec “dpkg-architecture”: No such file or directory at /nix/store/zx5mg2aw9fqaasp6c1csibh5rcxlkyy2-dpkg-1.22.10/lib/perl5/site_perl/Dpkg/IPC.pm line 312.
.debuild-wrapped: error: unable to execute dpkg-architecture -f: No such file or directory
.debuild-wrapped: error: dpkg-architecture -f subprocess returned exit status 255

$ dpkg-architecture -f
DEB_BUILD_ARCH=amd64
DEB_BUILD_ARCH_ABI=base
DEB_BUILD_ARCH_BITS=64
DEB_BUILD_ARCH_CPU=amd64
DEB_BUILD_ARCH_ENDIAN=little
DEB_BUILD_ARCH_LIBC=gnu
DEB_BUILD_ARCH_OS=linux
DEB_BUILD_GNU_CPU=x86_64
DEB_BUILD_GNU_SYSTEM=linux-gnu
DEB_BUILD_GNU_TYPE=x86_64-linux-gnu
DEB_BUILD_MULTIARCH=x86_64-linux-gnu
DEB_HOST_ARCH=amd64
DEB_HOST_ARCH_ABI=base
DEB_HOST_ARCH_BITS=64
DEB_HOST_ARCH_CPU=amd64
DEB_HOST_ARCH_ENDIAN=little
DEB_HOST_ARCH_LIBC=gnu
DEB_HOST_ARCH_OS=linux
DEB_HOST_GNU_CPU=x86_64
DEB_HOST_GNU_SYSTEM=linux-gnu
DEB_HOST_GNU_TYPE=x86_64-linux-gnu
DEB_HOST_MULTIARCH=x86_64-linux-gnu
DEB_TARGET_ARCH=amd64
DEB_TARGET_ARCH_ABI=base
DEB_TARGET_ARCH_BITS=64
DEB_TARGET_ARCH_CPU=amd64
DEB_TARGET_ARCH_ENDIAN=little
DEB_TARGET_ARCH_LIBC=gnu
DEB_TARGET_ARCH_OS=linux
DEB_TARGET_GNU_CPU=x86_64
DEB_TARGET_GNU_SYSTEM=linux-gnu
DEB_TARGET_GNU_TYPE=x86_64-linux-gnu
DEB_TARGET_MULTIARCH=x86_64-linux-gnu

nix-shell -p dpkg debian-devscripts?

EDIT: I peaked at the perl script, it looks like it cleans the PATH. Did you try --preserve-env?

It is the same error.

$ debuild -b --preserve-env
Can’t exec “dpkg-architecture”: No such file or directory at /nix/store/zx5mg2aw9fqaasp6c1csibh5rcxlkyy2-dpkg-1.22.10/lib/perl5/site_perl/Dpkg/IPC.pm line 312.
.debuild-wrapped: error: unable to execute dpkg-architecture -f: No such file or directory
.debuild-wrapped: error: dpkg-architecture -f subprocess returned exit status 255

How can I reproduce it? I suppose I need to run this command inside a debian package source directory, right?

environment.systemPackages = with pkgs; [
debian-devscripts
dpkg
gcc14
];

git clone git@github.com:binli/sl.git
cd sl
debuild --no-lintian -uc -us -b

Try debuild --set-envvar=PATH=$PATH, it seems to work for me.

Anyway, the issue is that this script tries really hard not to use PATH, for some reason: even with --preserve-env it purposefully ignores it. Then what happens is that it fails completely on NixOS because it tries to use this hardcoded PATH: /usr/sbin:/usr/bin:/sbin:/bin:/usr/bin/X11.