Per file derivations with C++

You may be interested in GitHub - edolstra/nix-ccache: A flake to remotely build and/or cache C/C++ compilation, using recursive Nix, which provides a gcc wrapper that runs the input through the preprocessor and then uses a Nix derivation to perform the actual compilation. This enables caching and distributed builds similar to ccache (hence the name - it doesn’t actually use ccache).

There is also the ancient https://github.com/edolstra/nix-make which provides functions for building C/C++ source files, using some import-from-derivation magic to figure out the header file dependencies automatically.

5 Likes