···
14
+
, withExamples ? false
16
+
, withEncryption ? false # or "openssl" or "mbedtls"
20
+
, withPubSub ? false
22
+
# for passthru.tests only
27
+
encryptionBackend = {
28
+
inherit openssl mbedtls;
29
+
}."${withEncryption}" or (throw "Unsupported encryption backend: ${withEncryption}");
32
+
stdenv.mkDerivation (finalAttrs: {
33
+
pname = "open62541";
36
+
src = fetchFromGitHub {
37
+
owner = "open62541";
39
+
rev = "v${finalAttrs.version}";
40
+
sha256 = "sha256-X0kdMKSqKAJvmrd1YcYe1mJpFONqPCALA09xwd6o7BQ=";
41
+
fetchSubmodules = true;
46
+
name = "Ensure-absolute-paths-in-pkg-config-file.patch";
47
+
url = "https://github.com/open62541/open62541/commit/023d4b6b8bdec987f8f3ffee6c09801bbee4fa2d.patch";
48
+
sha256 = "sha256-mq4h32js2RjI0Ljown/01SXA3gc+7+zX8meIcvDPvoA=";
53
+
"-DOPEN62541_VERSION=v${finalAttrs.version}"
55
+
"-DBUILD_SHARED_LIBS=${if stdenv.hostPlatform.isStatic then "OFF" else "ON"}"
56
+
"-DUA_NAMESPACE_ZERO=FULL"
58
+
"-DUA_BUILD_UNIT_TESTS=${if finalAttrs.doCheck then "ON" else "OFF"}"
60
+
++ lib.optional withExamples "-DUA_BUILD_EXAMPLES=ON"
61
+
++ lib.optional (withEncryption != false)
62
+
"-DUA_ENABLE_ENCRYPTION=${lib.toUpper withEncryption}"
63
+
++ lib.optional withPubSub "-DUA_ENABLE_PUBSUB=ON"
66
+
nativeBuildInputs = [
69
+
python3Packages.python
71
+
++ lib.optionals withDoc (with python3Packages; [
77
+
buildInputs = lib.optional (withEncryption != false) encryptionBackend;
79
+
buildFlags = [ "all" ] ++ lib.optional withDoc "doc";
88
+
# Tests must run sequentially to avoid port collisions on localhost
89
+
enableParallelChecking = false;
93
+
lib.optionals (withEncryption == "mbedtls") [
94
+
"encryption_basic128rsa15"
96
+
++ lib.optionals withPubSub [
97
+
# "Cannot set socket option IP_ADD_MEMBERSHIP"
99
+
"check_pubsub_get_state"
100
+
"check_pubsub_publish_rt_levels"
101
+
"check_pubsub_subscribe_config_freeze"
102
+
"check_pubsub_subscribe_rt_levels"
103
+
"check_pubsub_multiple_subscribe_rt_levels"
105
+
regex = "^(${builtins.concatStringsSep "|" disabledTests})\$";
106
+
in lib.optionalString (disabledTests != []) ''
107
+
checkFlagsArray+=(ARGS="-E ${lib.escapeRegex regex}")
110
+
postInstall = lib.optionalString withDoc ''
111
+
# excluded files, see doc/CMakeLists.txt
112
+
rm -r doc/{_sources/,CMakeFiles/,cmake_install.cmake}
114
+
# doc is not installed automatically
115
+
mkdir -p $out/share/doc/open62541
116
+
cp -r doc/ $out/share/doc/open62541/html
117
+
'' + lib.optionalString withExamples ''
118
+
# install sources of examples
119
+
mkdir -p $out/share/open62541
120
+
cp -r ../examples $out/share/open62541
122
+
${lib.optionalString (!stdenv.hostPlatform.isWindows) ''
123
+
# remove .exe suffix
124
+
mv -v $out/bin/ua_server_ctt.exe $out/bin/ua_server_ctt
127
+
# remove duplicate libraries in build/bin/, which cause forbidden
128
+
# references to /build/ in ua_server_ctt
129
+
rm -r bin/libopen62541*
132
+
passthru.tests = let
133
+
open62541Full = encBackend: open62541.override {
135
+
# if (withExamples && withPubSub), one of the example currently fails to build
136
+
#withExamples = true;
137
+
withEncryption = encBackend;
141
+
open62541Full = open62541Full false;
142
+
open62541Full-openssl = open62541Full "openssl";
143
+
open62541Full-mbedtls = open62541Full "mbedtls";
147
+
description = "Open source implementation of OPC UA";
148
+
longDescription = ''
149
+
open62541 (http://open62541.org) is an open source and free implementation
150
+
of OPC UA (OPC Unified Architecture) written in the common subset of the
151
+
C99 and C++98 languages.
152
+
The library is usable with all major compilers and provides the necessary
153
+
tools to implement dedicated OPC UA clients and servers, or to integrate
154
+
OPC UA-based communication into existing applications.
156
+
homepage = "https://www.open62541.org";
157
+
license = licenses.mpl20;
158
+
maintainers = with maintainers; [ panicgh ];
159
+
platforms = platforms.linux;