nix-community / npmlock2nix

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

feat: allow to set package-name and version #104

Open milahu opened 3 years ago

milahu commented 3 years ago

continue #102

name and version can be missing in package-lock.json, but are required for stdenv.mkDerivation

if version is missing, use the unknown version 0.0.0

sample use:

npmlock2nix.build rec {
  src = "...";
  node_modules_attrs = {
    pname = "some-package";
    version = "1.2.3";
  };
}
milahu commented 3 years ago

pname and version should be inherited from build

npmlock2nix.build rec {
  src = "...";
  pname = "some-package";
  version = "1.2.3";
  node_modules_attrs = {
    inherit pname version; # avoid this
  };
}

maybe the node_modules derivation name should be some-package-1.2.3-node_modules

andir commented 3 years ago

pname and version should be inherited from build

npmlock2nix.build rec {
  src = "...";
  pname = "some-package";
  version = "1.2.3";
  node_modules_attrs = {
    inherit pname version; # avoid this
  };
}

maybe the node_modules derivation name should be some-package-1.2.3-node_modules

I agree on the node_modules derivations name. Feel free to add a commit to this PR that adjusts that.

I also agree on the inheriting part. I think we already do that with a couple of attributes and it would make sense here. If we do that we also have to add a test case that ensures that it works as expected. Even if it is correct now I'd like to make it as risk-free as possible to refactor the implementation while keeping the external interface.

milahu commented 3 years ago

Perhaps this could be a starting point?

thanks. i just started test.sh and it takes foreeeeeeeeever seems to download a million packages ...

edit: just 742 paths

these paths will be fetched (989.65 MiB download, 4236.21 MiB unpacked):

crazy!

i hope there is a lighter test method, like snapshot testing