!NhAsaYbbgmzHtXTPQJ:funklause.de

Nix NodeJS

180 Members
51 Servers

Load older messages


SenderMessageTime
13 Jan 2025
@xiaoxiangmoe:matrix.org🐰 xiaoxiangmoe
{
  lib,
  stdenv,
  buildNpmPackage,
  fetchFromGitHub,
  nodejs,
  pnpm,
  cacert,
}:

buildNpmPackage rec {
  pname = "ni";
  version = "23.2.0";

  src = fetchFromGitHub {
    owner = "antfu-collective";
    repo = "ni";
    tag = "v${version}";
    hash = "sha256-f210qz53IgUXDon4bWIp+dynJ3aWi0za0puPjplzmqg=";
  };

  buildInputs = [
  ];
  nativeBuildInputs = [
    nodejs
  ];
  npmConfigHook = pnpm.configHook;
  npmDeps = pnpmDeps;
  pnpmDeps = pnpm.fetchDeps {
    inherit pname version src;
    hash = "sha256-+hnkj0uevURkRboTH8WbSt82pZTdWL4ii1PKr6NO0Cg=";
  };


  meta = {
    description = "Use the right package manager";
    homepage = "https://github.com/antfu-collective/ni";
    license = lib.licenses.mit;
    maintainers = with lib.maintainers; [ xiaoxiangmoe ];
  };
}

This raise a error

       >  UNABLE_TO_GET_ISSUER_CERT_LOCALLY  request to https://registry.npmjs.org/@eslint/core/-/core-0.9.0.tgz failed, reason: unable to get local issuer certificate
       >
       > FetchError: request to https://registry.npmjs.org/@eslint/core/-/core-0.9.0.tgz failed, reason: unable to get local issuer certificate
       >     at ClientRequest.<anonymous> (/nix/store/hhprmwazmgvxqff5zpra2bw0cb12f4sl-pnpm-9.15.3/libexec/pnpm/dist/pnpm.cjs:66979:18)
       >     at ClientRequest.emit (node:events:518:28)
       >     at emitErrorEvent (node:_http_client:103:11)
       >     at TLSSocket.socketErrorListener (node:_http_client:506:5)
       >     at TLSSocket.emit (node:events:518:28)
       >     at emitErrorNT (node:internal/streams/destroy:170:8)
       >     at emitErrorCloseNT (node:internal/streams/destroy:129:3)
       >     at process.processTicksAndRejections (node:internal/process/task_queues:90:21)
       > Progress: resolved 685, reused 0, downloaded 0, added 0
       For full logs, run 'nix log /nix/store/i13ksyg9fqd8rlc3dywlarsvm5ix2cbn-ni-pnpm-deps.drv'.
14:33:34
@xiaoxiangmoe:matrix.org🐰 xiaoxiangmoe *
{
  lib,
  stdenv,
  buildNpmPackage,
  fetchFromGitHub,
  nodejs,
  pnpm,
  cacert,
}:

buildNpmPackage rec {
  pname = "ni";
  version = "23.2.0";

  src = fetchFromGitHub {
    owner = "antfu-collective";
    repo = "ni";
    tag = "v${version}";
    hash = "sha256-f210qz53IgUXDon4bWIp+dynJ3aWi0za0puPjplzmqg=";
  };

  buildInputs = [
  ];
  nativeBuildInputs = [
    nodejs
  ];
  npmConfigHook = pnpm.configHook;
  npmDeps = pnpmDeps;
  pnpmDeps = pnpm.fetchDeps {
    inherit pname version src;
    hash = "sha256-+hnkj0uevURkRboTH8WbSt82pZTdWL4ii1PKr6NO0Cg=";
  };


  meta = {
    description = "Use the right package manager";
    homepage = "https://github.com/antfu-collective/ni";
    license = lib.licenses.mit;
    maintainers = with lib.maintainers; [ xiaoxiangmoe ];
  };
}

