!NhAsaYbbgmzHtXTPQJ:funklause.de

Nix NodeJS

180 Members
53 Servers

Load older messages


SenderMessageTime
29 Apr 2025
@c0ba1t:matrix.orgCobalthttps://yarnpkg.com/features/pnp12:53:41
@c0ba1t:matrix.orgCobalt Though @c3n21:matrix.org, it might helpful if you could clarify if yarn PNP or pmpn was referred to here. 12:55:39
@c3n21:matrix.orgc3n21Yes it is yarn pnp, I should have mentioned that I'm packaging v6.1.2 which only uses yarn15:30:47
@c0ba1t:matrix.orgCobaltHave you tried the yarn deps fetcher then? https://nixos.org/manual/nixpkgs/stable/#javascript-yarn If this project requires more elaborate packaging than `npm install` it is usually easier to put into it's own package instead of the `nodePackages` set. Following the nixpkgs manual for JavaScript projects should help you there. 15:44:52
@c0ba1t:matrix.orgCobaltThe package does contain a yarn.lock for the requested tag so that might work out as a bypass for yarn PNP. 15:48:13
@c3n21:matrix.orgc3n21

Yes I followed the docs, and it doesn't work because fetchYarnDeps only supports yarn v1 (they have # yarn lockfile v1 as first line, which yarn berry doesn't have)

Funny enough, going the nodePackages at least allows me to build and run the package correctly, but it breaks the pipeline because generate script pulls in python for some reason

15:52:41
@c3n21:matrix.orgc3n21 *

Yes I followed the docs, and it doesn't work because fetchYarnDeps only supports yarn v1 (they have # yarn lockfile v1 as first line, which yarn berry doesn't have)

Funny enough, going the nodePackages at least allows me to build and run the package correctly, but it breaks the pipeline because generate script pulls in python2 for some reason

15:53:04
@cathal_mullan:matrix.orgCJThe yarn.lock in the Verdaccio 6.x branch is from a yarn berry install, i.e. yarn v3/v4. Support for yarn berry just got merged last week, only hit unstable today actually: https://github.com/NixOS/nixpkgs/pull/399404 See these docs: https://github.com/NixOS/nixpkgs/blob/master/doc/languages-frameworks/javascript.section.md#yarn-berry-v3v4-javascript-yarn-v3-v415:57:13
@c3n21:matrix.orgc3n21My current attempt is already using fetchYarnBerryDeps, but it seems that with pnp it just doesn't work, I think I should report it in the PR16:30:06
@c3n21:matrix.orgc3n21* My current attempt is already using fetchYarnBerryDeps, but it seems that with pnp it just doesn't work, do you think I should report it in the PR?16:30:14
@c3n21:matrix.orgc3n21* My current attempt is already using fetchYarnBerryDeps (on my machine, not on the PR), but it seems that with pnp it just doesn't work, do you think I should report it in the PR?16:30:40
@c3n21:matrix.orgc3n21* My current attempt is already using fetchYarnBerryDeps (on my machine, not on the PR), but it seems that with pnp it just doesn't work, do you think I should report it here https://github.com/NixOS/nixpkgs/pull/399404?16:31:12
@cathal_mullan:matrix.orgCJ

Hmm, the actual fetcher seems to work fine manually for me.
e.g. this works correctly:

{
  stdenv,
  fetchFromGitHub,
  yarn-berry_3,
  nodejs,
}:

stdenv.mkDerivation (finalAttrs: {
  pname = "verdaccio";
  version = "6.1.2";

  src = fetchFromGitHub {
    owner = "verdaccio";
    repo = "verdaccio";
    rev = "v${finalAttrs.version}";
    hash = "sha256-EssvN5HtGI5Hmw4EXetj5nzrkBZAAJGgOx09dlYJzhI=";
  };

  nativeBuildInputs = [
    yarn-berry_3.yarnBerryConfigHook
    yarn-berry_3
    nodejs
  ];

  offlineCache = yarn-berry_3.fetchYarnBerryDeps {
    inherit (finalAttrs) src;
    hash = "sha256-jzkmDxQtIFMa1LIPcvKKsXIItPntgXTavoWhd5eZWyQ=";
  };

  buildPhase = ''
    yarn build
  '';

  installPhase = ''
    mkdir -p $out
    cp -r build $out
  '';
})
16:33:21
@c3n21:matrix.orgc3n21

