nixpkgs/pkgs/applications/misc/buku/default.nix
Anthony Roussel 86a160ea18 buku: fix build failing for bukuserver
SQLAlchemy-Utils v0.36.6 package override build is failing.

This is due to a patch in the original SQLAlchemy-Utils package which
broke the build of this package override:

```bash
> applying patch /nix/store/pd6anhwbf0in3r3jhi3sbn5v2fjs0mf2-skip-database-tests.patch
> patching file conftest.py
> Hunk #1 FAILED at 61.
> Hunk #2 succeeded at 98 (offset -10 lines).
```

These SQLAlchemy package overrides were originaly added to fix
incompatibilities with Flask-Admin.

See commit 05ae01fcea

However with Flask-Admin >= v1.5.6, several SQLAlchemy compatibility patches were added:
* https://flask-admin.readthedocs.io/en/latest/changelog/

We can now safely remove these package overrides to make bukuserver work again.
2022-08-04 21:53:58 +02:00

92 lines
2.2 KiB
Nix

{ lib, python3, fetchFromGitHub, withServer ? false }:
let
serverRequire = with python3.pkgs; [
requests
flask
flask-admin
flask-api
flask-bootstrap
flask-paginate
flask-reverse-proxy-fix
flask-wtf
arrow
werkzeug
click
vcrpy
toml
];
in
with python3.pkgs; buildPythonApplication rec {
version = "4.7";
pname = "buku";
src = fetchFromGitHub {
owner = "jarun";
repo = "buku";
rev = "v${version}";
sha256 = "sha256-7piJK1hz9h6EWiU/q5MAS1PSvHFxnW7rZBKxq+wda1c=";
};
checkInputs = [
hypothesis
pytest
pytest-vcr
pyyaml
mypy-extensions
click
];
propagatedBuildInputs = [
cryptography
beautifulsoup4
certifi
urllib3
html5lib
] ++ lib.optionals withServer serverRequire;
postPatch = ''
# Jailbreak problematic dependencies
sed -i \
-e "s,'PyYAML.*','PyYAML',g" \
-e "/'pytest-cov/d" \
-e "/'pylint/d" \
-e "/'flake8/d" \
setup.py
'';
preCheck = ''
# Fixes two tests for wrong encoding
export PYTHONIOENCODING=utf-8
# Disables a test which requires internet
substituteInPlace tests/test_bukuDb.py \
--replace "@pytest.mark.slowtest" "@unittest.skip('skipping')" \
--replace "self.assertEqual(shorturl, \"http://tny.im/yt\")" "" \
--replace "self.assertEqual(url, \"https://www.google.com\")" ""
substituteInPlace setup.py \
--replace mypy-extensions==0.4.1 mypy-extensions>=0.4.1
'' + lib.optionalString (!withServer) ''
rm tests/test_{server,views}.py
'';
postInstall = ''
make install PREFIX=$out
mkdir -p $out/share/zsh/site-functions $out/share/bash-completion/completions $out/share/fish/vendor_completions.d
cp auto-completion/zsh/* $out/share/zsh/site-functions
cp auto-completion/bash/* $out/share/bash-completion/completions
cp auto-completion/fish/* $out/share/fish/vendor_completions.d
'' + lib.optionalString (!withServer) ''
rm $out/bin/bukuserver
'';
meta = with lib; {
description = "Private cmdline bookmark manager";
homepage = "https://github.com/jarun/Buku";
license = licenses.gpl3;
platforms = platforms.unix;
maintainers = with maintainers; [ matthiasbeyer infinisil ma27 ];
};
}