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

javascript: add corepack option #475

Merged
merged 1 commit into from
May 31, 2023
Merged

Conversation

nicknovitski
Copy link
Contributor

@nicknovitski nicknovitski commented Mar 9, 2023

# Before: 
{
  languages.javascript.enable = true;
  languages.javascript.package = pkgs.nodejs-16_x;
  packages = [ (pkgs.yarn.override { nodejs = pkgs.nodejs-16_x; }) ];
}

# Or alternatively:
{
  languages.javascript.enable = true;
  languages.javascript.package = pkgs.nodejs-16_x;
  scripts.yarn.exec = ''exec corepack yarn "$@"'';
}

# But with this change:
{
  languages.javascript.enable = true;
  languages.javascript.package = pkgs.nodejs-16_x;
  languages.javascript.corepack.enable = true;
}

@domenkozar
Copy link
Member

Seems like you need to run pre-commit run -a

@nicknovitski nicknovitski force-pushed the patch-1 branch 2 times, most recently from d12c3ca to 1c00063 Compare March 16, 2023 22:44
@nicknovitski
Copy link
Contributor Author

~~> Setting up the default profile
  installing 'nix-2.13.3'
  error: unexpected EOF reading a line
  (use '--show-trace' to show detailed location information)

Since this happened on macos, I assume it's this: NixOS/nix#3605.

```
{
  languages.javascript.enable = true;
  languages.javascript.package = pkgs.nodejs-16_x;
  packages = [ (pkgs.yarn.override { nodejs = pkgs.nodejs-16_x; }) ];
}

{
  languages.javascript.enable = true;
  languages.javascript.package = pkgs.nodejs-16_x;
  scripts.yarn.exec = ''exec corepack yarn "$@"'';
}

{
  languages.javascript.enable = true;
  languages.javascript.package = pkgs.nodejs-16_x;
  languages.javascript.corepack.enable = true;
}
```
@domenkozar domenkozar merged commit 714da65 into cachix:main May 31, 2023
@tennox
Copy link
Contributor

tennox commented Jun 1, 2023

I'm curious if corepack brings any advantage over nix-native installing of package-managers, and if the problem described couldn't be fixed in a more nix-y way (and not installing package managers later via this shim, which is kinda bypassing nix & it's advantages) by adding package-manager selection & overlay handling to devenv's languages/javascript.nix instead.

Also, adding an overlay with the nodejs version selected might be a good idea so if users install e.g. yarn/pnpm, it will use the right version. 🤔

@shyim
Copy link
Contributor

shyim commented Jun 1, 2023

@tennox I guess it always depends on the team. If it's required to use Nix for the setup definitively Yes. But if an project have multiple setups, I guess this solution is okay. Also it's optional :)

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.

None yet

4 participants