This raise a error on macOS

       >  UNABLE_TO_GET_ISSUER_CERT_LOCALLY  request to https://registry.npmjs.org/@eslint/core/-/core-0.9.0.tgz failed, reason: unable to get local issuer certificate
       >
       > FetchError: request to https://registry.npmjs.org/@eslint/core/-/core-0.9.0.tgz failed, reason: unable to get local issuer certificate
       >     at ClientRequest.<anonymous> (/nix/store/hhprmwazmgvxqff5zpra2bw0cb12f4sl-pnpm-9.15.3/libexec/pnpm/dist/pnpm.cjs:66979:18)
       >     at ClientRequest.emit (node:events:518:28)
       >     at emitErrorEvent (node:_http_client:103:11)
       >     at TLSSocket.socketErrorListener (node:_http_client:506:5)
       >     at TLSSocket.emit (node:events:518:28)
       >     at emitErrorNT (node:internal/streams/destroy:170:8)
       >     at emitErrorCloseNT (node:internal/streams/destroy:129:3)
       >     at process.processTicksAndRejections (node:internal/process/task_queues:90:21)
       > Progress: resolved 685, reused 0, downloaded 0, added 0
       For full logs, run 'nix log /nix/store/i13ksyg9fqd8rlc3dywlarsvm5ix2cbn-ni-pnpm-deps.drv'.
