nixpkgs/pkgs/applications/misc/ocropus/default.nix
Profpatsch 4a7f99d55d treewide: with stdenv.lib; in meta -> with lib;
Part of: https://github.com/NixOS/nixpkgs/issues/108938

meta = with stdenv.lib;

is a widely used pattern. We want to slowly remove
the `stdenv.lib` indirection and encourage people
to use `lib` directly. Thus let’s start with the meta
field.

This used a rewriting script to mostly automatically
replace all occurances of this pattern, and add the
`lib` argument to the package header if it doesn’t
exist yet.

The script in its current form is available at
https://cs.tvl.fyi/depot@2f807d7f141068d2d60676a89213eaa5353ca6e0/-/blob/users/Profpatsch/nixpkgs-rewriter/default.nix
2021-01-11 10:38:22 +01:00

59 lines
1.5 KiB
Nix

{ lib, stdenv, fetchFromGitHub, fetchurl, pythonPackages, curl }:
let
getmodel = name: sha256: {
inherit name;
src = fetchurl {
url = "http://www.tmbdev.net/ocropy/${name}";
inherit sha256;
};
};
models = [
(getmodel "en-default.pyrnn.gz"
"1xyi3k3p81mfw0491gb1haisazfyi2i18f1wjs1m34ak39qfqjdp")
(getmodel "fraktur.pyrnn.gz"
"1wlwvxn91ilgmlri1hj81arl3mbzxc24ycdnkf5icq4hdi4c6y8b")
];
in
pythonPackages.buildPythonApplication rec {
pname = "ocropus";
version = "1.3.3";
src = fetchFromGitHub {
sha256 = "02p1334mic5cfhvpfphfrbim4036yfd8s2zzpwm0xmm829z71nr7";
rev = "v${version}";
repo = "ocropy";
owner = "tmbdev";
};
propagatedBuildInputs = with pythonPackages; [ curl numpy scipy pillow
matplotlib beautifulsoup4 pygtk lxml ];
enableParallelBuilding = true;
preConfigure = with stdenv.lib; ''
${concatStrings (map (x: "cp -R ${x.src} models/`basename ${x.name}`;")
models)}
substituteInPlace ocrolib/common.py --replace /usr/local $out
substituteInPlace ocrolib/default.py --replace /usr/local $out
'';
doCheck = false; # fails
checkPhase = ''
patchShebangs .
substituteInPlace ./run-test \
--replace 'ocropus-rpred' 'ocropus-rpred -Q $NIX_BUILD_CORES'
PATH=".:$PATH" ./run-test
'';
meta = with lib; {
description = "Open source document analysis and OCR system";
license = licenses.asl20;
homepage = "https://github.com/tmbdev/ocropy/";
maintainers = with maintainers; [ domenkozar ];
platforms = platforms.linux;
};
}