| 10 Nov 2023 |
szucsitg | * I managed to figure out how to build the project mkYarnPackage. I added all packagges as workspaceDependencies, and it displays correctly in the offline cache derivation under node-modules (symlinked from deps). However when I want to build the React frontend a few folders down, it cannot find our own packages, while the node_modules folder correctly symlinked in root to offlineCache. Anybody seen such behavior? | 16:15:00 |
Lily Foster | In reply to @szucsitg:matrix.org I managed to figure out how to build the project mkYarnPackage. I added all packagges as workspaceDependencies, and it displays correctly in the offline cache derivation under node-modules (symlinked from deps). However when I want to build the React frontend a few folders down, it cannot find our own packages, while the node_modules folder correctly symlinked in root to offlineCache. i really think trying to symlink node_modules like that is gonna cause more problems than it will solve | 16:15:30 |
Lily Foster | what's in that "few folders down" you're referring to? | 16:15:44 |
Lily Foster | (e.g. a new yarn package entirely or workspace package or what?) | 16:15:58 |
szucsitg | So I've got a project/yarn.lock which is root and the package.json for the frontend to built is under project/web/app | 16:17:18 |
szucsitg | I'm open to other suggestion then symlink node-modules in configurePhase | 16:18:09 |
szucsitg | * I'm open to other suggestion than symlink node-modules in configurePhase | 16:18:17 |
Lily Foster | but you aren't using workspace packaging then? | 16:18:29 |
Lily Foster | just separate yarn packages entirely? | 16:18:35 |
szucsitg | I have a derivation as mkYarnPackage, which uses fetchYarnDeps to populate offline cache. And I'm also adding workspace dependencies by iterating through a couple of folders and generating them with mkYarnPackage and inheriting yarnLock and offlineCache | 16:20:40 |
szucsitg | Also without symlinking the node_modules in configurePhase the derivation build fail that it cannot unlink folders as they're not empty | 16:25:56 |
szucsitg | Like this:
error: builder for '/nix/store/2wh00drgf8sxhx6k8z7sx9fsbw35jb4y-account-settings-modules-1.0.0.drv' failed with exit code 1
error: 1 dependencies of derivation '/nix/store/9xvqxvm2hr9dq1d487zww0zywmnaa007-account-settings-1.0.0.drv' failed to build
error (ignored): error: cannot unlink '/private/tmp/nix-build-accept-shared-modules-1.0.0.drv-6/yarn_home/Library/Caches/Yarn/v6/npm-core-js-3.31.0-4471dd33e366c79d8c0977ed2d940821719db344-integrity/node_modules/core-js/internals': Directory not empty
error (ignored): error: cannot unlink '/private/tmp/nix-build-web-client-modules-4.123.0.drv-0/yarn_home/Library/Caches/Yarn/v6/npm-core-js-pure-3.31.0-052fd9e82fbaaf86457f5db1fadcd06f15966ff2-integrity/node_modules/core-js-pure/modules': Directory not empty
error: 1 dependencies of derivation '/nix/store/6il46rk23vm78ly4n5fiv63dghb6mh7d-frontend.drv' failed to build
| 16:28:08 |
peter-lustig | Lily Foster: could you help me with packaging my nodejs app? These are the requirements:
You will need the output directory, the project's package.json, and the production dependencies in node_modules to run the application. Production dependencies can be generated by copying the package.json and package-lock.json and then running npm ci --omit dev (you can skip this step if your app doesn't have any dependencies). You can then start your app with this command:
node build
Development dependencies will be bundled into your app using Rollup. To control whether a given package is bundled or externalised, place it in devDependencies or dependencies respectively in your package.json.
This is what I have:
buildInputs = with pkgs; [
nodejs_20
];
src = ./.;
npmDepsHash = "sha256-mTpjBKTIJkYVj2jrH5lF/n3Axceak4L60ZDQECQhGew=";
npmBuild = "npm run build";
npmInstallFlags = [ "--omit dev" ];
installPhase = ''
mkdir $out
cp -r build/* $out
cp package.json $out
cp package-lock.json $out
'';
| 22:26:37 |
peter-lustig | * Lily Foster: could you help me with packaging my nodejs app? These are the requirements:
*First,
You will need the output directory, the project's package.json, and the production dependencies in node_modules to run the application. Production dependencies can be generated by copying the package.json and package-lock.json and then running npm ci --omit dev (you can skip this step if your app doesn't have any dependencies). You can then start your app with this command:
node build Development dependencies will be bundled into your app using Rollup. To control whether a given package is bundled or externalised, place it in devDependencies or dependencies respectively in your package.json.*
This is what I have:
buildInputs = with pkgs; [
nodejs_20
];
src = ./.;
npmDepsHash = "sha256-mTpjBKTIJkYVj2jrH5lF/n3Axceak4L60ZDQECQhGew=";
npmBuild = "npm run build";
npmInstallFlags = [ "--omit dev" ];
installPhase = ''
mkdir $out
cp -r build/* $out
cp package.json $out
cp package-lock.json $out
'';
| 22:26:53 |
peter-lustig | I think there are already few faults in there, but this is the first error I have:
sh: line 1: vite: command not found | 22:27:56 |
peter-lustig | (build is output directory, just to give context) | 22:28:40 |
Lily Foster | In reply to @peter-lustig:matrix.org
Lily Foster: could you help me with packaging my nodejs app? These are the requirements:
*First,
You will need the output directory, the project's package.json, and the production dependencies in node_modules to run the application. Production dependencies can be generated by copying the package.json and package-lock.json and then running npm ci --omit dev (you can skip this step if your app doesn't have any dependencies). You can then start your app with this command:
node build Development dependencies will be bundled into your app using Rollup. To control whether a given package is bundled or externalised, place it in devDependencies or dependencies respectively in your package.json.*
This is what I have:
buildInputs = with pkgs; [
nodejs_20
];
src = ./.;
npmDepsHash = "sha256-mTpjBKTIJkYVj2jrH5lF/n3Axceak4L60ZDQECQhGew=";
npmBuild = "npm run build";
npmInstallFlags = [ "--omit dev" ];
installPhase = ''
mkdir $out
cp -r build/* $out
cp package.json $out
cp package-lock.json $out
'';
I don't think npmBuild is doing anything there (it's not a valid arg?) and npm install implicitly has --omit=dev, but what that will do is prune dev dependencies (like vite) also when installing deps... | 22:30:04 |
Lily Foster | If you want to prune deps, you should npm prune --omit=dev yourself | 22:30:33 |
Lily Foster | wait the more i'm reading this the less sense it makes | 22:31:44 |
Lily Foster | are you able to share more info on the npm package itself? | 22:31:55 |
peter-lustig | In reply to @lily:lily.flowers are you able to share more info on the npm package itself? This is what I am following now, just trying to do that stuff with nix: https://kit.svelte.dev/docs/adapter-node#deploying | 22:32:23 |
Lily Foster | (and you shouldn't need modules if you use rollup, right?) | 22:32:29 |
Lily Foster | i'm pretty sure buildNpmPackage will do the right thing without trying to recreate what these docs are suggesting | 22:33:24 |
Lily Foster | you might just need to add build as a dir for npm package in your package.json | 22:33:35 |
Lily Foster | and then it should handle everything else | 22:33:42 |
Lily Foster | * and then buildNpmPackage should handle everything else | 22:33:47 |
peter-lustig | In reply to @lily:lily.flowers you might just need to add build as a dir for npm package in your package.json so what could I omit in buildNpmPackage? | 22:34:03 |
Lily Foster | these docs are confusing because if it's using rollup, why is it saying you need node_modules? | 22:34:28 |
Lily Foster | unless i'm misremembering what rollup does | 22:34:35 |
Lily Foster | also that buildInputs is likely not doing anything either | 22:35:00 |