js2nix icon indicating copy to clipboard operation
js2nix copied to clipboard

overlays has no effect

Open milahu opened this issue 6 months ago • 2 comments

im trying to build popcorn-desktop

first it failed with

Error: Failed to parse resolved source: git+ssh://[email protected]/adam-lynch/node-temp.git#279c1350cb7e4f02515d91da9e35d39a40774016

so i patched yarn.lock with

yarn.lock.patch
diff --git a/yarn.lock b/yarn.lock
index 370b9c7..643a3fd 100644
--- a/yarn.lock
+++ b/yarn.lock
@@ -7176,7 +7176,8 @@ teex@^1.0.1:
 
 "temp@github:adam-lynch/node-temp#remove_tmpdir_dep":
   version "0.8.3"
-  resolved "git+ssh://[email protected]/adam-lynch/node-temp.git#279c1350cb7e4f02515d91da9e35d39a40774016"
+  resolved "https://github.com/adam-lynch/node-temp/archive/279c1350cb7e4f02515d91da9e35d39a40774016.tar.gz"
+  integrity sha256-0sv2nivr5i8hr312i4im8yb7s83plpaa92xd695kcbm9zpam64rp
   dependencies:
     rimraf "~2.2.6"
 
@@ -7948,7 +7949,8 @@ vinyl@^3.0.0:
 
 "vtt.js@git+https://github.com/gkatsev/vtt.js.git#vjs-v0.12.1":
   version "0.12.1"
-  resolved "git+ssh://[email protected]/gkatsev/vtt.js.git#8ea664e257ec7b5c092f58ac989e3134ff536a7a"
+  resolved "https://github.com/videojs/vtt.js/archive/8ea664e257ec7b5c092f58ac989e3134ff536a7a.tar.gz"
+  integrity sha256-19ifc02d82v1cn7zxamk1vcinpjiv26ppbnnab7alwagm27il9zm
 
 w-json@^1.3.10:
   version "1.3.10"

then it failed with

Failed to infer sha256 hash of the @fortawesome/[email protected] package source from https://registry.npmjs.org/@fortawesome/fontawesome-free/-/fontawesome-free-6.4.0.tgz.

Override "@fortawesome/[email protected]".src.sha256 attribute in order to provide this missing piece to Nix. For example:

self: super: {
    "@fortawesome/[email protected]" = super."@fortawesome/[email protected]".override (x: {
        # The sha256 value is obtained via
        #   nix-prefetch-url https://registry.npmjs.org/@fortawesome/fontawesome-free/-/fontawesome-free-6.4.0.tgz
        src = x.src.override {
        sha256 = "<sha256>";
        };
    });
}

so i added an overlay, but the build still fails with the same error "Failed to infer sha256 hash"

also, the "Failed to infer sha256 hash" error is wrong, becaue the lockfile has

"@fortawesome/fontawesome-free@^6.4":
  version "6.4.0"
  resolved "https://registry.npmjs.org/@fortawesome/fontawesome-free/-/fontawesome-free-6.4.0.tgz"
  integrity sha512-0NyytTlPJwB/BF5LtRV8rrABDbe3TdTXqNB3PdZ+UUUZAEIrdOJdmABqKjt4AXwIoJNaRVVZEXxpNrqvE1GAYQ==
popcorn-desktop.nix
{
  lib,
  stdenv,
  fetchFromGitHub,
  npmlock2nix,
  js2nix,
  yarn,
  nodePackages,
  writeText,
}:

let
  js2nix_env = js2nix {
    package-json = ./package.json;
    yarn-lock = ./yarn.lock;
    overlays = [
      (self: super: {
        # fix: Failed to infer sha256 hash
        "@fortawesome/[email protected]" = super."@fortawesome/[email protected]".override (x: {
          # nix-prefetch-url https://registry.npmjs.org/@fortawesome/fontawesome-free/-/fontawesome-free-6.4.0.tgz
          src = x.src.override {
            sha256 = "18nzcnafiiqs6li857svmkh83l4z9wkkc0f7dzsva09kg9cq2miq";
          };
        });
        # fix: Error: Failed to parse resolved source
        "temp@github:adam-lynch/node-temp#remove_tmpdir_dep" = super."temp@github:adam-lynch/node-temp#remove_tmpdir_dep".override (x: {
          src = x.src.override {
            url = "https://github.com/adam-lynch/node-temp/archive/279c1350cb7e4f02515d91da9e35d39a40774016.tar.gz";
            sha256 = "0sv2nivr5i8hr312i4im8yb7s83plpaa92xd695kcbm9zpam64rp";
          };
        });
        # fix: Error: Failed to parse resolved source
        "git+https://github.com/gkatsev/vtt.js.git#vjs-v0.12.1" = super."git+https://github.com/gkatsev/vtt.js.git#vjs-v0.12.1".override (x: {
          src = x.src.override {
            url = "https://github.com/videojs/vtt.js/archive/8ea664e257ec7b5c092f58ac989e3134ff536a7a.tar.gz";
            sha256 = "19ifc02d82v1cn7zxamk1vcinpjiv26ppbnnab7alwagm27il9zm";
          };
        });
      })
    ];
  };
