Skip to content

Conversation

jaredponn
Copy link
Contributor

@jaredponn jaredponn commented Dec 12, 2023

Surprisingly, one can scan the package-lock.json for URLS of tarballs for dependencies, then fetch those tarballs in a nix derivation, and manually add them into npm's cache. Then, npm install will surprisingly manage to find everything in the cache without hitting the network.

Future work

For now, this only supports grabbing things from the npm registry, and in the future we would like to support the complete set of allowed package-specs by npm.

Honestly, a better way forward would probably to cook up a proxy registry to the npm registry. override npm s.t. it always uses the proxy registry, and dump all the nix packages there. A brief glance suggests that https://verdaccio.org/ might be useful for this :^).

@jaredponn jaredponn force-pushed the jared/typescript-remove-node2nix branch from 856bd4c to d116f31 Compare December 12, 2023 23:11
@jaredponn jaredponn requested a review from bladyjoker December 12, 2023 23:14
@jaredponn jaredponn force-pushed the jared/typescript-remove-node2nix branch from d116f31 to fc3c3fd Compare December 12, 2023 23:17
@jaredponn jaredponn force-pushed the jared/typescript-remove-node2nix branch from fc3c3fd to 0fc8d17 Compare December 12, 2023 23:20
# ```
# So instead, we explicitly write out all the attribute names and what
# they are assigned to.
inherit (typescriptFlake) packages checks devShells;
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Woo hoo, no more IFD so this works now :^)

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

hell yes!

@jaredponn jaredponn self-assigned this Dec 13, 2023
Copy link
Contributor

@bladyjoker bladyjoker left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is great!!!

A question though. Is this really flake-typescript? or is it flake-npm? or smtn like that? At which point is typescript invoked here I can't figure it out :D

@@ -0,0 +1,53 @@
# Given a `package-lock.json`, grabs all packages as tarballs.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you state which npm versions have what you expect?

buildPhase = ''
cp -r "$src" .
cp -r "$src/." .
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Haha yes, cp is difficult

# ```
# So instead, we explicitly write out all the attribute names and what
# they are assigned to.
inherit (typescriptFlake) packages checks devShells;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

hell yes!

Copy link
Contributor

@bladyjoker bladyjoker left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also heads up, you have dependencies, but you also need data (dependencies). Curious how that will work

@jaredponn
Copy link
Contributor Author

A question though. Is this really flake-typescript? or is it flake-npm? or smtn like that? At which point is typescript invoked here I can't figure it out :D

I suppose this really is just flake-npm -- typescript is only called with the build script in the package.json which indeed may not be typescript at all.

Unfortunately, I ended up not going with this, so I'll close this PR.

@jaredponn jaredponn closed this Dec 20, 2023
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

Successfully merging this pull request may close these issues.

2 participants