nix-community / npmlock2nix

nixify npm based packages [maintainer=@andir]
Apache License 2.0
130 stars 42 forks source link

lockfile v2 #146

Closed mkhl closed 1 year ago

mkhl commented 2 years ago

an ugly attempt at getting started with lockfile v2 support

patching shebangs probably doesn't work: npm install doesn't treat the lockfile as frozen and npm ci removes node_packages before fetching packages, and the hook with it

related to #140

andir commented 2 years ago

@mkhl Thanks for picking this up. I'll try to give it a go in one of the coming days. This might be a first step towards supporting lockfiles v2 (and newer npm?).

I am guessing this will still fail on any package that requires any of our patch hooks, correct?

mkhl commented 2 years ago

I am guessing this will still fail on any package that requires any of our patch hooks, correct?

correct. npm ci removes the node_modules folder along with our hooks, while npm install will not treat the lockfile as frozen. i'm thinking of writing a facade to npm that'll invoke the hooks after installation but i need to find more time for that.

andir commented 2 years ago

i'm thinking of writing a facade to npm that'll invoke the hooks after installation but i need to find more time for that.

That is exactly what I was thinking of. Bonus points for creating an upstream issue and explaining the situation. I doubt that we are alone (think Bazel etc..).

hlolli commented 2 years ago

I gave your pr a try, fails with nodejs 16. It's when calling npmlock2nix.build with installPhase that is just an echo. Perhaps when I don't specify buildPhase, it starts doing something strange.

@nix { "action": "setPhase", "phase": "patchPhase" }
patching sources
@nix { "action": "setPhase", "phase": "updateAutotoolsGnuConfigScriptsPhase" }
updateAutotoolsGnuConfigScriptsPhase
@nix { "action": "setPhase", "phase": "configurePhase" }
configuring
no configure script, doing nothing
@nix { "action": "setPhase", "phase": "buildPhase" }
building
/nix/store/0qlq4s175mzlx9g0aqcdk95j92g1z7mf-stdenv-darwin/setup: line 1364: $TMP/preinstall-env: ambiguous redirect
hlolli commented 2 years ago

ok so I have symbols in my derivation name which are being converted to question mark signs, causing question marks in TMP environment variable, causing ambiguous redirect in bash. Not sure why it doesn't happen on master.

edit: made a PR, seems unrelated but this is breaking for me at least, maybe others milages vary on this https://github.com/mkhl/npmlock2nix/pull/1

edit2: with these changes in my PR your changes are working without hiccups

andir commented 1 year ago

This shouldn't be required anymore as we've just merged #166.