build: add initial nix build system #277
Draft
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.
why?
nix is a language-agnostic build system that is purely functional;
a "package" is a function which accepts inputs (src code, config, etc)
and produces an output (binaries, a jarfile, documentation, anything)
one benefit of this is reproducibility. if you specify your inputs precisely,
and take care not to introduce impurities, you will receive byte-for-byte,
the exact output as someone else running the same function over the
same inputs.
gradle is not a functional build system. oneconfig produces highly variable
outputs depending on a host of impure inputs, including:
by using nix we can solve these problems by using it to control
the inputs we use when building polyfrost projects. this is useful
for both development and packaging.
when run on oneconfig (hopefully), it will record all dependencies
for both the build environment and the project, and provide a nix
expression to run the build. the build itself is run in a secure sandbox,
where only content-tracked network requests are allowed to fetch
dependencies, and a local maven repo is created on-the-fly to
host the dependency artifacts somewhere gradle can resolve them
(using nix's package management)
we can use this to:
using/building polyfrost projects and CI/CD pipelines
to distribute a project on a package manager)
uninix gradle and the implementation isnt fully done yet (hence the draft) but i think this would be cool to implement in polyfrost projects.