init dream2nix integration templates + tests #8
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 initializes templates for integration with dream2nix and adds a test that can be executed via:
nix run .#dream2nix-integration-test
.I do not intend to complete this PR, but it can serve as a starting point for whoever wants to take on the work, and can be used for discussions.
The templates for the translator and builder are largely just copied from
dream2nix/src/templates/...
, and contain only minor modifications.Usually we commit the modules for ecosystem support like these, directly to the dream2nix source itself, but as I understood you, @cdepillabout, the intention is to keep the stacklock2nix project separate. Therefore the PR adds the dream2nix modules to the stacklock2nix project itself and exposes them via the flake outputs. Feel free anytime to move this whole project inside dream2nix and maintain it from there, if you feel comfortable with that.
Some comments in the templates contain references to other files, like examples or specifications. Those references are relative to the source of the upstream dream2nix project.
In general, some more detailed guide on contributing ecosystem support to dream2nix can be found here
Short Summary
The purpose of the translator is to extract data from any given project source (by parsing the stack.yaml.lock for example) and return the extracted data via the dream-lock format, which is JSON serializable.
The specification of the dream-lock format can be found at dream2nix/src/specifications
A successful termination of the .#dream2nix-integration-test app implies that the dream-lock format produced by the translator is correct.
The purpose of the builder is to read the data represented by the dream-lock and generate nix
packages
anddevShells
from it.The builder accesses the dream-lock indirectly through getter functions like
getDependencies
etc. which are provided by dream2nix (see builder template below).Now there is a clean way and a dirty way of integrating stacklock2nix into dream2nix.
The dream-lock format contains fields like
dependencies
andsources
, for which the format is strict. If those fields are used, it will:inject
andsourceOverrides
allowing the user to manipulate the the dependency tree and sourcesBesides these strict fields, the dream-lock also offers the
_subsystem
field, which can be used as a free-form field. So the quick and dirty way would be to ignore some fields of the dream-lock and instead put data into_subsystem
. That would work around some of the requirements of dream2nix but kill some features and general compatibility with other haskell modules.It would be great to do it the clean way, so we can re-use the stacklock2nix builder for example with other translators like
cabal-plan
etc. and we won't have to do the work twice.Feel free to comment if you have any more questions.