[POC] Elm json "source-directories" support
~At this moment this is only proof of concept that needs to be discussed and polished.~
Related to #6 and #19
This is an attempt to implement source-directories (elm.json) compatibility for both code generation and nix derivations.
Background
Elm make performs lookups for modules based on optional source-directories attr in elm.json file. If this attribute is not present ./src is a default destination where it looks for .elm files.
- it's possible to import
foo/A.elmwithinbar/B.elmasimport Aandimport Bif bothfooandbarare defined insource-directories - it's possible to do
elm make foo/A.elm bar/B.elmas well (as an entry). - it's possible to use any relative path like
../../baz
Implementation
Because of this, we need to use srcs instead of src. srcs attribute is currently generated in Haskell from elm.json. Paths like ../foo are also valid and needs to be supported. In the case of . (current directory) nix seems to be using the name of the current directory. This means that ["../foo", "."] within app results in 2 directories foo app. Because of changes in directories structure, new elm.json must be produced during the build - done via nix.
Details will be in source comments.
@domenkozar This is ready for a review.
principles followed:
- as simple and concise as I managed to make it
-
pkgs.mkDerivationofdefault.nixdoesn't contain any hs generated code - all project specific tab is argument defined ininblock - as much breaking changes as possible
Some of the functions are not exactly most optimal or robust (path handling mostly).
Sorry for taking this long, I've just moved over the continent and don't have immediate time to review this work. Hope you're ok waiting a few more days or so.
no worries. I'm busy as well. Take your time, there is no need to rush anything. Given the nature of these changes, I expect this to take maybe even a few weeks still
This is how it works on a project with rather complicated source-directories setting in elm.json:

That's being said this is still not good enough for merge.
What is the status of this pull request?
Also, correct me if I'm wrong, but once merged could it help us import private elm packages?
I'm not sure how you emulate private packages but if you use source-directories then yes this would solve it. But the PR is on freeze. There are few hacks that made this work and it would probably require some more discussion before being really ready. Other than that I think this PR might still work so you can try to just run elm2nix version from this.