2022-11-02 15:02:53 +00:00
|
|
|
{
|
|
|
|
fetchFromGitLab,
|
|
|
|
python3,
|
|
|
|
certifi,
|
|
|
|
flask,
|
|
|
|
flask_sqlalchemy,
|
|
|
|
flask_mail,
|
|
|
|
flask_migrate,
|
|
|
|
flask_wtf,
|
|
|
|
mastodon-py,
|
|
|
|
pandas,
|
|
|
|
psutil,
|
|
|
|
pygal,
|
|
|
|
python-twitter,
|
|
|
|
pymysql,
|
|
|
|
sentry-sdk,
|
|
|
|
authlib,
|
|
|
|
cairosvg,
|
|
|
|
werkzeug,
|
|
|
|
wheel,
|
|
|
|
callPackage,
|
|
|
|
stdenvNoCC,
|
|
|
|
lib,
|
2022-11-02 17:56:08 +00:00
|
|
|
setuptools,
|
2022-11-02 18:52:23 +00:00
|
|
|
psycopg2,
|
2022-11-02 15:02:53 +00:00
|
|
|
}: let
|
|
|
|
source = builtins.fromJSON (builtins.readFile ./source.json);
|
|
|
|
src = fetchFromGitLab {
|
|
|
|
owner = "hexchen";
|
|
|
|
repo = "moa";
|
|
|
|
inherit (source) rev sha256;
|
|
|
|
};
|
|
|
|
moa-env = python3.withPackages (_: [
|
|
|
|
certifi
|
|
|
|
flask
|
|
|
|
flask_sqlalchemy
|
|
|
|
flask_mail
|
|
|
|
flask_migrate
|
|
|
|
flask_wtf
|
|
|
|
mastodon-py
|
|
|
|
pandas
|
|
|
|
psutil
|
|
|
|
pygal
|
|
|
|
python-twitter
|
|
|
|
pymysql
|
|
|
|
sentry-sdk
|
|
|
|
authlib
|
|
|
|
cairosvg
|
|
|
|
werkzeug
|
|
|
|
wheel
|
2022-11-02 17:56:08 +00:00
|
|
|
setuptools
|
2022-11-02 15:02:53 +00:00
|
|
|
(callPackage ../python/instagram.nix {})
|
2022-11-02 18:52:23 +00:00
|
|
|
psycopg2
|
2022-11-02 15:02:53 +00:00
|
|
|
]);
|
|
|
|
in
|
|
|
|
stdenvNoCC.mkDerivation {
|
|
|
|
pname = "moa";
|
|
|
|
version = source.date;
|
|
|
|
inherit src;
|
|
|
|
buildPhase = ''
|
|
|
|
echo "#!/bin/sh" > start.sh
|
|
|
|
echo "cd $out" >> start.sh
|
|
|
|
echo "${moa-env}/bin/python -m moa.models" >> start.sh
|
2022-11-02 15:21:33 +00:00
|
|
|
cp start.sh start-worker.sh
|
|
|
|
mv start.sh start-app.sh
|
|
|
|
echo "exec ${moa-env}/bin/python -m moa.worker" >> start-worker.sh
|
|
|
|
echo "exec ${moa-env}/bin/python app.py" >> start-app.sh
|
|
|
|
chmod +x start-*.sh
|
2022-11-02 15:02:53 +00:00
|
|
|
'';
|
|
|
|
|
|
|
|
installPhase = ''
|
|
|
|
cp -rv $src $out
|
2022-11-02 19:19:39 +00:00
|
|
|
chmod -R +w $out
|
2022-11-02 15:21:33 +00:00
|
|
|
cp start-*.sh $out
|
2022-11-02 19:23:32 +00:00
|
|
|
sed -i 's/, reflect=True//' $out/moa/models.py
|
2022-11-02 19:41:05 +00:00
|
|
|
substituteInPlace $out/app.py --replace "from authlib.integrations._client import MissingRequestTokenError" "class MissingRequestTokenError(Exception): pass"
|
2022-11-02 19:45:24 +00:00
|
|
|
substituteInPlace $out/moa/worker.py --replace "Path(f'" "Path(f'/tmp/moa_"
|
2022-11-02 19:41:05 +00:00
|
|
|
substituteInPlace $out/app.py --replace "logHandler = logging.FileHandler('logs/app.log')" "import sys; logHandler = logging.StreamHandler(sys.stderr)"
|
2022-11-02 19:53:52 +00:00
|
|
|
substituteInPlace $out/moa/worker.py --replace "sqlite" "postgresql"
|
2022-11-02 15:02:53 +00:00
|
|
|
'';
|
|
|
|
meta = {
|
|
|
|
description = "Mastodon-Twitter crossposter";
|
|
|
|
license = lib.licenses.mit;
|
|
|
|
};
|
|
|
|
passthru.updateScript = [
|
|
|
|
../scripts/update-git.sh
|
|
|
|
"https://gitlab.com/hexchen/moa"
|
|
|
|
"moa/source.json"
|
|
|
|
"--rev refs/heads/fix/pleroma"
|
|
|
|
];
|
|
|
|
}
|