summaryrefslogtreecommitdiffstats
path: root/pkgs/by-name/sw/sword/package.nix
blob: d9496fb3cbb46a7ba1deb64c377341f91879b08b (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
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
{
  lib,
  stdenv,
  fetchurl,
  pkg-config,
  icu,
  clucene-core,

  autoreconfHook,
  bzip2,
  curl,
  xz,
  zlib,
}:

stdenv.mkDerivation (
  finalAttrs:
  let
    # Used on Windows, where libpsl doesn't compile, yet
    curlDep = (curl.override { pslSupport = false; }).overrideAttrs (finalCurlAttrs: {
      buildInputs = [ ]; # Does not need runtimeShellPackage, which is Bash and unsupported on MinGW targets
      # This is the shell script that requires runtimeShellPackage on systems, but we are
      # only interested in the library here, not the binaries
      postInstall = finalCurlAttrs.postInstall + ''
        rm "''${!outputBin}/bin/wcurl"
      '';
    });
  in
  {
    pname = "sword";
    version = "1.9.0";

    src = fetchurl {
      url = "https://www.crosswire.org/ftpmirror/pub/sword/source/v${lib.versions.majorMinor finalAttrs.version}/sword-${finalAttrs.version}.tar.gz";
      hash = "sha256-QkCc894vrxEIUj4sWsB0XSH57SpceO2HjuncwwNCa4o=";
    };

    nativeBuildInputs = [
      pkg-config
    ]
    ++ (lib.optionals stdenv.hostPlatform.isWindows [
      autoreconfHook # The Windows patch modifies autotools files
    ]);

    buildInputs = [
      icu
    ]
    ++ (lib.optionals stdenv.hostPlatform.isUnix [
      clucene-core
      curl
    ])
    ++ (lib.optionals stdenv.hostPlatform.isWindows [
      bzip2
      curlDep
      xz
    ]);

    outputs = [
      "out"
      "dev"
    ];

    prePatch = ''
      patchShebangs .;
    '';

    preConfigure = lib.optionalString stdenv.hostPlatform.isWindows ''
      substituteInPlace configure --replace-fail "-no-undefined" "-Wl,-no-undefined"
    '';

    patches = lib.optional stdenv.hostPlatform.isWindows ./sword-1.9.0-diatheke-includes.patch;

    configureFlags = [
      "--without-conf"
      "--enable-tests=no"
    ]
    ++ (lib.optionals stdenv.hostPlatform.isWindows [
      "--with-xz"
      "--with-bzip2"
      "--with-icuregex"
      "--without-zlib"
    ]);

    makeFlags = lib.optionals stdenv.hostPlatform.isWindows [
      "LDFLAGS=-no-undefined"
    ];

    env = {
      # When placed in nativeBuildInputs, icu.dev is finding the native ICU libs, but setting it
      # explicitly here has it finding the platform appropriate version
      ICU_CONFIG = lib.optionalString stdenv.hostPlatform.isWindows "${icu.dev}/bin/icu-config --noverify";
      CURL_CONFIG = lib.optionalString stdenv.hostPlatform.isWindows "${lib.getDev curlDep}/bin/curl-config";

      CXXFLAGS = (
        builtins.concatStringsSep " " (
          [
            "-Wno-unused-but-set-variable"
            "-Wno-unknown-warning-option"
            # compat with icu61+ https://github.com/unicode-org/icu/blob/release-64-2/icu4c/readme.html#L554
            "-DU_USING_ICU_NAMESPACE=1"
          ]
          ++ (lib.optionals stdenv.hostPlatform.isWindows [
            "-Wint-to-pointer-cast"
            "-fpermissive"
            "-D_ICUSWORD_"
            "-DCURL_STATICLIB"
          ])
        )
      );
    };

    meta = {
      description = "Software framework that allows research manipulation of Biblical texts";
      homepage = "https://www.crosswire.org/sword/";
      longDescription = ''
        The SWORD Project is the CrossWire Bible Society's free Bible software
        project. Its purpose is to create cross-platform open-source tools --
        covered by the GNU General Public License -- that allow programmers and
        Bible societies to write new Bible software more quickly and easily. We
        also create Bible study software for all readers, students, scholars, and
        translators of the Bible, and have a growing collection of many hundred
        texts in around 100 languages.
      '';
      license = lib.licenses.gpl2;
      maintainers = with lib.maintainers; [
        greg
      ];
      platforms = lib.platforms.all;
    };
  }
)