Bug #406
opensplitted system packages in isolated prefixes
Description
Hi,
I'm wondering if and how we could use splitted system packages in isolated prefixes.
Here is an example on archivers/bzip2/depend.mk. Both RedHat and Debian provide one package for the executable, and another one for the header, but they are installed in the same prefix, so SYSTEM_SEARCH.bzip2 is happy to find this prefix.
But with package managers that isolate each package, and which also split this kind of package, we get eg. on NixOS:
$ tree $PREFIX_BZIP2 /nix/store/b0gdx2hz2nyf9ap2n0zixczc7k2kqk9j-bzip2-1.0.8-bin └── bin ├── bunzip2 -> bzip2 ├── bzcat -> bzip2 ├── bzcmp -> bzdiff ├── bzdiff ├── bzegrep -> bzgrep ├── bzfgrep -> bzgrep ├── bzgrep ├── bzip2 ├── bzip2recover ├── bzless -> bzmore └── bzmore 2 directories, 11 files $ tree $PREFIX_BZIP2_DEV /nix/store/kh542xlg6mgb14xwz22mvqpm8810aidp-bzip2-1.0.8-dev ├── include │ └── bzlib.h ├── lib │ └── pkgconfig │ └── bzip2.pc └── nix-support └── propagated-build-inputs 5 directories, 3 files
Therefore, building pkgtools/pkg_install fail with:
Missing system package bzip2: searching in /nix/store/kh542xlg6mgb14xwz22mvqpm8810aidp-bzip2-1.0.8-dev missing: /nix/store/kh542xlg6mgb14xwz22mvqpm8810aidp-bzip2-1.0.8-dev/bin/bzip2 searching in /nix/store/b0gdx2hz2nyf9ap2n0zixczc7k2kqk9j-bzip2-1.0.8-bin found: /nix/store/b0gdx2hz2nyf9ap2n0zixczc7k2kqk9j-bzip2-1.0.8-bin/bin/bzip2 missing: /nix/store/b0gdx2hz2nyf9ap2n0zixczc7k2kqk9j-bzip2-1.0.8-bin/include/bzlib.h Please install the Ubuntu package bzip2 libbz2-dev. - SYSTEM_PREFIX or PREFIX.bzip2 can be set to the installation prefix of this package in robotpkg.conf. - If no bzip2 package can be made available in your system, you can use the robotpkg version, by setting in robotpkg.conf PREFER.bzip2= robotpkg
I guess one option would be to split this package on robotpkg… But I think that's way too much work for nothing.
Another option is to define that we don't support this use case, and it would be fine for me. And in the case of bzip2 here, I can just follow the instructions and PREFER.bzip2=robotpkg.
But if you have other options in mind, which would not require a ton of work, and would allow me to use my system packages, feel free to share !
Best,
Guilhem
Updated by Anthony Mallet 10 months ago
/nix/store/kh542xlg6mgb14xwz22mvqpm8810aidp-bzip2-1.0.8-dev
├── include
│ └── bzlib.h
├── lib
│ └── pkgconfig
│ └── bzip2.pc
└── nix-support
└── propagated-build-inputs
So this particular bzip2-dev package splits headers and libraries?
While it makes sense to split bzip2 "tools" and "libraries", as
e.g. on debian with bzip2 libbz2-dev I don't really get the benefit of
this extra split. It seems even a bit unsafe, in the sense that you
could mix headers and libraries from different versions?
For bzip2 in robotpkg, it would also make sense to have split bzip2
and libbz2 packages, especially since the bootstrap only requires the
latter (I think).
I guess one option would be to split this package on robotpkg… But I
think that's way too much work for nothing.
It all depends on how many packages are involved. If all Nix packages
have separate headers and libs, yes, it's a bit overwhelming.
If it's only for packages that have both "tools" and "libs" then I
think it's cleaner and not too invasive.
But if you have other options in mind
Not really at the moment, and I am even a bit reluctant to handle different
prefixes for headers and libs for the same package, since the goal of
the 'system search' script was to expliticly avoid this situation :)
E.g. when you have /foo/pkg-1.0 and /bar/pkg-2.0, you don't want
headers from the first beeing used with the second ...
There's no way in Nix to configure a shared prefix for groups of
packages that must be consistent?
Updated by Anthony Mallet 10 months ago
It's also easy to have different 'depend.mk' files in robotpkg even if
a package is not split.
Keeping the bzip2 example, there could be a 'depend-tool.mk' and
'depend-libs.mk'. The key used in 'DEPEND_USE' doesn't have to match a
package name, it's only a key to access 'DEPEND_ABI.key' (which
contents must match a robotpkg pkg name) and similar variables. So the
depend-*.mk files can use different keys and still refer to the same
robotpkg package when configured as PREFER.bzip2= robotpkg.
Updated by Guilhem Saurel 10 months ago
I see, thanks for your inputs !
I don't know how many packages are splitted in nix. I guess a lot.
I'll probably give depend-*.mk a try, at least on a couple system packages.
And yes, the point is to allow multiple versions of the same packages in /nix/store. The user is expected to activate only the prefixes of the version they want when they want. Obviously, the tooling makes this use easy enough, and it's almost impossible to activate multiple versions of the same package in the same environment by accident.
The goal is the opposite to be "a bit unsafe", as it easily allow fully reproducible builds, in a build system which is pure and written in functionnal way.
I'll probably cover this in a talk at 2RM :)
Updated by Anthony Mallet 10 months ago
On Tuesday 12 Mar 2024, at 15:06, Guilhem Saurel wrote:
And yes, the point is to allow multiple versions of the same
packages in /nix/store.
The point I was raising was rather about mixed headers and libs from
the same package. E.g. foo-libs-1.0 vs. foo-headers-2.0. I don't see a
useful use case where mixing them would give any benefit?
Updated by Guilhem Saurel 10 months ago
having them in your /nix/store is not the same as mixing them. You can have foo-libs-1.0 and foo-headers-2.0 at the same time on you hard drive, without using them simultaneously in your current environment
Updated by Anthony Mallet 10 months ago
On Tuesday 12 Mar 2024, at 20:16, Guilhem Saurel wrote:
having them in your /nix/store is not the same as mixing them. You
can have foo-libs-1.0 and foo-headers-2.0 at the same time on you
hard drive, without using them simultaneously in your current
environment
Sure. But if you can set independant prefixes in robotpkg (or any
build system) for the two, then you can easily mix them by mistake.
Updated by Guilhem Saurel 10 months ago
If you declare them manually, yes, clearly. But this would be super tedious to do this manually by handling those horrible hashes anyway.
This is supposed to be used from a source generated by a purely functional declarative system, which prevent such kind of mistake.