!NhAsaYbbgmzHtXTPQJ:funklause.de

Nix NodeJS

182 Members
51 Servers

Load older messages


SenderMessageTime
24 Apr 2025
@cathal_mullan:matrix.orgCathal joined the room.14:46:51
@root:xvx.shroot joined the room.19:29:10
25 Apr 2025
@nrs-status:matrix.orgthirdofmay18081814goya joined the room.16:10:41
26 Apr 2025
@aktaboot:tchncs.deaktabootRedacted or Malformed Event12:56:06
27 Apr 2025
@adam_neverwas:matrix.org@adam_neverwas:matrix.org joined the room.15:56:01
@arexon:matrix.orgarexon changed their profile picture.16:12:40
@arexon:matrix.orgarexon changed their profile picture.16:12:53
29 Apr 2025
@c3n21:matrix.orgc3n21 joined the room.10:08:02
@c3n21:matrix.orgc3n21

Hey guys!

Does anybody know how to create a package for a yarn project that uses pnp?

I'm trying to package Verdaccio https://github.com/NixOS/nixpkgs/pull/398441

but it seems that pnp is not supported by the current packaging tooling

10:09:26
@c0ba1t:matrix.orgCobaltI'm not too familiar with yarn but PNP still has a yarn lockfile, correct? You could try to use the normal yarn deps fetcher on it. Regardless, the linked project's source, verdaccio, seems to use pnpm from cursory glance. This is iirc supported with a custom deps fetcher 10:31:07
@c0ba1t:matrix.orgCobalt(The pnpm guess is based on the pnpm lockfile, https://github.com/verdaccio/verdaccio/blob/master/pnpm-lock.yaml)10:33:24
@sandro:supersandro.deSandro 🐧Pnpm has its own lock file and fetcher11:57:24
@sandro:supersandro.deSandro 🐧(that is a pnpm lock file, or is pnp yet another package manager?)11:58:27
@c0ba1t:matrix.orgCobaltyarn PNP is yarn plug-n-plug iirc, it's a special-ish way for yarn to handle deps. An alternative to traditional node_modules12:52:52
@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.orgCathalThe 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.orgCathal

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

Show newer messages


Back to Room ListRoom Version: 6