15 , withExamples ? false
17 , withEncryption ? false # or "openssl" or "mbedtls"
21 # for passthru.tests only
27 inherit openssl mbedtls;
28 }."${withEncryption}" or (throw "Unsupported encryption backend: ${withEncryption}");
31 stdenv.mkDerivation (finalAttrs: {
35 src = fetchFromGitHub {
38 rev = "v${finalAttrs.version}";
39 hash = "sha256-ziKtRojc/MqRPG//HPESzJa0W0YaHOlz2Mi35UujOkU=";
40 fetchSubmodules = true;
44 (lib.cmakeFeature "OPEN62541_VERSION" finalAttrs.src.rev)
45 (lib.cmakeFeature "UA_NAMESPACE_ZERO" "FULL")
46 (lib.cmakeBool "BUILD_SHARED_LIBS" (!stdenv.hostPlatform.isStatic))
48 # Note comment near doCheck
49 (lib.cmakeBool "UA_BUILD_UNIT_TESTS" finalAttrs.finalPackage.doCheck)
50 (lib.cmakeBool "UA_ENABLE_ALLOW_REUSEADDR" finalAttrs.finalPackage.doCheck)
52 (lib.cmakeBool "UA_BUILD_EXAMPLES" withExamples)
53 ] ++ lib.optionals (withEncryption != false) [
54 (lib.cmakeFeature "UA_ENABLE_ENCRYPTION" (lib.toUpper withEncryption))
60 python3Packages.python
61 ] ++ lib.optionals withDoc (with python3Packages; [
67 buildInputs = lib.optional (withEncryption != false) encryptionBackend;
69 buildFlags = [ "all" ] ++ lib.optional withDoc "doc";
71 # Tests must normally be disabled because they require
72 # -DUA_ENABLE_ALLOW_REUSEADDR=ON. The option must not be used in production,
73 # since it is a security risk.
74 # See https://github.com/open62541/open62541/issues/6407
83 # Tests must run sequentially to avoid port collisions on localhost
84 enableParallelChecking = false;
88 # error "Could not create a raw Ethernet socket (are you root?)"
91 # Cannot set socket option IP_ADD_MEMBERSHIP
92 "check_pubsub_publish"
93 "check_pubsub_publish_json"
94 "check_pubsub_connection_udp"
95 "check_pubsub_get_state"
96 "check_pubsub_publisherid"
97 "check_pubsub_subscribe"
98 "check_pubsub_publishspeed"
99 "check_pubsub_subscribe_config_freeze"
100 "check_pubsub_subscribe_rt_levels"
101 "check_pubsub_multiple_subscribe_rt_levels"
102 "check_pubsub_config_freeze"
103 "check_pubsub_publish_rt_levels"
105 # Could not find the interface
106 "check_pubsub_connection_ethernet"
107 "check_pubsub_connection_ethernet_etf"
108 "check_pubsub_publish_ethernet_etf"
109 "check_pubsub_informationmodel"
110 "check_pubsub_informationmodel_methods"
112 regex = "^(${builtins.concatStringsSep "|" disabledTests})\$";
113 in lib.optionalString (disabledTests != []) ''
114 checkFlagsArray+=(ARGS="-E ${lib.escapeRegex regex}")
117 postInstall = lib.optionalString withDoc ''
118 # excluded files, see doc/CMakeLists.txt
119 rm -r doc/{_sources/,CMakeFiles/,cmake_install.cmake}
121 # doc is not installed automatically
122 mkdir -p $out/share/doc/open62541
123 cp -r doc/ $out/share/doc/open62541/html
124 '' + lib.optionalString withExamples ''
125 # install sources of examples
126 mkdir -p $out/share/open62541
127 cp -r ../examples $out/share/open62541
129 ${lib.optionalString (!stdenv.hostPlatform.isWindows) ''
131 mv -v $out/bin/ua_server_ctt.exe $out/bin/ua_server_ctt
134 # remove duplicate libraries in build/bin/, which cause forbidden
135 # references to /build/ in ua_server_ctt
136 rm -r bin/libopen62541*
139 passthru.updateScript = nix-update-script { };
142 open62541Full = encBackend: (open62541.overrideAttrs (_: {
146 # if withExamples, one of the example currently fails to build
147 #withExamples = true;
148 withEncryption = encBackend;
151 open62541WithTests = finalAttrs.finalPackage.overrideAttrs (_: { doCheck = true; });
152 open62541Full = open62541Full false;
153 open62541Full-openssl = open62541Full "openssl";
154 open62541Full-mbedtls = open62541Full "mbedtls";
158 description = "Open source implementation of OPC UA";
160 open62541 (http://open62541.org) is an open source and free implementation
161 of OPC UA (OPC Unified Architecture) written in the common subset of the
162 C99 and C++98 languages.
163 The library is usable with all major compilers and provides the necessary
164 tools to implement dedicated OPC UA clients and servers, or to integrate
165 OPC UA-based communication into existing applications.
167 homepage = "https://www.open62541.org";
168 changelog = "https://github.com/open62541/open62541/releases/tag/v${finalAttrs.version}";
169 license = licenses.mpl20;
170 maintainers = with maintainers; [ panicgh ];
171 platforms = platforms.linux;