nixos-seafile-overlay/seafile-server/default.nix

155 lines
5 KiB
Nix

{ 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
version = "8.0.1";
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
seafile-server-core = stdenv.mkDerivation rec {
name = "seafile-server-core";
inherit version;
src = fetchFromGitHub {
owner = "haiwen";
repo = "seafile-server";
rev = "v${version}-server";
sha256 = "0brjmibg1vd1v6f2ybl1xr0ivf5kc8qg7fy4h204adnc0wkvjkrf";
};
# 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 ];
propagatedBuildInputs = [ libsearpc ] ++ seahubPythonDependencies;
# 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" ];
postFixup = ''
buildPythonPath $propagatedBuildInputs
wrapPythonProgramsIn "$out/bin" "$out $pythonPath"
'';
checkPhase = "bash ./run_tests.sh";
meta = with lib; {
license = licenses.agpl3; # with additional OpenSSL linking exception
maintainers = with maintainers; [ schmittlauch ];
};
};
seahub = pythonPackages.buildPythonApplication rec {
name = "seahub";
inherit version;
src = fetchFromGitHub {
owner = "haiwen";
repo = "seahub";
rev = "v${version}-server";
sha256 = "16lf88j6sjxm5scx4db4bljsbksv27xr6w9rcvcnjba0fkabrlir";
};
phases = [ "unpackPhase" "installPhase" "fixupPhase" "distPhase" ];
buildInputs = [ python pythonPackages.wrapPython ];
propagatedBuildInputs = seahubPythonDependencies ++ [ pythonPackages.seafile-bindings ]; # for `seaserv` module
installPhase = ''
cp -r ./ $out
cd "$out"
${python.interpreter} -m compileall ./
buildPythonPath $propagatedBuildInputs
set -x
patchPythonScript manage.py
'';
meta = with lib; {
license = licenses.asl20;
maintainers = with maintainers; [ schmittlauch ];
};
};
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;
buildInputs = [ seahub seafile-server-core libsearpc ]
++ lib.optional withMysql libmysqlclient;
phases = [ "installPhase" "fixupPhase" "distPhase" ];
# 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.
installPhase = ''
mkdir "$out"
cd "$out"
ln -s ${seahub} seahub
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
'';
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
}