nix-community / yarn2nix

Generate nix expressions from a yarn.lock file [maintainer=???]
GNU General Public License v3.0
123 stars 61 forks source link

Error: getaddrinfo ENOTFOUND registry.npmjs.org #165

Closed jtojnar closed 3 years ago

jtojnar commented 3 years ago

When trying to build Vikunja, generating the yarn.nix in build sandbox fails:

events.js:292
      throw er; // Unhandled 'error' event
      ^

Error: getaddrinfo ENOTFOUND registry.npmjs.org
    at GetAddrInfoReqWrap.onlookup [as oncomplete] (dns.js:67:26)
Emitted 'error' event on ClientRequest instance at:
    at TLSSocket.socketErrorListener (_http_client.js:469:9)
    at TLSSocket.emit (events.js:315:20)
    at emitErrorNT (internal/streams/destroy.js:106:8)
    at emitErrorCloseNT (internal/streams/destroy.js:74:3)
    at processTicksAndRejections (internal/process/task_queues.js:80:21) {
  errno: -3008,
  code: 'ENOTFOUND',
  syscall: 'getaddrinfo',
  hostname: 'registry.npmjs.org'
}

Repro

let
  pkgs = import <nixpkgs> {};

  yarn2nixSrc = import (pkgs.fetchFromGitHub {
    owner = "nix-community";
    repo = "yarn2nix";
    rev = "37c3b7c1d1170ed6e063b804c4dbe871f4043349";
    sha256 = "tt/6Yt1kGfXZbfV8Ny9B166R5c4E78bo8BZEjWvpL3w=";
  }) {
    inherit pkgs;
  };

  yarn2nix = yarn2nixSrc.yarn2nix;

  # working
  # src = pkgs.fetchgit {
  #   url = "https://kolaente.dev/vikunja/frontend.git";
  #   rev = "cf47e196d7a4493b9b1afccc20b7c42d44bb857e";
  #   sha256 = "0n67jim5382wn89sn9yygvh28vnxf6aa5qii62kqj9rsp306vnnp";
  # };

  # borked
  src = pkgs.fetchgit {
    url = "https://kolaente.dev/vikunja/frontend.git";
    rev = "e1cee4f5e0c217c4c34b7a859a4a49b19bab1db4";
    sha256 = "0m6ywqp6w1g6jz13kqzic9l63cc9ql47x1sg32j5shn1q0xjzj3i";
  };
in
pkgs.runCommand "build" {
  nativeBuildInputs = [ yarn2nix ];
} ''
  mkdir "$out"
  cat "${src}/yarn.lock" > "$out/yarn.lock"
  yarn2nix --lockfile "${src}/yarn.lock" --no-patch --builtin-fetchgit > "$out/yarn.nix"
''

The error message points to registry.npmjs.org which is only used by caniuse-lite in yarn.lock and indeed, git bisect points to https://github.com/go-vikunja/frontend/commit/b885eb7ff287d9a22276904c8f395c04f80d62c0.

kolaente commented 3 years ago

It turns out this was an issue with browserlist: https://github.com/browserslist/browserslist/issues/546

I've just pushed a fix to Vikunja: https://kolaente.dev/vikunja/frontend/commit/56788a38efba6ca0dc06d709c4b334a201df2cbc

With that commit, I was able to build the frontend without issues.