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

WIP feat: add language.nodejs extra #233

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

tennox
Copy link
Contributor

@tennox tennox commented Oct 18, 2022

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
Contributor Author

tennox commented Oct 22, 2022

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:
Copy link

@r17x r17x Nov 21, 2022

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
let nodePackages = pkgs.nodePackages.override {
  nodejs = cfg.package
};
  • define packages
devshell.packages = [
  cfg.package
 
  nodePackages.yarn
  nodePackages.pnpm
]

Copy link
Contributor Author

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?

@tennox tennox changed the title feat: add language.nodejs extra WIP feat: add language.nodejs extra Nov 21, 2022
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