forked from axeman/erpnext-nix
wip: assets compile, run script still doesn't work
This commit is contained in:
parent
f1b7a7a5b9
commit
b5365ffb3c
25
flake.nix
25
flake.nix
|
@ -6,8 +6,7 @@
|
|||
inputs.pip2nix = {
|
||||
url = "github:nix-community/pip2nix";
|
||||
flake = false;
|
||||
# inputs.nixpkgs.follows = "nixpkgs";
|
||||
# inputs.flake-utils.follows = "flake-utils";
|
||||
# inputs.nixpkgs.follows = "nixpkgs"; # inputs.flake-utils.follows = "flake-utils";
|
||||
};
|
||||
|
||||
outputs = {nixpkgs, flake-utils, pip2nix, ...}:
|
||||
|
@ -26,12 +25,30 @@
|
|||
#newversion = python3.pkgs.newversion.overrideAttrs(old: {
|
||||
# propagatedBuildInputs = old.propagatedBuildInputs ++ [python3.pkgs.setuptools];
|
||||
#});
|
||||
assets = pkgs.callPackage ./node/frappe-assets.nix {};
|
||||
penv = py.buildEnv.override {
|
||||
extraLibs = [ py.pkgs.frappe py.pkgs.erpnext ];
|
||||
};
|
||||
runErpNext = pkgs.writeShellScriptBin "runErpNext" ''
|
||||
export PYTHON_PATH=${penv}/${py.sitePackages}
|
||||
${penv}/bin/gunicorn --bind=0.0.0.0:9090 --threads=4 --workers=2 --worker-class=gthread --worker-tmp-dir=/dev/shm --timeout=120 --preload frappe.app:application
|
||||
sites=$(mktemp -d)
|
||||
for f in ${assets}/share/sites/*; do
|
||||
ln -s "$f" "$sites/$(basename $f)"
|
||||
done
|
||||
cat >$sites/common_site_config.json <<EOF
|
||||
{
|
||||
"db_host": "foo",
|
||||
"db_port": 1336,
|
||||
"db_name": "foo" ,
|
||||
"redis_cache": "foo",
|
||||
"redis_queue": "foo",
|
||||
"redis_socketio": "foo",
|
||||
"socketio_port": 6732,
|
||||
"maintenance_mode": true
|
||||
}
|
||||
EOF
|
||||
echo "Sites dir: $sites"
|
||||
${penv}/bin/gunicorn --chdir="$sites" --bind=0.0.0.0:9090 --threads=4 --workers=2 --worker-class=gthread --worker-tmp-dir=/dev/shm --timeout=120 --preload frappe.app:application
|
||||
'';
|
||||
in rec {
|
||||
packages = {
|
||||
|
@ -41,7 +58,7 @@
|
|||
pkgs.dasel
|
||||
];
|
||||
};
|
||||
inherit pkgs runErpNext;
|
||||
inherit pkgs runErpNext assets;
|
||||
pip2nix = import "${pip2nix}/default.nix" { inherit pkgs; pythonPackages = "python310Packages"; };
|
||||
erpnext = py.pkgs.erpnext;
|
||||
pythonPkgs = py.pkgs;
|
||||
|
|
98
node/frappe-assets.nix
Normal file
98
node/frappe-assets.nix
Normal file
|
@ -0,0 +1,98 @@
|
|||
{ 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 {
|
||||
yarnLock = "${erpnextSrc}/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
|
|
@ -16,20 +16,11 @@
|
|||
, python-stdnum
|
||||
, frappe
|
||||
}:
|
||||
let
|
||||
frappe-version = "14.36.1";
|
||||
erpnext-version = "14.24.3";
|
||||
in
|
||||
buildPythonPackage rec {
|
||||
pname = "erpnext";
|
||||
version = erpnext-version;
|
||||
version = "14.24.3";
|
||||
format = "flit";
|
||||
src = fetchFromGitHub {
|
||||
owner = "frappe";
|
||||
repo = pname;
|
||||
rev = "v${erpnext-version}";
|
||||
sha256 = "sha256-zovdbpTp9fTpY7kAs4J8EiPh+EjqUOtVUk+rDYMfYDk=";
|
||||
};
|
||||
src = import ../srcs/erpnext.nix {inherit fetchFromGitHub; };
|
||||
propagatedBuildInputs = [
|
||||
taxjar
|
||||
gocardless-pro
|
||||
|
@ -44,103 +35,9 @@ buildPythonPackage rec {
|
|||
frappe
|
||||
];
|
||||
|
||||
frappe-assets = mkYarnPackage {
|
||||
pname = "frappe-assets";
|
||||
version = frappe-version;
|
||||
|
||||
src = fetchFromGitHub {
|
||||
owner = "frappe";
|
||||
repo = "frappe";
|
||||
rev = "v${frappe-version}";
|
||||
hash = "sha256-eee6IS/Ep/DSDCPdnyrqBea/ag0kNnN5Id3YQMNz5js=";
|
||||
};
|
||||
|
||||
packageJSON = ../frappe-package.json;
|
||||
yarnFlags = [ "--production" ];
|
||||
|
||||
offlineCache = fetchYarnDeps {
|
||||
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
|
||||
echo -e "erpnext\nfrappe\n" > sites/apps.txt
|
||||
cp -r ${src} apps/erpnext
|
||||
chmod u+rw apps/erpnext
|
||||
cp -r ${erpnext-modules}/node_modules apps/erpnext/node_modules
|
||||
chmod u+rw apps/erpnext
|
||||
#ln -s ${frappe-assets.src} apps/frappe
|
||||
|
||||
yarn --offline production
|
||||
mv sites deps/
|
||||
|
||||
runHook postBuild
|
||||
'';
|
||||
|
||||
# Do not attempt generating a tarball
|
||||
doDist = false;
|
||||
|
||||
meta = with lib; {
|
||||
description = "Assets for frappe";
|
||||
homepage = "https://github.com/frappe/frappe";
|
||||
license = licenses.mit;
|
||||
maintainers = with maintainers; [ axeman teutat3s ];
|
||||
};
|
||||
};
|
||||
erpnext-modules = mkYarnPackage {
|
||||
pname = "erpnext-modules";
|
||||
version = erpnext-version;
|
||||
|
||||
src = fetchFromGitHub {
|
||||
owner = "frappe";
|
||||
repo = "erpnext";
|
||||
rev = "v${erpnext-version}";
|
||||
hash = "sha256-zovdbpTp9fTpY7kAs4J8EiPh+EjqUOtVUk+rDYMfYDk=";
|
||||
};
|
||||
|
||||
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;
|
||||
|
||||
meta = with lib; {
|
||||
description = "Node modules for erpnext";
|
||||
homepage = "https://github.com/frappe/erpnext";
|
||||
license = licenses.mit;
|
||||
maintainers = with maintainers; [ axeman teutat3s ];
|
||||
};
|
||||
};
|
||||
|
||||
postInstall = ''
|
||||
mkdir -p $out/test/frappe $out/test/erpnext
|
||||
ln -s ${frappe-assets} $out/test/frappe
|
||||
ln -s ${erpnext-modules} $out/test/erpnext
|
||||
'';
|
||||
# postInstall = ''
|
||||
# mkdir -p $out/test/frappe $out/test/erpnext
|
||||
# ln -s ${frappe-assets} $out/test/frappe
|
||||
# ln -s ${erpnext-modules} $out/test/erpnext
|
||||
# '';
|
||||
}
|
||||
|
|
|
@ -83,12 +83,7 @@ buildPythonPackage rec {
|
|||
pname = "frappe";
|
||||
version = "14.36.1";
|
||||
format = "flit";
|
||||
src = fetchFromGitHub {
|
||||
owner = "akshaymankar";
|
||||
repo = "frappe";
|
||||
rev = "d4d3cbc12d3e40f104500866a2bf468d128e2e32";
|
||||
sha256 = "sha256-+z/IeK3bFGYxnvWCR6GTgik25lSReJvRCbV7MsoUA/g=";
|
||||
};
|
||||
src = import ../srcs/frappe.nix { inherit fetchFromGitHub; } ;
|
||||
propagatedBuildInputs = [
|
||||
babel
|
||||
click
|
||||
|
|
7
srcs/erpnext.nix
Normal file
7
srcs/erpnext.nix
Normal file
|
@ -0,0 +1,7 @@
|
|||
{fetchFromGitHub}:
|
||||
fetchFromGitHub {
|
||||
owner = "frappe";
|
||||
repo = "erpnext";
|
||||
rev = "v14.24.3";
|
||||
sha256 = "sha256-zovdbpTp9fTpY7kAs4J8EiPh+EjqUOtVUk+rDYMfYDk=";
|
||||
}
|
8
srcs/frappe.nix
Normal file
8
srcs/frappe.nix
Normal file
|
@ -0,0 +1,8 @@
|
|||
{fetchFromGitHub}:
|
||||
|
||||
fetchFromGitHub {
|
||||
owner = "akshaymankar";
|
||||
repo = "frappe";
|
||||
rev = "d4d3cbc12d3e40f104500866a2bf468d128e2e32";
|
||||
sha256 = "sha256-+z/IeK3bFGYxnvWCR6GTgik25lSReJvRCbV7MsoUA/g=";
|
||||
}
|
Loading…
Reference in a new issue