CppNix is a Nix-based C preprocessor.
The C preprocessor is a powerful tool, but it has some limitations. For example, it is not possible to use the C preprocessor to generate a list of files in a directory. CppNix is a custom preprocessor that is more flexible and extensible.
Is it a good idea? Probably not, but it's fun.
CppNix comes with a setup hook that intercepts cc1
invocations to perform extra preprocessing.
It also configures the environment to allow Nix itself to run in the build sandbox.
See ./example for an example of how to use CppNix in a Nix build and dev shell.
$ nix build .#example
$ nix develop .#example
$ cd example/src
$ make
$ ./example