!NhAsaYbbgmzHtXTPQJ:funklause.de

Nix NodeJS

137 Members
42 Servers

Load older messages


SenderMessageTime
17 Jul 2024
@c0ba1t:matrix.orgCobaltThat sounds unusal can you please share, if possible, the corresponding nix code?21:04:50
@wst:imagisphe.rewstSure, just beware that it's not even nearly complete, I'm taking it step by step21:12:54
@wst:imagisphe.rewst
{ 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.rewst 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.rewstI'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.rewstThere'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.rewstYep, 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.rewstI 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.rewstBut I'm getting ahead of myself22:01:55
@wst:imagisphe.rewstI see22:03:44
@wst:imagisphe.rewst So the frontend part lives in joi as far as I understood 22:05:06
@c0ba1t:matrix.orgCobaltI'm not too sure about that. You would likely lose some functionlaity. Their electron app is a bit more than a simple wrapper and also, e.g., offers tray support and appears to be doing some fancy stuff to make it appear more native-sh.22:05:05
@wst:imagisphe.rewstTo build it I would need to run first pull the dependencies in advance, since there's no network while building derivation22:06:20
@c0ba1t:matrix.orgCobaltRedacted or Malformed Event22:05:20
@c0ba1t:matrix.orgCobalt
In reply to @wst:imagisphe.re
So the frontend part lives in joi as far as I understood
I think that's just their UI kit. The build job in the Makefile only directly calls out to build web and afterwards electron.
22:10:29
@c0ba1t:matrix.orgCobalt You will probably first want to try to get a derivation with the equivalent of build:web to work. Afterward, approach build:electron. 22:12:07
@c0ba1t:matrix.orgCobalt It's a bit late in my TZ so I'm off for today, I can replicate your problem with the yarn.lock and will try to take a look at it tomorrow. 22:15:42
@wst:imagisphe.rewstThanks for your advice. I will take another look tomorrow with some fresh eyes22:18:18
@c0ba1t:matrix.orgCobalt
In reply to @wst:imagisphe.re
So the frontend part lives in joi as far as I understood
* I think that's just their UI kit. The build job in the Makefile only directly calls out to build web (this component itself requires joi but that should just be another node dependency and not it's own derivation) and afterwards electron.
22:16:55
@wst:imagisphe.rewstHowever I also consider I might be a bit out of my depth here, maybe I should just give up. The reason I wanted to package this for myself is that the existing package in nixpkgs extracts the app for AppImage which is not available for arm architecture(even those the sourcefile in nixpkgs erroneously claims it should work for any linux)22:19:55
@wst:imagisphe.rewstI will try to take another stab at it tomorrow I guess and then see how it goes22:20:47
@wst:imagisphe.rewstI appreciate your help and time, thank you!22:21:04
18 Jul 2024
@qfe6mwof7:matrix.orgqfe6mwof7 joined the room.06:24:10
@jayhenks:matrix.orgjayhenks

Anyone able to help me with this problem? I guess I could solve it by going through the Nix source code for buildNpmPackage, but if anyone here knows it would be preferable.

https://discourse.nixos.org/t/need-help-with-buildnpmpackage/49074

11:03:21

There are no newer messages yet.


Back to Room ListRoom Version: 6