summaryrefslogtreecommitdiffstats
path: root/pkgs/by-name/cu/cuneiform/package.nix
blob: 3717c05477a40881447f80b1de5a9d96a2319fc3 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
{
  lib,
  gcc14Stdenv,
  fetchurl,
  cmake,
  imagemagick,
  testers,
}:

# Deprecated: unmaintained, no consumers in nixpkgs as of 2025-10-05, and doesn't compile with gcc 15. Switched to gcc14Stdenv as of 2026-09-13 to fix hydra build error
gcc14Stdenv.mkDerivation (finalAttrs: {
  pname = "cuneiform";
  version = "1.1.0";

  src = fetchurl {
    url = "https://launchpad.net/cuneiform-linux/1.1/1.1/+download/cuneiform-linux-1.1.0.tar.bz2";
    sha256 = "1bdvppyfx2184zmzcylskd87cxv56d8f32jf7g1qc8779l2hszjp";
  };

  patches = [
    (fetchurl {
      url = "https://raw.githubusercontent.com/archlinux/svntogit-community/a2ec92f05de006b56d16ac6a6c370d54a554861a/cuneiform/trunk/build-fix.patch";
      sha256 = "19cmrlx4khn30qqrpyayn7bicg8yi0wpz1x1bvqqrbvr3kwldxyj";
    })
    (fetchurl {
      url = "https://gitweb.gentoo.org/repo/gentoo.git/plain/app-text/cuneiform/files/cuneiform-1.1.0-gcc11.patch?id=fd8e596c6a5eab634656e265c3da5241f5ceee8c";
      sha256 = "14bp2f4dvlgxnpdza1rgszhkbxhp6p7lhgnb1s7c1x7vwdrx0ri7";
    })
    ./gcc14-fix.patch
  ];

  # Workaround build failure on -fno-common toolchains like upstream
  # gcc-10. Otherwise build fails as:
  #   ld: CMakeFiles/rbal.dir/src/statsearchbl.cpp.o:(.bss+0x0):
  #     multiple definition of `minrow'; CMakeFiles/rbal.dir/src/linban.c.o:(.bss+0xa3a): first defined here
  env.NIX_CFLAGS_COMPILE = "-fcommon";

  postPatch = ''
    rm cuneiform_src/Kern/hhh/tigerh/h/strings.h
    substituteInPlace CMakeLists.txt --replace-fail \
      'cmake_minimum_required(VERSION 2.6.2)' \
      'cmake_minimum_required(VERSION 3.10)'
  '';

  # make the install path match the rpath
  postInstall = ''
    if [[ -d ''${!outputLib}/lib64 ]]; then
      mv ''${!outputLib}/lib64 ''${!outputLib}/lib
      ln -s lib ''${!outputLib}/lib64
    fi
  '';

  buildInputs = [ imagemagick ];

  nativeBuildInputs = [ cmake ];

  passthru.tests = testers.testVersion {
    package = finalAttrs.finalPackage;
    command = "cuneiform";
  };

  meta = {
    description = "Multi-language OCR system";
    homepage = "https://launchpad.net/cuneiform-linux";
    license = lib.licenses.bsd3;
    platforms = lib.platforms.linux;
    maintainers = [ lib.maintainers.raskin ];
    mainProgram = "cuneiform";
  };
})