!NhAsaYbbgmzHtXTPQJ:funklause.de

Nix NodeJS

199 Members
57 Servers

Load older messages


SenderMessageTime
16 Jul 2024
@wst:imagisphe.re@wst:imagisphe.re left the room.14:06:10
@wst:imagisphe.re@wst:imagisphe.re joined the room.14:06:16
@alex3829:matrix.org@alex3829:matrix.org left the room.23:17:06
17 Jul 2024
@wst:imagisphe.re@wst:imagisphe.reHi, I'm "trying" to package an electron app that uses yarn, but I don't know anything about modern js stack, is this the right place to ask questions or should I rather go to nixpkgs room?13:48:57
@wst:imagisphe.re@wst:imagisphe.reTrying is quoted because I'm not exactly sure what I'm doing :/13:49:48
@c0ba1t:matrix.orgCobaltSure, ask questions and maybe we can help you. Note: If you are new to packaging for nodejs w/ nix, a good point to start is looking at existing packaged software. 14:04:45
@c0ba1t:matrix.orgCobalt* Sure, ask questions and we can try to help you. Note: If you are new to packaging for nodejs w/ nix, a good point to start is looking at existing packaged software. 14:05:03
@wst:imagisphe.re@wst:imagisphe.reYeah, I do try to read docks and see some examples, but it's confusing18:46:07
@wst:imagisphe.re@wst:imagisphe.re So first question I have: the app I'm trying to build and package doesn't have yarn.lock. Is there any way nix can generate it for me let's say during configurePhase or smth? I tried to generate it manually and it ended up being bigger than 500 kB o_O 18:47:28
@c0ba1t:matrix.orgCobaltNix might be able to generate the lock file it with a fixed output derivation but that's a bit clunky. A good approach might be to supply a a yarn.lock or package-lock.json as a patch. In this case you would: 1. Generate a lock file yourself 2. supply it as a patch with the build helper20:35:32
@wst:imagisphe.re@wst:imagisphe.re

I did generate yarn.lock with yarn install but now I have next obstacle: when I try to use fetchYarnDeps with it, it gives me following error:

> Error: The lockfile entry with key "@janhq/core@link:./electron/core" cannot be downloaded because it is missing the "resolved" attribute, which should contain the URL to download from. The lockfile might be invalid.
20:53:02
@wst:imagisphe.re@wst:imagisphe.re *

I did generate yarn.lock with yarn install but now I have next obstacle: when I try to use fetchYarnDeps with it, it gives me following error:

`

Error: The lockfile entry with key "@janhq/core@link:./electron/core" cannot be downloaded because it is missing the "resolved" attribute, which should contain the URL to download from. The lockfile might be invalid.
`

20:53:29
@wst:imagisphe.re@wst:imagisphe.re *

I did generate yarn.lock with yarn install but now I have next obstacle: when I try to use fetchYarnDeps with it, it gives me following error:

Error: The lockfile entry with key "@janhq/core@link:./electron/core" cannot be downloaded because it is missing the "resolved" attribute, which should contain the URL to download from. The lockfile might be invalid.

20:53:49
@wst:imagisphe.re@wst:imagisphe.re There's no package-lock.json as far as I can see in this project 20:54:52
@c0ba1t:matrix.orgCobaltThat sounds unusal can you please share, if possible, the corresponding nix code?21:04:50
@wst:imagisphe.re@wst:imagisphe.reSure, just beware that it's not even nearly complete, I'm taking it step by step21:12:54
@wst:imagisphe.re@wst:imagisphe.re
{ lib
, stdenv
, fetchFromGitHub
, fetchYarnDeps
, yarn2nix
, yarn
}:

stdenv.mkDerivation rec {
  pname = "jan";
  version = "0.5.2";

  src = fetchFromGitHub {
    owner = "janhq";
    repo = pname;
    rev = "v${version}";
    hash = "sha256-MByI66+fmHQOMMlpA/uJ9/iL8ImAr7XbzW4Hht7CeDM=";
  };

  offlineCache = fetchYarnDeps {
    yarnLock = ./yarn.lock;
    sha256 = lib.fakeSha256;
  };

  nativeBuildInputs = [
    yarn2nix
    yarn
  ];

  buildPhase = ''
    cd joi
    yarn2nix
    yarn build
  '';

  meta = {
    homepage = "https://jan.ai";
    license = lib.licenses.gpl3Only;
  };

}
21:13:48
@wst:imagisphe.re@wst:imagisphe.re As far as I understood from makefile of the project I need to first cd to joi subfolder and build yarn dependencies and then I can put offlineCache as a nativeBuildInput to the main project 21:15:48
@wst:imagisphe.re@wst:imagisphe.reI'm absolutely not sure about what I'm doing, so pardon my ignorance in case it doesn't make any sense21:16:32
@c0ba1t:matrix.orgCobaltThank you, I'll try to take a look at it asap21:32:54
@wst:imagisphe.re@wst:imagisphe.reThere's no rush. I will be happy to accept any help.21:38:51
@c0ba1t:matrix.orgCobaltSo, afaict, this repo contains three node components. A web ui, a server for the corresponding backend and an electron app. The web ui and server can be used separately (see Dockerfile) and the electron app wraps the logic from the other components. You are currently trying to package the electron app. Does that sound about right?21:47:44
@c0ba1t:matrix.orgCobaltTo build the electron app, you require a compiled version of the frontend.21:48:54
@c0ba1t:matrix.orgCobalt And the compiled frontend + docs needs to be copied into the electron source in copy:assets. 21:51:33
@wst:imagisphe.re@wst:imagisphe.reYep, that's what I'm trying to do. 21:56:41
@c0ba1t:matrix.orgCobalt

So my first guess would be to

  1. build the frontend and then
  2. build the electron app
    in separate derivations. For 2. you would have to replicate the logic from copy:assets in the preBuild/ patchPhase phase using the compiled output from 1.
21:53:49
@wst:imagisphe.re@wst:imagisphe.reI wonder if the "frontend" can just be wrapped with electron by some nixpkgs function. As far as I understand electron just renders the frontend, so I don't have to build electron from their repo22:01:47
@c0ba1t:matrix.orgCobalt *

So my first guess would be to

  1. build the frontend and then
  2. build the electron app

in separate derivations. For 2. you would have to replicate the logic from copy:assets in the preBuild/ patchPhase phase using the compiled output from 1.

21:54:17
@wst:imagisphe.re@wst:imagisphe.reBut I'm getting ahead of myself22:01:55
@wst:imagisphe.re@wst:imagisphe.reI see22:03:44

Show newer messages


Back to Room ListRoom Version: 6