nixpkgs/pkgs/by-name/li/libwebsockets/package.nix
Silvan Mosberger 4f0dadbf38 treewide: format all inactive Nix files
After final improvements to the official formatter implementation,
this commit now performs the first treewide reformat of Nix files using it.
This is part of the implementation of RFC 166.

Only "inactive" files are reformatted, meaning only files that
aren't being touched by any PR with activity in the past 2 months.
This is to avoid conflicts for PRs that might soon be merged.
Later we can do a full treewide reformat to get the rest,
which should not cause as many conflicts.

A CI check has already been running for some time to ensure that new and
already-formatted files are formatted, so the files being reformatted here
should also stay formatted.

This commit was automatically created and can be verified using

    nix-build a08b3a4d19.tar.gz \
      --argstr baseRev b32a094368
    result/bin/apply-formatting $NIXPKGS_PATH
2024-12-10 20:26:33 +01:00

96 lines
2.4 KiB
Nix

{
lib,
stdenv,
fetchFromGitHub,
cmake,
openssl,
zlib,
libuv,
removeReferencesTo,
# External poll is required for e.g. mosquitto, but discouraged by the maintainer.
withExternalPoll ? false,
}:
stdenv.mkDerivation rec {
pname = "libwebsockets";
version = "4.3.3";
src = fetchFromGitHub {
owner = "warmcat";
repo = "libwebsockets";
rev = "v${version}";
hash = "sha256-IXA9NUh55GtZmn4BhCXntVdHcKZ34iZIJ/0wlySj0/M=";
};
outputs = [
"out"
"dev"
];
buildInputs = [
openssl
zlib
libuv
];
nativeBuildInputs = [
cmake
removeReferencesTo
];
cmakeFlags =
[
"-DLWS_WITH_PLUGINS=ON"
"-DLWS_WITH_IPV6=ON"
"-DLWS_WITH_SOCKS5=ON"
"-DDISABLE_WERROR=ON"
"-DLWS_BUILD_HASH=no_hash"
]
++ lib.optional (stdenv.hostPlatform != stdenv.buildPlatform) "-DLWS_WITHOUT_TESTAPPS=ON"
++ lib.optional withExternalPoll "-DLWS_WITH_EXTERNAL_POLL=ON"
++ (
if stdenv.hostPlatform.isStatic then
[ "-DLWS_WITH_SHARED=OFF" ]
else
[
"-DLWS_WITH_STATIC=OFF"
"-DLWS_LINK_TESTAPPS_DYNAMIC=ON"
]
);
postInstall = ''
find "$out" -type f -exec remove-references-to -t ${stdenv.cc.cc} '{}' +
# Fix path that will be incorrect on move to "dev" output.
substituteInPlace "$out/lib/cmake/libwebsockets/LibwebsocketsTargets-release.cmake" \
--replace "\''${_IMPORT_PREFIX}" "$out"
# The package builds a few test programs that are not usually necessary.
# Move those to the dev output.
moveToOutput "bin/libwebsockets-test-*" "$dev"
moveToOutput "share/libwebsockets-test-*" "$dev"
'';
# $out/share/libwebsockets-test-server/plugins/libprotocol_*.so refers to crtbeginS.o
disallowedReferences = [ stdenv.cc.cc ];
meta = with lib; {
description = "Light, portable C library for websockets";
longDescription = ''
Libwebsockets is a lightweight pure C library built to
use minimal CPU and memory resources, and provide fast
throughput in both directions.
'';
homepage = "https://libwebsockets.org/";
# Relicensed from LGPLv2.1+ to MIT with 4.0. Licensing situation
# is tricky, see https://github.com/warmcat/libwebsockets/blob/main/LICENSE
license = with licenses; [
mit
publicDomain
bsd3
asl20
];
maintainers = with maintainers; [ mindavi ];
platforms = platforms.all;
};
}