14:34:05
@xiaoxiangmoe:matrix.org🐰 xiaoxiangmoeIs there anyway to add cacert for pnpm.fetchDeps in macOS?14:41:32
@lily:lily.flowersLily Foster
In reply to @xiaoxiangmoe:matrix.org
Is there anyway to add cacert for pnpm.fetchDeps in macOS?
nativeBuildInputs in the pnpm.fetchDeps?
14:42:15
@lily:lily.flowersLily Foster(i'd be surprised though if that fetcher was made so uncarefully to not handle cert stuff like other fechers (e.g. npm) do)14:43:11
@xiaoxiangmoe:matrix.org🐰 xiaoxiangmoe

But this also not working

 WARN  GET https://registry.npmjs.org/@eslint-community/eslint-utils/-/eslint-utils-4.4.1.tgz error (UNABLE_TO_GET_ISSUER_CERT_LOCALLY). Will retry in 1 minute. 1 retries left.
14:43:30
15 Jan 2025
@rosssmyth:matrix.orgrosssmyth

After setting up my aforementioned pnpm build, I am now wondering why the devshell and build derivations behave differently. My outputs look like this:

      devShells.default = pkgs.mkShellNoCC {
        inherit pnpmDeps cargoDeps;
        inputsFrom = [ self.packages.${system}.default ];
      };

      packages.default = pkgs.stdenvNoCC.mkDerivation (finalAttrs: {
        inherit pnpmDeps cargoDeps pname version;
        src = gitignoreSource ./.;
        strict = true;
        doCheck = false;
        nativeBuildInputs = with pkgs; [
          wasm-bindgen-cli
          nodejs
          nodejs.pkgs.pnpm.configHook
          pkgs.rustPlatform.cargoSetupHook
          wrappedWasmPack
          (rust-bin.stable.latest.default.override {targets = ["wasm32-unknown-unknown"];})
        ];

        buildPhase = ''
          pnpm build
        '';
        installPhase = ''
          mv dist/ $out
        '';
      });

The packaging derivation works exactly how I want it. But the devshell does not. Specifically, while in the packaging derivation all the dependencies are installed and then all I need to do is run "pnpm build" in the build phase as shown. But in the dev shell when I execute "pnpm build" pnpm complains that I need to install the dependencies still.

Is there something I am missing? Is mkshell different from mkderivation in a way that prevents this? Obviously it is impure, but I'd like to confine the dependencies in the store as much as I can.

02:58:12
@winter:catgirl.cloudWinterit does not have the config hook.03:12:47
@winter:catgirl.cloudWinter*run03:13:18
@winter:catgirl.cloudWinterthose setup hooks do not run when in a devshell03:13:37
@rosssmyth:matrix.orgrosssmyth😔03:26:03
@rosssmyth:matrix.orgrosssmythIt does download them somewhere to my store. It's just not setup so that pnpm can see the dependencies 03:26:40
@winter:catgirl.cloudWinteryou can set that up with a shell hook03:39:57
@rosssmyth:matrix.orgrosssmythgood idea 03:41:34
@rosssmyth:matrix.orgrosssmythThat does work03:41:43
@ss:someonex.netSomeoneSerge (Ever OOMed by Element) changed their display name from SomeoneSerge (utc+3) to SomeoneSerge.19:02:28
16 Jan 2025
@hasnep:matrix.orgHannes joined the room.01:28:40
@hasnep:matrix.orgHannes Hi, can someone tell what is the preferred way of packaging a Node.js CLI in nixpkgs? Should I add it to pkgs/development/node-packages/node-packages.json or use buildNpmPackage? 02:14:21
@emilazy:matrix.orgemilylatter02:16:10
@hasnep:matrix.orgHannesThanks, I'm glad because I tried the first method and it wasn't working 😅02:16:47
@hasnep:matrix.orgHannes Okay, followup question, the package I'm building has an npm run build script, but it's just defined as npm run lint && npm run test, should I set dontNpmBuild = true so that nix doesn't lint and test the package every time it builds? 02:39:45
@hasnep:matrix.orgHannesHere's the PR for the package if anyone has suggestions :) https://github.com/NixOS/nixpkgs/pull/37420604:26:42
18 Jan 2025
@maralorn:maralorn.demaralorn joined the room.14:55:16
@maralorn:maralorn.demaralornHey there. I am trying to build https://github.com/gristlabs/grist-core bad sadly I have no clue what I am doing.14:57:06
@maralorn:maralorn.demaralornFrom perusing nixpkgs my take away was that the current best approach are yarn* hooks.14:57:50
@maralorn:maralorn.demaralornSo I copied the element-call derivation which seems to be doing exactly that.14:58:12
@maralorn:maralorn.demaralornNow I get this error:14:58:26
@maralorn:maralorn.demaralorn

grist-core> no configure script, doing nothing
grist-core> Executing yarnConfigHook
yarn config v1.22.22
success Set "yarn-offline-mirror" to "/nix/store/iswv7iddmhm8py46spivs75x2n53mjcf-offline".
Done in 0.02s.
yarn install v1.22.22
[1/4] Resolving packages...
[2/4] Fetching packages...
error Can't make a request in offline mode ("https://registry.yarnpkg.com/https___registry.npmjs.org_jquery___jquery_3.5.0.tgz")
info Visit https://yarnpkg.com/en/docs/cli/install for documentation about this command.
error Can't make a request in offline mode ("https://registry.yarnpkg.com/node_gyp___node_gyp_8.4.1.tgz")
14:58:51
@maralorn:maralorn.demaralorn *
grist-core> no configure script, doing nothing
grist-core> Executing yarnConfigHook
yarn config v1.22.22
success Set "yarn-offline-mirror" to "/nix/store/iswv7iddmhm8py46spivs75x2n53mjcf-offline".
Done in 0.02s.
yarn install v1.22.22
[1/4] Resolving packages...
[2/4] Fetching packages...
error Can't make a request in offline mode ("https://registry.yarnpkg.com/https___registry.npmjs.org_jquery___jquery_3.5.0.tgz")
info Visit https://yarnpkg.com/en/docs/cli/install for documentation about this command.
error Can't make a request in offline mode ("https://registry.yarnpkg.com/node_gyp___node_gyp_8.4.1.tgz")
14:59:03
@maralorn:maralorn.demaralornIf there are any docs about how to do this properly please let me know.14:59:53

Show newer messages


Back to Room ListRoom Version: 6