in

stdenv.mkDerivation rec {
  pname = "popcorn-desktop";
  version = "0.5.1";

  src = fetchFromGitHub {
    owner = "popcorn-official";
    repo = "popcorn-desktop";
    rev = "v${version}";
    hash = "sha256-lCy2BbqeTF92Fvc7sdoNbhrdzXKiR364Q3JVouQD7F0=";
  };

  nativeBuildInputs = [
    nodePackages.npm
  ];

  postPatch = ''
    ln -s ${js2nix_env.nodeModules} node_modules
  '';

  buildPhase = ''
    npm build
  '';

  installPhase = ''
    cp -r . $out
  '';

  meta = {
    description = "BitTorrent client and media player";
    homepage = "https://github.com/popcorn-official/popcorn-desktop";
    changelog = "https://github.com/popcorn-official/popcorn-desktop/blob/${src.rev}/CHANGELOG.md";
    license = lib.licenses.gpl3Only;
    maintainers = with lib.maintainers; [ ];
    mainProgram = "popcorn-desktop";
    platforms = lib.platforms.all;
  };
}
yarn.lock - relevant parts
"@fortawesome/fontawesome-free@^6.4":
  version "6.4.0"
  resolved "https://registry.npmjs.org/@fortawesome/fontawesome-free/-/fontawesome-free-6.4.0.tgz"
  integrity sha512-0NyytTlPJwB/BF5LtRV8rrABDbe3TdTXqNB3PdZ+UUUZAEIrdOJdmABqKjt4AXwIoJNaRVVZEXxpNrqvE1GAYQ==

"temp@github:adam-lynch/node-temp#remove_tmpdir_dep":
  version "0.8.3"
  resolved "git+ssh://[email protected]/adam-lynch/node-temp.git#279c1350cb7e4f02515d91da9e35d39a40774016"
  dependencies:
    rimraf "~2.2.6"

"vtt.js@git+https://github.com/gkatsev/vtt.js.git#vjs-v0.12.1":
  version "0.12.1"
  resolved "git+ssh://[email protected]/gkatsev/vtt.js.git#8ea664e257ec7b5c092f58ac989e3134ff536a7a"

nw-builder@^3.7.4:
  version "3.7.4"
  resolved "https://registry.npmjs.org/nw-builder/-/nw-builder-3.7.4.tgz"
  integrity sha512-rkjoeGBl8YmFobIcsnJZsawr6yBvLJ74ml+j04LRDVRsqevDspih6zI1+ybA28RLLrcqzgR7nJivKaUlAcuS7g==
  dependencies:
    temp "github:adam-lynch/node-temp#remove_tmpdir_dep"

video.js@^4.12.5:
  version "4.12.15"
  resolved "https://registry.npmjs.org/video.js/-/video.js-4.12.15.tgz"
  integrity sha1-KQ7+MPmdyaSs6Mdz3sJU3+5DTec=
  dependencies:
    vtt.js "git+https://github.com/gkatsev/vtt.js.git#vjs-v0.12.1"

milahu avatar Jul 07 '25 11:07 milahu

Hi @milahu, this is unclear from the first glance what's going on here. Can you attach the original yarn.lock generated files here? you can generate nix expression file by running:

js2nix --lock <path/to/thelock/file> --out ./yarn.lock.nix

To get the js2nix CLI you would need to enter the nix-shell with this file https://github.com/canva-public/js2nix/blob/main/shell.nix

olebedev avatar Jul 08 '25 06:07 olebedev

popcorn-desktop/yarn.lock is part of the repo

i want to build node_modules from yarn.lock directly, not via yarn.lock.nix

milahu avatar Jul 08 '25 08:07 milahu