How to use apt as the build input?

@AndersonTorres since you just adopted apt recently.

I’m trying to package mmdebstrap which depends on apt-get among others. When the script tests if tools are installed, apt-get keeps throwing E: Unable to determine a suitable packaging system type error, which blocked the execution:

❯ mmdebstrap
E: Unable to determine a suitable packaging system type
printf: usage: printf [-v var] format [arguments]
E: Unable to determine a suitable packaging system type
printf: usage: printf [-v var] format [arguments]
E: Unable to determine a suitable packaging system type
printf: usage: printf [-v var] format [arguments]
E: cannot find apt-get

The error message is generated here, and it appears to be unable to find a system with score > 0. The only score function is here.

However, those 3 criteria either needs to access /etc/apt/apt.conf or /etc/apt/apt.conf.d to read the configuration files before I can override them, or needs /etc/debian_version to exist. Since I can’t really install files to global /etc, apt-get is unusable as a build input.

Do you think if BIN_DIR is patched to point to dpkg Nix store in CMakeLists.txt, apt would work as input? I’m not too familiar with this code, nor how to generate dynamic patch on the fly.

1 Like

I have found a way to deal with this without patching the code:

  # apt assumes dpkg is installed under the same $BIN_DIR folder on a Debian
  # system (among a few other things), otherwise it will refuse to run with
  # the following error:
  # E: Unable to determine a suitable packaging system type
  postInstall = ''
    ln -s ${lib.getBin dpkg}/bin/dpkg $out/bin/dpkg
  '';

Edit: well there are more works to get it working. I’ll have a complete solution in my PR.

1 Like

PR is now live: mmdebstrap: init at 1.4.0 by MakiseKurisu · Pull Request #270095 · NixOS/nixpkgs · GitHub

I was already on throwing the towel, since I could not understand why this error appeared.

Hello!

May be at least default apt.conf can be added inside /nix/store?
Or it would not help because of lock file cannot be created by apt?

spiage@nixos:~/tmp/apt$ apt --version -o "Apt::System=Debian APT planner interface"
apt 2.7.12 (amd64)
spiage@nixos:~/tmp/apt$ apt --version
apt 2.7.12 (amd64)
E: Unable to determine a suitable packaging system type
spiage@nixos:~/tmp/apt$ ll /nix/store/b0csx8qwr4sl7kkbbmwyq6wamilwmlpc-apt-2.7.12/etc/apt/
итого 20
dr-xr-xr-x 2 root root 4096 янв  1  1970 apt.conf.d
dr-xr-xr-x 2 root root 4096 янв  1  1970 auth.conf.d
dr-xr-xr-x 2 root root 4096 янв  1  1970 preferences.d
dr-xr-xr-x 2 root root 4096 янв  1  1970 sources.list.d
dr-xr-xr-x 2 root root 4096 янв  1  1970 trusted.gpg.d
spiage@nixos:~/tmp/apt$ ll /nix/store/b0csx8qwr4sl7kkbbmwyq6wamilwmlpc-apt-2.7.12/etc/apt/apt.conf.d/
итого 0
spiage@nixos:~/tmp/apt$ ll debian/apt.conf*
-rw-r--r-- 1 spiage users 399 ноя  7 14:56 debian/apt.conf.autoremove

You are probably using apt from the official channel, which does not have this PR merged yet. As a result it is not usable.

Once the above PR is merged you can manage it under /etc/apt folder like on a Debian system.

Thank you!

It would be the nice way to find Debian package dependents without debootstrap+chroot :wink: or container/VM with only one command:

apt list ‘?any-version(?installed?depends(?exact-name(apt)))’