Skip to content

WIP feat: add language.nodejs extra - #233

Open
tennox wants to merge 1 commit into
numtide:mainfrom
tennox:lang-nodejs
Open

WIP feat: add language.nodejs extra#233
tennox wants to merge 1 commit into
numtide:mainfrom
tennox:lang-nodejs

Conversation

@tennox

@tennoxtennox commented Oct 18, 2022

Copy link
Copy Markdown
Contributor

I'm new to nix but managed to throw together
what I needed to have consistent nodejs version for:

node --version
yarn node --version
pnpm node --version

Usage:

imports = ["language/nodejs"]
[language.nodejs]
package = "nodejs-16_x"

I think in the end it might be better or more DRY to use something like:
https://github.com/cprussin/nixjs

But it's a bit outdated and I did not figure out how to define overlays in an extra file. 😢
(I still would love to know)

@tennox

Copy link
Copy Markdown
ContributorAuthor

I figured out now that most of the custom patches are not necessary if you just overlay the default nodejs package:

overlays=[(self: prevPkgs: {nodejs=prevPkgs.nodejs-16_x;})]

So if we can add an overlay in an extra file that would be the the simplest solution 🤔

see also in the discourse

Comment on lines +23 to +30
# Yarn
(pkgs.yarn.override {
nodejs = cfg.package;
})

# Pnpm
(pkgs.nodePackages.pnpm.override {
nodejs = cfg.package; # sadly doesn't suffice, but I found this:

@r17xr17xNov 21, 2022

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

I think it could be like this:

  • override nodejs pkg in pkgs.nodePackages
letnodePackages=pkgs.nodePackages.override{nodejs=cfg.package};
  • define packages
devshell.packages=[cfg.packagenodePackages.yarnnodePackages.pnpm]

Copy link
Copy Markdown
ContributorAuthor

Choose a reason for hiding this comment

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

I think I tried this, but don't remember.

I figured that the overlay is much better and will then cover everything dependant on nodejs (e.g. yarn toplevel)

But I don't know how to do that in a devshell extra, do you?

@tennoxtennox changed the title feat: add language.nodejs extraWIP feat: add language.nodejs extraNov 21, 2022
Sign up for freeto 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

@tennox@r17x