Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

unclear how to use with Elixir/Pheonix projects #323

Open
brianmay opened this issue Nov 23, 2023 · 1 comment
Open

unclear how to use with Elixir/Pheonix projects #323

brianmay opened this issue Nov 23, 2023 · 1 comment

Comments

@brianmay
Copy link

brianmay commented Nov 23, 2023

Elixir projects typically have a package.json file that contains the following:

{
  [...]
  "dependencies": {
   [...]
    "phoenix": "file:../deps/phoenix",
    "phoenix_html": "file:../deps/phoenix_html",
    "phoenix_live_view": "file:../deps/phoenix_live_view"
  },
  [...]
}

This was recommended practise in fact. Due to the fact these dependencies need to be the same versions of the dependencies already downloaded by mix.

But this breaks badly when trying to build with node2nix:

error: getting status of '/nix/store/8mdp84lpjdh3h1isgipk1258d999zw82-source/deps': No such file or directory

I think this means that the deps folder is not accessible. And probably this is a good thing. Because those files could be stale, and not part of the build.

As far as I can tell, there is no way of overriding the important bits so npm can find the files.

So not sure how to solve this...

brianmay added a commit to brianmay/teslamate that referenced this issue Nov 23, 2023
This will add support for nix flakes. Which really helps with my
development on nixos. This has two basic parts:

1. DEVELOPMENT

After this you can use the following commands on computer with nix and a
patched version of direnv:

direnv allow
devenv up

And it will automatically start and instance of postgresql and mosquitto
for development.

And the environment variables are already configured for teslamate.

So then can start teslamate with:

npm install --prefix ./assets && npm run deploy --prefix ./assets
iex -S mix phx.server

This part is all working as designed. And pretty simple and straight
forward.

2. NIX PACKAGE OF TESLA

This is 99% complete, but some pain points I haven't addressed yet.
Because I don't yet know of good solutions.

* node2nix really does not like having "package.json" refer to file
  installed from mix. For my packages I changed it to pull the files
  from npm. But need to keep the versions in sync with mix. I filled a
  bug report on this: svanderburg/node2nix#323

* node2nix needs to be run every time assets/assets/package-lock.json is
  updated. Yuck.

* There is a checksum in flake.nix that needs to be updated whenever
  mix.lock changes.
brianmay added a commit to brianmay/teslamate that referenced this issue Nov 23, 2023
This will add support for nix flakes. Which really helps with my
development on nixos. This has two basic parts:

1. DEVELOPMENT

After this you can use the following commands on computer with nix and a
patched version of direnv:

direnv allow
devenv up

And it will automatically start and instance of postgresql and mosquitto
for development.

And the environment variables are already configured for teslamate.

So then can start teslamate with:

npm install --prefix ./assets && npm run deploy --prefix ./assets
iex -S mix phx.server

This part is all working as designed. And pretty simple and straight
forward.

2. NIX PACKAGE OF TESLA

This is 99% complete, but some pain points I haven't addressed yet.
Because I don't yet know of good solutions.

* node2nix really does not like having "package.json" refer to file
  installed from mix. For my packages I changed it to pull the files
  from npm. But need to keep the versions in sync with mix. I filled a
  bug report on this: svanderburg/node2nix#323

* node2nix needs to be run every time assets/assets/package-lock.json is
  updated. Yuck.

* There is a checksum in flake.nix that needs to be updated whenever
  mix.lock changes.
brianmay added a commit to brianmay/teslamate that referenced this issue Nov 26, 2023
This will add support for nix flakes. Which really helps with my
development on nixos. This has two basic parts:

1. DEVELOPMENT

After this you can use the following commands on computer with nix and a
patched version of direnv:

direnv allow
devenv up

And it will automatically start and instance of postgresql and mosquitto
for development.

And the environment variables are already configured for teslamate.

So then can start teslamate with:

npm install --prefix ./assets && npm run deploy --prefix ./assets
iex -S mix phx.server

This part is all working as designed. And pretty simple and straight
forward.

2. NIX PACKAGE OF TESLA

This is 99% complete, but some pain points I haven't addressed yet.
Because I don't yet know of good solutions.

* node2nix really does not like having "package.json" refer to file
  installed from mix. For my packages I changed it to pull the files
  from npm. But need to keep the versions in sync with mix. I filled a
  bug report on this: svanderburg/node2nix#323

* node2nix needs to be run every time assets/assets/package-lock.json is
  updated. Yuck.

* There is a checksum in flake.nix that needs to be updated whenever
  mix.lock changes.
@Munksgaard
Copy link

I've also been bitten by this. As a quick workaround, I decided to vendor the dependencies and add them to my git repository, but I'd be really interested in a better fix.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants