halfzebra/create-elm-app

Doesn't work on NixOs

Opened this issue · 9 comments

Feel free to close if irrelevant but I have no idea what's happening with this.

Link to thread on discourse with details:
https://discourse.nixos.org/t/elm-0-19-development/867

Hi @lolcookie!

Thanks for reporting this issue. I have an idea on fixing this, but I'm not entirely sure if it's a good one.

We could provide an option to supplement the path to the elm binary using env variable(for starters)

Example:

ELM_PATH=/usr/bin/elm create-elm-app

Alternatively, it could be replaced by a flag.

What do you think?

From what I understand the issue comes from bundling a binary inside an npm package, has there been much more thought to having the elm installed on path as a requirement to use create elm app?

I experimented with this a bit today. I don't think adding an environment variable would help, as the NixOS build is actually failing on installing elm with npm (it never gets to create-elm-app.) I don't have much nix experience, and this is the first time I've ever used node2nix, so take my opinion with a grain of salt.

If node2nix has a way to chain dependencies that it has overridden, we may be able to get this to work; either by patching binwrap (used by elm npm package), or patching the elm npm package itself. I have no clue how that might be done though.

For people that just need to get create-elm-app working, there is a way to brute force it: https://gist.github.com/jhillyerd/df925d0d675ce13de006f9b002aeea1b

Hello @lolcookie and @jhillyerd!

I agree that there is a problem with Elm Compiler distribution, which is included into this package.

Unfortunately, it seems like there is no other obvious way to fix this other than to remove the compiler from Create Elm App dependencies.

The original motivation for creating CEA was to have a single CLI tool to cover the basic needs of working with Elm for beginners, but the times have changed, and requirements have changed.

This change would imply that people will have to install the following to get going:

npm install elm create-elm-app -g
npm install elm create-elm-app --save

Should Create Elm App remove Elm Compiler from dependencies and require a separately installed npm distribution of Elm Compiler?

I have doubts whether Create Elm App should be supported on operating systems which require a custom Elm Compiler distribution, but maybe it is enough to move it to peerDependencies?

I'm not saying no to the idea, but we need to have more feedback from the community. Please raise awareness of this issue and if there's enough interest towards this, I think it would help to make a decision.

Another idea: NixOS can apply patches when i t builds a package. What if ${someone_good_at_nixos} were to patch elm out of the create-elm-app packages.json file during the build?

Edit: I've been getting some practice with nix packaging, may be able to tackle this myself in the near future. I'm not sure if they will include in NixOS, but it would likely still be enough for something to build from the repo themselves with 1-2 commands.

Should Create Elm App remove Elm Compiler from dependencies and require a separately installed npm distribution of Elm Compiler?

The main entry point for elm is the user guide. Anyone who followed that will know how to install elm. Given that I don't think create-elm-app needs to make this easier.
Maybe it would be worth mentioning in the readme that create-elm-app shouldn't be used before having started with the elm guide.

@dawehner I doubt the elm user guide and its instructions about installation will be helpful for NixOS configuration ;)

I was able to resolve the binwrap issue with elm instalation but there similar issue with elm-test which is even harder to resolve. Elm test depends on elmi-to-json so dependecy of dependency would need to be patched and so far I was unable to find a way how to do it.

Given I'm not using this package myself I'm passing this. If anyone else would want to try to fix this see this file and let me know if I can assist somehow. I'm also skeptical about adding this to nixpkgs when looking to the enourmous scope of dependecies this has.

I spent few more hours trying to make it work but I can't even found which revision in git actually matches the version that npm downloads so I was unable to define patches which will make this work with pure nix build.

For people who need to make this work no matter what just use npm prefix hack:

$ mkdir ~/mutable_node_modules
$ npm config set prefix ~/mutable_node_modules 
$ npm install -g create-elm-app