From 8b73ec0585292db407bfe9bf779fa28e27f882a7 Mon Sep 17 00:00:00 2001 From: Trolli Schmittlauch Date: Sun, 24 Jan 2021 23:13:23 +0100 Subject: [PATCH] expose python environment throug sub-attribute, for accessing python interpreter to run admin scripts --- mod-seafile-server.nix | 14 +++----------- seafile-server/default.nix | 16 +++++++++++++++- seafile-test.nix | 2 +- 3 files changed, 19 insertions(+), 13 deletions(-) diff --git a/mod-seafile-server.nix b/mod-seafile-server.nix index 6c4a427..18b274e 100644 --- a/mod-seafile-server.nix +++ b/mod-seafile-server.nix @@ -237,17 +237,8 @@ in ''}") ("${pkgs.writeShellScript "seafile-server-preStart-unprivileged" '' # stuff run as seafile user + set -x - # ccnet-init must only be run once per installation, as it also generates stateful key and ID - # solution: invoke it once, use result as template - if [ ! -e ./ccnet/mykey.peer ]; then - #$ {pkgs.seafile-server.ccnet-server}/bin/ccnet-init -c ./ccnet -H 'TEMPLATEHOST' - mv ./ccnet/ccnet.conf{,.template} - fi - - # generate actual ccnet config file - echo "[General]" > ./conf/ccnet.conf - grep "^ID =" ./ccnet/ccnet.conf.template >> ./conf/ccnet.conf # outside URL SERVICE_URL="http${if cfg.enableTLS then "s" else ""}://${cfg.domainName}:${toString cfg.externalPort}" @@ -264,8 +255,9 @@ in } + pwd ln -sf ${pkgs.seafile-server} seafile-server - ./seafile-server/setup-seafile-mysql.sh \ + ${pkgs.seafile-server.pythonEnv}/bin/python seafile-server/setup-seafile-mysql.py auto \ -n "${cfg.name}" \ -i "${cfg.domainName}" \ -p "${toString cfg.fileserverPort}" \ diff --git a/seafile-server/default.nix b/seafile-server/default.nix index c2e5f67..acb535a 100644 --- a/seafile-server/default.nix +++ b/seafile-server/default.nix @@ -49,6 +49,8 @@ let pycryptodome ] ++ map (p: p.override { inherit django; }) djangoModules; # build django modules with required version + # defining them here to be able to expose them in a python environment as well + pythonEnvDeps = seahubPythonDependencies ++ [ libsearpc ]; seafile-server-core = stdenv.mkDerivation rec { name = "seafile-server-core"; inherit version; @@ -66,7 +68,7 @@ let # `which` is called directly from python during buildPhase, so we need the binary nativeBuildInputs = [ autoconf automake libtool pkgconfig vala autoreconfHook which pythonPackages.wrapPython ]; buildInputs = [ sqlite glib python libuuid openssl oniguruma fuse libarchive libevent libevhtp ]; - propagatedBuildInputs = [ libsearpc ] ++ seahubPythonDependencies; + propagatedBuildInputs = pythonEnvDeps; # copy manual to required location postInstall = '' mkdir $out/doc @@ -127,6 +129,7 @@ stdenv.mkDerivation { name = "seafile-server"; inherit version; + nativeBuildInputs = [ python3Packages.wrapPython ]; buildInputs = [ seahub seafile-server-core libsearpc ] ++ lib.optional withMysql libmysqlclient; phases = [ "installPhase" "fixupPhase" "distPhase" ]; @@ -145,10 +148,21 @@ stdenv.mkDerivation { cp -r ${seafile-server-core.src}/scripts/upgrade . cp -r ${seafile-server-core.src}/scripts/sql . # copy_user_manual is already done in the postInstall hook of seafile-server-core + # python admin scripts need to be made executable and patched with python path + chmod ugo+x *.py + buildPythonPath $propagatedBuildInputs + wrapPythonProgramsIn "$out/*.py" "$out $pythonPath" + + echo -n "${version}" > installed_version ''; meta = with lib; { maintainers = with maintainers; [ schmittlauch ]; license = licenses.free; # components with different free software licenses are combined }; inherit seafile-server-core seahub;# for using the path in the NixOS module + + pythonEnv = python3.buildEnv.override { + extraLibs = pythonEnvDeps; + ignoreCollisions = true; + }; } diff --git a/seafile-test.nix b/seafile-test.nix index 5022de2..1bd1cb1 100644 --- a/seafile-test.nix +++ b/seafile-test.nix @@ -25,7 +25,7 @@ services.seafile-server = { enable = true; #autorun = false; - domainName = "localhost"; + domainName = "seaf.local"; }; }