Added nix flake support for reitti #729
Closed
+386
−10
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This PR adds nix flake support to reitti.
It provides a dev shell with the basic tools needed to compile and build the application, can be used to build the jar and a docker image.
There are some limitations (see top of flake.nix). These limitations lead to different outputs based on whether nix was used to build or github-actions/maven.
Most notable is that the git info which the maven commit id plugin generates is not available and thus will not be shown correctly:
This is because the nix sandboxed environment does not keep the .git folder in order to provide better reproducibility.
Thus the maven commit id plugin has no git folder to work with and needs to be patched out during build phase.
Additionally the tests are patched out as they interfere with the sandboxed environment and will fail. This means that tests are NOT done when running this flake at all.
Additionally the reproducibility nix normally provides is broken by the contributors list and thus this is an impure build.
This is because the github api does not provide contributors for up until a given commit.
Thus we need to use the impure flag:
nix build .#<jar|docker> --impure==== Note ====
Feel free to decline this PR. It is just meant as an offer for everyone using nix to help nixify this project too.
I fully understand that this might be something you do not want to keep in the project given that it might need future adaptations to keep in sync with the rest of the project.
I will keep this branch on my fork nevertheless and thus hopefully provide some guidance for people who want to use nix.
As I am also fairly new to nix myself I cannot guarantee this is up to the best practices of nix and like to take criticism on it if anyone finds the potential to enhance this further!