Yes the fetcher seems to work

Try this

{
  lib,
  stdenv,
  nodejs,
  fetchFromGitHub,
  yarn-berry_3,
}:
let
  yarn-berry = yarn-berry_3;
in

stdenv.mkDerivation (finalAttrs: rec {
  pname = "verdaccio";
  version = "6.1.2";

  src = fetchFromGitHub {
    owner = "verdaccio";
    repo = pname;
    rev = "v${version}";
    hash = "sha256-EssvN5HtGI5Hmw4EXetj5nzrkBZAAJGgOx09dlYJzhI=";
  };

  nativeBuildInputs = [
    nodejs
    yarn-berry
    yarn-berry.yarnBerryConfigHook
  ];

  offlineCache = yarn-berry.fetchYarnBerryDeps {
    inherit (finalAttrs) src;
    hash = "sha256-jzkmDxQtIFMa1LIPcvKKsXIItPntgXTavoWhd5eZWyQ=";
  };

  buildPhase = ''
    runHook preBuild
    yarn run build
    runHook postBuild
  '';

  installPhase = ''
    runHook preInstall

    mkdir -p $out

    cp -r {bin,build,package.json,.pnp.cjs} $out/

    runHook postInstall
  '';

  meta = with lib; {
    description = "A simple, zero-config-required local private npm registry";
    longDescription = ''
      Verdaccio is a simple, zero-config-required local private npm registry. No need for an entire database just to get started! Verdaccio comes out of the box with its own tiny database, and the ability to proxy other registries (eg. npmjs.org), caching the downloaded modules along the way. For those looking to extend their storage capabilities, Verdaccio supports various community-made plugins to hook into services such as Amazon's s3, Google Cloud Storage or create your own plugin.
    '';
    homepage = "https://verdaccio.org";
    license = licenses.mit;
  };
})

16:34:14
@c3n21:matrix.orgc3n21 *

Yes the fetcher seems to work but when you try to run the entrypoint script it doesn't work

Try this

{
  lib,
  stdenv,
  nodejs,
  fetchFromGitHub,
  yarn-berry_3,
}:
let
  yarn-berry = yarn-berry_3;
in

stdenv.mkDerivation (finalAttrs: rec {
  pname = "verdaccio";
  version = "6.1.2";

  src = fetchFromGitHub {
    owner = "verdaccio";
    repo = pname;
    rev = "v${version}";
    hash = "sha256-EssvN5HtGI5Hmw4EXetj5nzrkBZAAJGgOx09dlYJzhI=";
  };

  nativeBuildInputs = [
    nodejs
    yarn-berry
    yarn-berry.yarnBerryConfigHook
  ];

  offlineCache = yarn-berry.fetchYarnBerryDeps {
    inherit (finalAttrs) src;
    hash = "sha256-jzkmDxQtIFMa1LIPcvKKsXIItPntgXTavoWhd5eZWyQ=";
  };

  buildPhase = ''
    runHook preBuild
    yarn run build
    runHook postBuild
  '';

  installPhase = ''
    runHook preInstall

    mkdir -p $out

    cp -r {bin,build,package.json,.pnp.cjs} $out/

    runHook postInstall
  '';

  meta = with lib; {
    description = "A simple, zero-config-required local private npm registry";
    longDescription = ''
      Verdaccio is a simple, zero-config-required local private npm registry. No need for an entire database just to get started! Verdaccio comes out of the box with its own tiny database, and the ability to proxy other registries (eg. npmjs.org), caching the downloaded modules along the way. For those looking to extend their storage capabilities, Verdaccio supports various community-made plugins to hook into services such as Amazon's s3, Google Cloud Storage or create your own plugin.
    '';
    homepage = "https://verdaccio.org";
    license = licenses.mit;
  };
})

16:35:00
@c3n21:matrix.orgc3n21 *

Yes the fetcher seems to work but when you try to run the entrypoint script it doesn't work

Try this

{
  lib,
  stdenv,
  nodejs,
  fetchFromGitHub,
  yarn-berry_3,
}:
let
  yarn-berry = yarn-berry_3;
in

