2023-06-02 14:00:58 +00:00
|
|
|
{ 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;
|
2023-06-02 16:16:34 +00:00
|
|
|
in runCommand "frappe-erpnext-apps-sites" {buildInputs = [yarn]; } ''
|
2023-06-02 14:00:58 +00:00
|
|
|
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
|
|
|
|
yarn --offline production
|
2023-06-02 16:16:34 +00:00
|
|
|
|
|
|
|
symlinkPublic() {
|
|
|
|
find $out/share/apps/$1/$1/public -type d -mindepth 1 -maxdepth 1 | xargs -I '{}' bash -c "ln -s {} $out/share/sites/assets/$1/"'$(basename {})'
|
|
|
|
}
|
|
|
|
|
|
|
|
symlinkPublic frappe
|
|
|
|
symlinkPublic erpnext
|
|
|
|
''
|