expose python environment throug sub-attribute, for accessing python interpreter to run admin scripts

This commit is contained in:
Trolli Schmittlauch 2021-01-24 23:13:23 +01:00
parent 9dde0d319f
commit 8b73ec0585
3 changed files with 19 additions and 13 deletions

View file

@ -237,17 +237,8 @@ in
''}") ''}")
("${pkgs.writeShellScript "seafile-server-preStart-unprivileged" '' ("${pkgs.writeShellScript "seafile-server-preStart-unprivileged" ''
# stuff run as seafile user # 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 # outside URL
SERVICE_URL="http${if cfg.enableTLS then "s" else ""}://${cfg.domainName}:${toString cfg.externalPort}" 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 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}" \ -n "${cfg.name}" \
-i "${cfg.domainName}" \ -i "${cfg.domainName}" \
-p "${toString cfg.fileserverPort}" \ -p "${toString cfg.fileserverPort}" \

View file

@ -49,6 +49,8 @@ let
pycryptodome pycryptodome
] ]
++ map (p: p.override { inherit django; }) djangoModules; # build django modules with required version ++ 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 { seafile-server-core = stdenv.mkDerivation rec {
name = "seafile-server-core"; name = "seafile-server-core";
inherit version; inherit version;
@ -66,7 +68,7 @@ let
# `which` is called directly from python during buildPhase, so we need the binary # `which` is called directly from python during buildPhase, so we need the binary
nativeBuildInputs = [ autoconf automake libtool pkgconfig vala autoreconfHook which pythonPackages.wrapPython ]; nativeBuildInputs = [ autoconf automake libtool pkgconfig vala autoreconfHook which pythonPackages.wrapPython ];
buildInputs = [ sqlite glib python libuuid openssl oniguruma fuse libarchive libevent libevhtp ]; buildInputs = [ sqlite glib python libuuid openssl oniguruma fuse libarchive libevent libevhtp ];
propagatedBuildInputs = [ libsearpc ] ++ seahubPythonDependencies; propagatedBuildInputs = pythonEnvDeps;
# copy manual to required location # copy manual to required location
postInstall = '' postInstall = ''
mkdir $out/doc mkdir $out/doc
@ -127,6 +129,7 @@ stdenv.mkDerivation {
name = "seafile-server"; name = "seafile-server";
inherit version; inherit version;
nativeBuildInputs = [ python3Packages.wrapPython ];
buildInputs = [ seahub seafile-server-core libsearpc ] buildInputs = [ seahub seafile-server-core libsearpc ]
++ lib.optional withMysql libmysqlclient; ++ lib.optional withMysql libmysqlclient;
phases = [ "installPhase" "fixupPhase" "distPhase" ]; 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/upgrade .
cp -r ${seafile-server-core.src}/scripts/sql . cp -r ${seafile-server-core.src}/scripts/sql .
# copy_user_manual is already done in the postInstall hook of seafile-server-core # 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; { meta = with lib; {
maintainers = with maintainers; [ schmittlauch ]; maintainers = with maintainers; [ schmittlauch ];
license = licenses.free; # components with different free software licenses are combined license = licenses.free; # components with different free software licenses are combined
}; };
inherit seafile-server-core seahub;# for using the path in the NixOS module inherit seafile-server-core seahub;# for using the path in the NixOS module
pythonEnv = python3.buildEnv.override {
extraLibs = pythonEnvDeps;
ignoreCollisions = true;
};
} }

View file

@ -25,7 +25,7 @@
services.seafile-server = { services.seafile-server = {
enable = true; enable = true;
#autorun = false; #autorun = false;
domainName = "localhost"; domainName = "seaf.local";
}; };
} }