erpnext-nix/node/frappe-assets.nix

99 lines
2.5 KiB
Nix
Raw Normal View History

{ mkYarnPackage
, fetchFromGitHub
, fetchYarnDeps
, stdenv
}:
let
erpnextSrc = import ../srcs/erpnext.nix {inherit fetchFromGitHub; };
erpnext-modules = mkYarnPackage {
pname = "erpnext-modules";
version = "14.24.3";
src = erpnextSrc;
packageJSON = ../erpnext-package.json;
yarnFlags = [ "--production" ];
offlineCache = fetchYarnDeps {
yarnLock = ../erpnext-yarn.lock;
hash = "sha256-Vho4BSbxcsVYExLvUaeoc3xIpbXoCUP/4jw4RwGnWGY=";
};
configurePhase = ''
ln -s $node_modules node_modules
'';
installPhase = ''
ls -alh
mkdir $out
cp -r node_modules $out/
ls -alh $out/
'';
# We only need node_modules
dontBuild = true;
# Do not attempt generating a tarball
doDist = false;
};
frappe-modules = mkYarnPackage rec {
pname = "frappe-assets";
version = "14.36.1";
src = import ../srcs/frappe.nix {inherit fetchFromGitHub; };
packageJSON = ../frappe-package.json;
yarnFlags = [ "--production" ];
offlineCache = fetchYarnDeps {
2023-05-22 17:26:55 +00:00
yarnLock = "${src}/yarn.lock";
hash = "sha256-PBdMUz9gJIoQaqQYbdk+xnd8CyZPmdeyz/9WznCb4Ss=";
};
buildPhase = ''
runHook preBuild
# Yarn writes cache directories etc to $HOME.
export HOME=$PWD/yarn_home
# The upstream build script reads sites/apps.txt to define what assets to build
# A list of assets is written to sites/assets/assets.json
mkdir -p apps sites/assets
cp -r "${erpnextSrc}/erpnext/public" "sites/assets/erpnext"
cp -r "$src/frappe/public" "sites/assets/frappe"
echo -e "erpnext\nfrappe\n" > sites/apps.txt
cp -r ${erpnextSrc} apps/erpnext
cp -r $src apps/frappe
chmod u+rw apps/erpnext
chmod u+rw apps/frappe
chmod -R u+rw sites/assets/erpnext
chmod -R u+rw sites/assets/frappe
cp -r ${erpnext-modules}/node_modules apps/erpnext/node_modules
cp -r $node_modules apps/frappe/node_modules
yarn --offline production
mv sites deps/
runHook postBuild
'';
# Do not attempt generating a tarball
doDist = false;
};
frappe-assets = stdenv.mkDerivation {
pname = "erpnext-assets";
version = "14.24.3";
phases = [ "installPhase" ];
installPhase = ''
mkdir -p $out/share
cp -r "${frappe-modules}/libexec/frappe-framework/deps/sites/" $out/share/sites
'';
};
in frappe-assets