I am in need to build quite a lot of software in a reproducible way while being as fast as possible.
Nix seems a perfect fit, however, I do have also some other restrictions.
All the build artefact must be placed inside a specific directory, I don’t care about the name of the artefact as long as they are placed under /foo/bar/...whatever..., it cannot be /.nix/store
I need to create a specific dir structure, still under the same directory of above, something like: /foo/bar/gcc7/lib/...all_the_libraries_compiled_with_gcc7... and then /foo/bar/gcc8/lib/...all_the_libraries_compiled_with_gcc8... and then /foo/bar/gcc7/bin/...all_the_binaries_compiled_with_gcc7... and so on and so forth.
This structure is quite more complex than this one, but similar.
This structure can very well being created using symlink.
So, before I dive deeper into Nix I am wondering if it is possible at all and if it is actually practical.
My first reaction was to respond with “Nix allows for stores in
arbitrary places”, but, even if that solved your wanted directory
problem, you would lose any speed benefit because every dependency would
have to be recompiled to live in that store.
I don’t think Nix’s design allows for anything to work outside the Nix
Store. However, your requirements may be addressed with nix-shell. You
could, in theory, write a shell.nix that puts your required binaries
in scope, then (if possible inside Nix, or with a shell hook) build a
tree made of symlinks (looking at the source code for buildFHSUserEnv
may be useful, and probably tells us that the possible approach is the
shell hook).
If you really need /foo/bar to be at /, steam-run
does some additional magic with a chroot. Although it still seems weird
to put the tree directly under /, but maybe that was just for the sake
of simplification?
I don’t really care to recompile everything from scratch, as long as I need to compile it only once. I can have massive jobs that compiles everything, but it is important that is done only once.
No actually will be very very similar to /foo/bar.