Hello!
I have a multi-language project that builds correctly using nix. I want to simplify the following code - the first target only exists to download the npm deps that are used by the later rust part - is there any way to combine those two?
Thanks!
npm-deps = pkgs.buildNpmPackage {
# used only to create the node_modules folder
name = "npm-deps";
src = ./.;
npmDeps = pkgs.importNpmLock {
npmRoot = ./.;
};
npmConfigHook = pkgs.importNpmLock.npmConfigHook;
buildPhase = ":";
installPhase = ''
mkdir -p $out
cp -r node_modules $out
'';
fixupPhase = ":";
checkPhase = ":";
};
backend = pkgs.rustPlatform.buildRustPackage {
name = "backend";
src = ./.;
cargoLock = {
lockFile = ./Cargo.lock;
};
nativeBuildInputs = global-packages;
HOME = "./home";
buildPhase = ''
mkdir -p ${backend.HOME}
cp -r ${npm-deps}/node_modules .
chmod -R 777 node_modules # to prevent Error: EACCES: permission denied, mkdir '/build/s4bnqnz1prnhv383fpn2hqm29m7ifn3g-source/node_modules/react-native-css-interop/.cache'
make rootfs
'';
checkPhase = "make test";
installPhase = ''
mkdir -p $out
cp -r output/rootfs/* $out
chmod +x $out/bin/* # TODO remove this hack
'';
};