2020-11-25 19:31:30 +01:00
|
|
|
{ stdenv
|
|
|
|
, lib
|
|
|
|
, fetchFromGitHub
|
|
|
|
, autoconf
|
|
|
|
, automake
|
|
|
|
, autoreconfHook
|
|
|
|
, pkgconfig
|
|
|
|
, curl
|
|
|
|
, libevent
|
|
|
|
, glib
|
|
|
|
, libuuid
|
|
|
|
, intltool
|
|
|
|
, sqlite
|
|
|
|
, withMysql ? true
|
|
|
|
, libmysqlclient
|
|
|
|
, libarchive
|
|
|
|
, libtool
|
|
|
|
, jansson
|
|
|
|
, vala
|
|
|
|
, fuse
|
|
|
|
, openssl
|
|
|
|
, oniguruma
|
|
|
|
, libevhtp
|
|
|
|
, libsearpc
|
|
|
|
, which
|
|
|
|
, # for SeaHub
|
|
|
|
python3
|
|
|
|
, python3Packages
|
|
|
|
}:
|
|
|
|
let
|
2021-01-27 00:45:57 +01:00
|
|
|
version = "8.0.3";
|
2020-11-25 19:31:30 +01:00
|
|
|
python = python3;
|
|
|
|
pythonPackages = python3Packages;
|
|
|
|
django = pythonPackages.django;
|
|
|
|
djangoModules = with pythonPackages; [ django-statici18n django-post_office django-picklefield django-formtools djangorestframework ];
|
|
|
|
seahubPythonDependencies = with pythonPackages; [
|
|
|
|
django
|
|
|
|
django-webpack-loader
|
|
|
|
future
|
|
|
|
captcha
|
|
|
|
gunicorn
|
|
|
|
pymysql
|
|
|
|
openpyxl
|
|
|
|
qrcode
|
|
|
|
dateutil
|
|
|
|
requests
|
|
|
|
pillow
|
|
|
|
pyjwt
|
|
|
|
pycryptodome
|
|
|
|
]
|
|
|
|
++ map (p: p.override { inherit django; }) djangoModules; # build django modules with required version
|
2021-01-24 23:13:23 +01:00
|
|
|
# defining them here to be able to expose them in a python environment as well
|
|
|
|
pythonEnvDeps = seahubPythonDependencies ++ [ libsearpc ];
|
2020-11-25 19:31:30 +01:00
|
|
|
seafile-server-core = stdenv.mkDerivation rec {
|
|
|
|
name = "seafile-server-core";
|
|
|
|
inherit version;
|
|
|
|
src = fetchFromGitHub {
|
|
|
|
owner = "haiwen";
|
|
|
|
repo = "seafile-server";
|
|
|
|
rev = "v${version}-server";
|
2021-01-27 00:45:57 +01:00
|
|
|
sha256 = "1wmbx4smf342b5pars1zm9af2i0yaq7kjj7ry0gr337gdpa4qn3b";
|
2019-10-12 22:45:05 +02:00
|
|
|
};
|
2020-11-25 19:31:30 +01:00
|
|
|
# patch to work with latest, non-vulnerable libevhtp
|
|
|
|
patches = [
|
|
|
|
./recent_libevhtp.patch
|
|
|
|
./django-version.patch
|
|
|
|
];
|
|
|
|
# `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 ];
|
2021-01-24 23:13:23 +01:00
|
|
|
propagatedBuildInputs = pythonEnvDeps;
|
2020-12-21 12:24:43 +01:00
|
|
|
# copy manual to required location
|
|
|
|
postInstall = ''
|
|
|
|
mkdir $out/doc
|
|
|
|
cp ${src}/doc/*.doc $out/doc/
|
|
|
|
'';
|
|
|
|
# prevent doc directory from being moved to share in fixupPhase
|
|
|
|
forceShare = [ "man" "info" ];
|
2020-11-25 19:31:30 +01:00
|
|
|
postFixup = ''
|
|
|
|
buildPythonPath $propagatedBuildInputs
|
|
|
|
wrapPythonProgramsIn "$out/bin" "$out $pythonPath"
|
|
|
|
'';
|
|
|
|
checkPhase = "bash ./run_tests.sh";
|
2019-10-09 00:53:54 +02:00
|
|
|
|
2020-11-25 19:31:30 +01:00
|
|
|
meta = with lib; {
|
|
|
|
license = licenses.agpl3; # with additional OpenSSL linking exception
|
|
|
|
maintainers = with maintainers; [ schmittlauch ];
|
2019-10-09 00:53:54 +02:00
|
|
|
};
|
2020-11-25 19:31:30 +01:00
|
|
|
};
|
|
|
|
seahub = pythonPackages.buildPythonApplication rec {
|
|
|
|
name = "seahub";
|
2019-10-09 00:53:54 +02:00
|
|
|
inherit version;
|
2020-11-25 19:31:30 +01:00
|
|
|
src = fetchFromGitHub {
|
|
|
|
owner = "haiwen";
|
|
|
|
repo = "seahub";
|
|
|
|
rev = "v${version}-server";
|
2021-01-27 00:45:57 +01:00
|
|
|
sha256 = "0vfkiavsmpjm6wjr5rcnmnpnb3rxr3svwk8fsh5c76zg87ckdz4d";
|
2020-11-25 19:31:30 +01:00
|
|
|
};
|
|
|
|
phases = [ "unpackPhase" "installPhase" "fixupPhase" "distPhase" ];
|
|
|
|
buildInputs = [ python pythonPackages.wrapPython ];
|
|
|
|
propagatedBuildInputs = seahubPythonDependencies ++ [ pythonPackages.seafile-bindings ]; # for `seaserv` module
|
2019-10-09 00:56:46 +02:00
|
|
|
installPhase = ''
|
2020-11-25 19:31:30 +01:00
|
|
|
cp -r ./ $out
|
2019-10-09 00:56:46 +02:00
|
|
|
cd "$out"
|
2020-11-25 19:31:30 +01:00
|
|
|
${python.interpreter} -m compileall ./
|
|
|
|
buildPythonPath $propagatedBuildInputs
|
|
|
|
set -x
|
|
|
|
patchPythonScript manage.py
|
|
|
|
'';
|
2019-10-12 22:45:05 +02:00
|
|
|
meta = with lib; {
|
2020-11-25 19:31:30 +01:00
|
|
|
license = licenses.asl20;
|
2019-10-12 22:45:05 +02:00
|
|
|
maintainers = with maintainers; [ schmittlauch ];
|
|
|
|
};
|
2020-11-25 19:31:30 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
buildInputs = [ vala fuse libsearpc libuuid sqlite openssl libarchive libevent glib python ]
|
|
|
|
++ lib.optional (!withMysql) "--without-mysql";
|
|
|
|
# `which` is called directly from python during buildPhase, so we need the binary
|
|
|
|
nativeBuildInputs = [ autoconf automake libtool pkgconfig autoreconfHook which ];
|
|
|
|
configureFlags = [ "--disable-static" ];
|
|
|
|
|
|
|
|
meta = {
|
|
|
|
description = "Internal communication framework and user/group management for Seafile server";
|
|
|
|
license = lib.licenses.agpl3; # with additional OpenSSL linking exception
|
|
|
|
};
|
|
|
|
|
|
|
|
in
|
|
|
|
stdenv.mkDerivation {
|
|
|
|
name = "seafile-server";
|
|
|
|
inherit version;
|
|
|
|
|
2021-01-24 23:13:23 +01:00
|
|
|
nativeBuildInputs = [ python3Packages.wrapPython ];
|
2020-11-25 19:31:30 +01:00
|
|
|
buildInputs = [ seahub seafile-server-core libsearpc ]
|
|
|
|
++ lib.optional withMysql libmysqlclient;
|
|
|
|
phases = [ "installPhase" "fixupPhase" "distPhase" ];
|
2020-12-21 12:24:43 +01:00
|
|
|
# create required directory structure
|
|
|
|
# Which files need to be copied is specified in the function `copy_scripts_and_libs`
|
|
|
|
# of ${seafile-server-core.src}/scripts/build/build-server.py
|
|
|
|
# The install script below has been hand crafted from that list of files and needs to be updated on new releases.
|
2020-11-25 19:31:30 +01:00
|
|
|
installPhase = ''
|
|
|
|
mkdir "$out"
|
|
|
|
cd "$out"
|
|
|
|
ln -s ${seahub} seahub
|
2020-12-21 12:24:43 +01:00
|
|
|
ln -s ${seafile-server-core} seafile-server
|
|
|
|
# copy general scripts
|
|
|
|
cp ${seafile-server-core.src}/scripts/{setup-seafile.sh,setup-seafile-mysql.sh,setup-seafile-mysql.py,seafile.sh,seahub.sh,reset-admin.sh,seaf-fuse.sh,check_init_admin.py,seaf-gc.sh,seaf-fsck.sh} .
|
|
|
|
# copy update scripts (and their sql)
|
|
|
|
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
|
2021-01-24 23:13:23 +01:00
|
|
|
# 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
|
2020-11-25 19:31:30 +01:00
|
|
|
'';
|
|
|
|
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
|
2021-01-24 23:13:23 +01:00
|
|
|
|
|
|
|
pythonEnv = python3.buildEnv.override {
|
|
|
|
extraLibs = pythonEnvDeps;
|
|
|
|
ignoreCollisions = true;
|
|
|
|
};
|
2019-10-12 22:45:05 +02:00
|
|
|
}
|