69 lines
2.1 KiB
Nix
69 lines
2.1 KiB
Nix
{ fetchFromGitHub
|
|
, fetchYarnDeps
|
|
, runCommand
|
|
, nodejs
|
|
, yarn
|
|
, path
|
|
, nodePackages
|
|
}:
|
|
let
|
|
erpnextSrc = import ../srcs/erpnext.nix {inherit fetchFromGitHub; };
|
|
erpnextOfflineCache = fetchYarnDeps {
|
|
yarnLock = "${erpnextSrc}/yarn.lock";
|
|
sha256 = "sha256-Vho4BSbxcsVYExLvUaeoc3xIpbXoCUP/4jw4RwGnWGY=";
|
|
};
|
|
|
|
frappeSrc = import ../srcs/frappe.nix {inherit fetchFromGitHub; };
|
|
frappeOfflineCache = fetchYarnDeps {
|
|
yarnLock = "${frappeSrc}/yarn.lock";
|
|
sha256 = "sha256-PBdMUz9gJIoQaqQYbdk+xnd8CyZPmdeyz/9WznCb4Ss=";
|
|
};
|
|
|
|
# Copied from nixpkgs:pkgs/development/tools/yarn2nix-moretea/yarn2nix/default.nix
|
|
fixup_yarn_lock = runCommand "fixup_yarn_lock" {buildInputs = [ nodejs ];} ''
|
|
mkdir -p $out/lib
|
|
mkdir -p $out/bin
|
|
|
|
cp ${path}/pkgs/development/tools/yarn2nix-moretea/yarn2nix/lib/urlToName.js $out/lib/urlToName.js
|
|
cp ${path}/pkgs/development/tools/yarn2nix-moretea/yarn2nix/internal/fixup_yarn_lock.js $out/bin/fixup_yarn_lock
|
|
|
|
patchShebangs $out
|
|
'';
|
|
|
|
mkApp = name: src: yarnOfflineCache: runCommand "${name}-app" {
|
|
buildInputs = [fixup_yarn_lock yarn nodePackages.node-gyp-build];
|
|
} ''
|
|
mkdir -p $out/share/apps
|
|
cp -r ${src} $out/share/apps/${name}
|
|
chmod -R +w $out/share/apps/${name}
|
|
|
|
export HOME=$(mktemp -d)
|
|
yarn config --offline set yarn-offline-mirror ${yarnOfflineCache}
|
|
|
|
cd $out/share/apps/${name}
|
|
fixup_yarn_lock yarn.lock
|
|
yarn --offline --ignore-scripts install
|
|
'';
|
|
|
|
frappeApp = mkApp "frappe" frappeSrc frappeOfflineCache;
|
|
erpnextApp = mkApp "erpnext" erpnextSrc erpnextOfflineCache;
|
|
|
|
assets = runCommand "frappe-erpnext-assets" {buildInputs = [yarn]; } ''
|
|
mkdir -p $out/share/sites $out/share/apps
|
|
|
|
# Cannot symlink because the code which traverses path to find sites
|
|
# directory gets confused.
|
|
cp -r ${frappeApp}/share/apps/frappe $out/share/apps/frappe
|
|
cp -r ${erpnextApp}/share/apps/erpnext $out/share/apps/erpnext
|
|
|
|
cat > $out/share/sites/apps.txt <<EOF
|
|
frappe
|
|
erpnext
|
|
EOF
|
|
|
|
cd $out/share/apps/frappe
|
|
pwd
|
|
yarn --offline production
|
|
'';
|
|
in assets
|