timhae / firefly

14 stars 3 forks source link

How to run Vite and other NPM dependencies? #68

Open charmoniumQ opened 4 months ago

charmoniumQ commented 4 months ago
git clone https://github.com/timhae/firefly
cd firefly
env -C nix develop -c ./update.sh
nix flake check

Checking the error log, /var/lib/firefly-iii/storage/logs/, I see production.ERROR: Vite manifest not found at: /nix/store/8w6ibkzlgbh9g0vka9xxz6k4p9xvj5ch-firefly-iii/public/build/manifest.json. Googling that error, it seems that the solution is to run vite build to generate this manifest. However, vite is an NPM dev-dependency of Firefly-III.

A quick and dirty solution would be to add Vite to the path as a special case. But a more general purpose solution would be to call buildNpmPackage on Firefly and either insert that package into the $PATH or perhaps merging the Npm-built package with the Composer-built package (as in https://github.com/svanderburg/composer2nix/issues/21).

JC5 commented 4 months ago

The Firefly III source code no longer includes generated JS files. Just like it doesn't include the vendor directory.

There is however, with every release a zip file that includes all generated files.

It may be smart to switch to this file as your source, because especially the v1 files are difficult to build (you need a separate npm package file).

charmoniumQ commented 4 months ago

I think we'd like to build/generate from source if at all possible (philosophy of Nix bootstrapping from small sources wherever possible). If not, we can switch to the released Zip.

timhae commented 3 months ago

I think it would be possible to make this work, we will need to add an overlay to the composer package anyways (to add the preliminary .env file), this could also contain the npm package contents. @JC5 are you familiar with nix/nixos? Are you by any chance interested in merging these files upstream once I have something that includes the npm files? It would allow you to add integration tests to the commit checks and provide contributers with a fixed testing/development environment.

JC5 commented 3 months ago

Are you by any chance interested in merging these files upstream once I have something that includes the npm files?

Not really, no.

In the next(!) release or the current develop branch, you can build all necessary JS files with the following commands.

npm install
npm run prod  --workspace=v1
npm run build --workspace=v2

I've got to admit I feel I have enough environment/build/release/os/platform specific files as it is, and I'm trying to get less of them, not more.

timhae commented 3 months ago

Sure, I understand. Thanks for letting me know and taking time to support packaging on different platforms! If you have a spare minute, try to look into nix/nixos, linux has not been the same for me after that :)