stdenv.mkDerivation (finalAttrs: rec {
  pname = "verdaccio";
  version = "6.1.2";

  src = fetchFromGitHub {
    owner = "verdaccio";
    repo = pname;
    rev = "v${version}";
    hash = "sha256-EssvN5HtGI5Hmw4EXetj5nzrkBZAAJGgOx09dlYJzhI=";
  };

  nativeBuildInputs = [
    nodejs
    yarn-berry
    yarn-berry.yarnBerryConfigHook
  ];

  offlineCache = yarn-berry.fetchYarnBerryDeps {
    inherit (finalAttrs) src;
    hash = "sha256-jzkmDxQtIFMa1LIPcvKKsXIItPntgXTavoWhd5eZWyQ=";
  };

  buildPhase = ''
    runHook preBuild
    yarn run build
    runHook postBuild
  '';

  installPhase = ''
    runHook preInstall

    mkdir -p $out

    cp -r {bin,build,package.json,.pnp.cjs} $out/

    runHook postInstall
  '';

  meta = with lib; {
    description = "A simple, zero-config-required local private npm registry";
    longDescription = ''
      Verdaccio is a simple, zero-config-required local private npm registry. No need for an entire database just to get started! Verdaccio comes out of the box with its own tiny database, and the ability to proxy other registries (eg. npmjs.org), caching the downloaded modules along the way. For those looking to extend their storage capabilities, Verdaccio supports various community-made plugins to hook into services such as Amazon's s3, Google Cloud Storage or create your own plugin.
    '';
    homepage = "https://verdaccio.org";
    license = licenses.mit;
  };
})

and run ./result/bin/verdaccio

16:36:05
@cathal_mullan:matrix.orgCJ Yeah I see what you mean now. I wonder if the yarnInstallHook has any support for PNP mode? Probably not though. 16:38:45
@c3n21:matrix.orgc3n21 Yeah, at this point I'm wondering if I should just wait the release of 7.x as the author told me that it will use pnpm or just try to hack this around 16:44:21
@cathal_mullan:matrix.orgCJI'm no yarn expert, but from a quick search seems that it should be possible to wrap the end binary to correctly pass the .pnp files, or set an env var. I came across this for example: https://github.com/madjam002/yarnpnp2nix/blob/master/lib/mkYarnPackage.nix#L196-L19716:48:16
@cathal_mullan:matrix.orgCJMight be more trouble than it's worth for the Verdaccio pakcage specifically, since they're switching to pnpm anyways, but there will likely be other packages who hit this issue in the future.16:51:29
@cathal_mullan:matrix.orgCJ* Might be more trouble than it's worth for the Verdaccio package specifically, since they're switching to pnpm anyways, but there will likely be other packages who hit this issue in the future.16:51:36
@c3n21:matrix.orgc3n21Yes this did indeed work, the only problem is that I'm not so acquaintanted with Nix packaging and I don't know if a node package can also have a wrapper16:57:25
@c3n21:matrix.orgc3n21

Yes I think that perhaps it should be wiser to package it for pnpm for now and use the unstable versioning till 7.x is released.

Meanwhile I will raise the topic about pnp

16:58:55
@cathal_mullan:matrix.orgCJWrapping node packages is fine, here's an example of the Prisma package doing it: https://github.com/NixOS/nixpkgs/blob/master/pkgs/by-name/pr/prisma/package.nix#L83-L8717:00:52
@dolcetriade:matrix.orgDolceTriade joined the room.23:12:13
@dolcetriade:matrix.orgDolceTriade Hello, I've been searching for a way to override the version of nodejs when using buildNpmPackage, but when I do this using the ways I know of, it always also includes the original version of the nodejs in the closure. For example, I'm trying to build mongosh with a newer version of nodejs, so I'm doing something like buildNpmPackage { ... nodejs = nodejs_23; };. Is there a way to ensure the original version of nodejs is not included? 23:17:59
@dolcetriade:matrix.orgDolceTriadeI've also tried buildNpmPackage.override { nodejs = nodejs_23; }. And also tried to use a nixpkgs overlay to override nodejs = nodejs_2323:19:15
@dolcetriade:matrix.orgDolceTriadeRedacted or Malformed Event23:19:21
@dolcetriade:matrix.orgDolceTriadeActually I think the overlay method works. I just had to overlay buildPackages instead of pkgs... Now to figure out how to remove nodejs-source from the closure23:25:46
9 May 2025
@gdesforges:matrix.org@gdesforges:matrix.org left the room.17:07:02

Show newer messages


Back to Room ListRoom Version: 6