Merge pull request #283319 from phaer/etebase-server
etebase: fix runtime crash due to wrong pydantic..
This commit is contained in:
commit
911b4015d2
2 changed files with 46 additions and 28 deletions
|
@ -5,9 +5,6 @@ with lib;
|
|||
let
|
||||
cfg = config.services.etebase-server;
|
||||
|
||||
pythonEnv = pkgs.python3.withPackages (ps: with ps;
|
||||
[ etebase-server daphne ]);
|
||||
|
||||
iniFmt = pkgs.formats.ini {};
|
||||
|
||||
configIni = iniFmt.generate "etebase-server.ini" cfg.settings;
|
||||
|
@ -46,6 +43,13 @@ in
|
|||
'';
|
||||
};
|
||||
|
||||
package = mkOption {
|
||||
type = types.package;
|
||||
default = pkgs.python3.pkgs.etebase-server;
|
||||
defaultText = literalExpression "pkgs.python3.pkgs.etebase-server";
|
||||
description = lib.mdDoc "etebase-server package to use.";
|
||||
};
|
||||
|
||||
dataDir = mkOption {
|
||||
type = types.str;
|
||||
default = "/var/lib/etebase-server";
|
||||
|
@ -164,7 +168,7 @@ in
|
|||
(runCommand "etebase-server" {
|
||||
nativeBuildInputs = [ makeWrapper ];
|
||||
} ''
|
||||
makeWrapper ${pythonEnv}/bin/etebase-server \
|
||||
makeWrapper ${cfg.package}/bin/etebase-server \
|
||||
$out/bin/etebase-server \
|
||||
--chdir ${escapeShellArg cfg.dataDir} \
|
||||
--prefix ETEBASE_EASY_CONFIG_PATH : "${configIni}"
|
||||
|
@ -178,8 +182,8 @@ in
|
|||
systemd.services.etebase-server = {
|
||||
description = "An Etebase (EteSync 2.0) server";
|
||||
after = [ "network.target" "systemd-tmpfiles-setup.service" ];
|
||||
path = [ cfg.package ];
|
||||
wantedBy = [ "multi-user.target" ];
|
||||
path = [ pythonEnv ];
|
||||
serviceConfig = {
|
||||
User = cfg.user;
|
||||
Restart = "always";
|
||||
|
@ -187,24 +191,26 @@ in
|
|||
};
|
||||
environment = {
|
||||
ETEBASE_EASY_CONFIG_PATH = configIni;
|
||||
PYTHONPATH = cfg.package.pythonPath;
|
||||
};
|
||||
preStart = ''
|
||||
# Auto-migrate on first run or if the package has changed
|
||||
versionFile="${cfg.dataDir}/src-version"
|
||||
if [[ $(cat "$versionFile" 2>/dev/null) != ${pkgs.etebase-server} ]]; then
|
||||
if [[ $(cat "$versionFile" 2>/dev/null) != ${cfg.package} ]]; then
|
||||
etebase-server migrate --no-input
|
||||
etebase-server collectstatic --no-input --clear
|
||||
echo ${pkgs.etebase-server} > "$versionFile"
|
||||
echo ${cfg.package} > "$versionFile"
|
||||
fi
|
||||
'';
|
||||
script =
|
||||
let
|
||||
python = cfg.package.python;
|
||||
networking = if cfg.unixSocket != null
|
||||
then "-u ${cfg.unixSocket}"
|
||||
else "-b 0.0.0.0 -p ${toString cfg.port}";
|
||||
then "--uds ${cfg.unixSocket}"
|
||||
else "--host 0.0.0.0 --port ${toString cfg.port}";
|
||||
in ''
|
||||
cd "${pythonEnv}/lib/etebase-server";
|
||||
daphne ${networking} \
|
||||
${python.pkgs.uvicorn}/bin/uvicorn ${networking} \
|
||||
--app-dir ${cfg.package}/${cfg.package.python.sitePackages} \
|
||||
etebase_server.asgi:application
|
||||
'';
|
||||
};
|
||||
|
|
|
@ -1,24 +1,22 @@
|
|||
{ lib
|
||||
, fetchFromGitHub
|
||||
, buildPythonPackage
|
||||
, aiofiles
|
||||
, django_3
|
||||
, fastapi
|
||||
, msgpack
|
||||
, pynacl
|
||||
, redis
|
||||
, typing-extensions
|
||||
, withLdap ? true
|
||||
, python-ldap
|
||||
, python3
|
||||
, withPostgres ? true
|
||||
, psycopg2
|
||||
, nix-update-script
|
||||
, nixosTests
|
||||
}:
|
||||
|
||||
buildPythonPackage rec {
|
||||
let
|
||||
python = python3.override {
|
||||
packageOverrides = self: super: {
|
||||
pydantic = super.pydantic_1;
|
||||
};
|
||||
};
|
||||
in
|
||||
python.pkgs.buildPythonPackage rec {
|
||||
pname = "etebase-server";
|
||||
version = "0.11.0";
|
||||
format = "other";
|
||||
|
||||
src = fetchFromGitHub {
|
||||
owner = "etesync";
|
||||
|
@ -29,32 +27,46 @@ buildPythonPackage rec {
|
|||
|
||||
patches = [ ./secret.patch ];
|
||||
|
||||
propagatedBuildInputs = [
|
||||
doCheck = false;
|
||||
|
||||
propagatedBuildInputs = with python.pkgs; [
|
||||
aiofiles
|
||||
django_3
|
||||
fastapi
|
||||
msgpack
|
||||
pynacl
|
||||
redis
|
||||
uvicorn
|
||||
websockets
|
||||
watchfiles
|
||||
uvloop
|
||||
pyyaml
|
||||
python-dotenv
|
||||
httptools
|
||||
typing-extensions
|
||||
] ++ lib.optional withLdap python-ldap
|
||||
++ lib.optional withPostgres psycopg2;
|
||||
|
||||
installPhase = ''
|
||||
postInstall = ''
|
||||
mkdir -p $out/bin $out/lib
|
||||
cp -r . $out/lib/etebase-server
|
||||
ln -s $out/lib/etebase-server/manage.py $out/bin/etebase-server
|
||||
cp manage.py $out/bin/etebase-server
|
||||
wrapProgram $out/bin/etebase-server --prefix PYTHONPATH : "$PYTHONPATH"
|
||||
chmod +x $out/bin/etebase-server
|
||||
'';
|
||||
|
||||
passthru.updateScript = nix-update-script {};
|
||||
passthru.python = python;
|
||||
# PYTHONPATH of all dependencies used by the package
|
||||
passthru.pythonPath = python.pkgs.makePythonPath propagatedBuildInputs;
|
||||
passthru.tests = {
|
||||
nixosTest = nixosTests.etebase-server;
|
||||
};
|
||||
|
||||
meta = with lib; {
|
||||
homepage = "https://github.com/etesync/server";
|
||||
description = "An Etebase (EteSync 2.0) server so you can run your own";
|
||||
changelog = "https://github.com/etesync/server/blob/${version}/ChangeLog.md";
|
||||
license = licenses.agpl3Only;
|
||||
maintainers = with maintainers; [ felschr ];
|
||||
maintainers = with maintainers; [ felschr phaer ];
|
||||
};
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue