summaryrefslogtreecommitdiff
path: root/poc/web_swarm/.nix/derivation.nix
blob: 31f1e2bb56ef3670da1e8838c55acfc8e0236b64 (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
{ lib
, stdenv
, scons
, clang-tools
, libdatachannel
, pname
, version
, kel
}:

stdenv.mkDerivation {
	pname = "${pname}-web-swarm";
	inherit version;
	src = ./..;

	nativeBuildInputs = [
		scons
		clang-tools
	];

	# Ordinary native derivations, so unlike the webgl module these get their
	# include paths from nix the usual way.
	#
	# libdatachannel ships CMake files but no pkg-config, hence the plain
	# LIBS=['datachannel'] in the SConstruct rather than a pkg-config lookup.
	# Note there is no forstio here: libdatachannel owns the threads and the
	# event handling, and forstio has no WebSocket or WebRTC to offer.
	buildInputs = [
		libdatachannel
		kel.lbm.core
		kel.lbm.swarm
	];

	# No checkPhase, and that is a limitation rather than a choice. The nix build
	# sandbox runs in a network namespace holding only a loopback interface, and
	# ICE finds no usable candidate there -- libdatachannel reports "Failed to
	# gather local ICE candidates" and negotiation never completes. Verified: the
	# same two binaries negotiate and register fine outside the sandbox.
	#
	# The end to end check therefore ships as an executable instead, so it is one
	# command rather than a procedure:
	#
	#   nix-build -A poc.web_swarm.native
	#   ./result/bin/kel_lbm_web_swarm_check
	#
	# The protocol itself is covered natively and in-sandbox by kel.lbm.swarm.
	doCheck = false;

	preferLocalBuild = true;

	outputs = [ "out" ];
}