summary refs log tree commit diff
path: root/pkgs/misc/drivers
diff options
context:
space:
mode:
authorgithub-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>2021-02-27 00:37:54 +0000
committerGitHub <noreply@github.com>2021-02-27 00:37:54 +0000
commite8162c62e3f5e50f14b7c52a5c1c4cec7fc789e2 (patch)
tree21cd4a54b57f8cdd48137e0132a40cfa304fd99c /pkgs/misc/drivers
parent403c2803dce9effe14d7546cba8f7a68fc922917 (diff)
parent84d3bc409b0c1e8acd735120a272e98b2da79a7b (diff)
downloadnixpkgs-e8162c62e3f5e50f14b7c52a5c1c4cec7fc789e2.tar
nixpkgs-e8162c62e3f5e50f14b7c52a5c1c4cec7fc789e2.tar.gz
nixpkgs-e8162c62e3f5e50f14b7c52a5c1c4cec7fc789e2.tar.bz2
nixpkgs-e8162c62e3f5e50f14b7c52a5c1c4cec7fc789e2.tar.lz
nixpkgs-e8162c62e3f5e50f14b7c52a5c1c4cec7fc789e2.tar.xz
nixpkgs-e8162c62e3f5e50f14b7c52a5c1c4cec7fc789e2.tar.zst
nixpkgs-e8162c62e3f5e50f14b7c52a5c1c4cec7fc789e2.zip
Merge staging-next into staging
Diffstat (limited to 'pkgs/misc/drivers')
-rw-r--r--pkgs/misc/drivers/spacenavd/configure-socket-path.patch118
-rw-r--r--pkgs/misc/drivers/spacenavd/default.nix32
2 files changed, 150 insertions, 0 deletions
diff --git a/pkgs/misc/drivers/spacenavd/configure-socket-path.patch b/pkgs/misc/drivers/spacenavd/configure-socket-path.patch
new file mode 100644
index 00000000000..03eb329f4b6
--- /dev/null
+++ b/pkgs/misc/drivers/spacenavd/configure-socket-path.patch
@@ -0,0 +1,118 @@
+diff --git a/src/proto_unix.c b/src/proto_unix.c
+index 998f234..d38452c 100644
+--- a/src/proto_unix.c
++++ b/src/proto_unix.c
+@@ -36,11 +36,14 @@ enum {
+ 
+ static int lsock = -1;
+ 
++static char *spath = NULL;
++
+ int init_unix(void)
+ {
+ 	int s;
+ 	mode_t prev_umask;
+ 	struct sockaddr_un addr;
++	char *sock_path;
+ 
+ 	if(lsock >= 0) return 0;
+ 
+@@ -49,16 +52,18 @@ int init_unix(void)
+ 		return -1;
+ 	}
+ 
+-	unlink(SOCK_NAME);	/* in case it already exists */
++	sock_path = socket_path();
++
++	unlink(sock_path);	/* in case it already exists */
+ 
+ 	memset(&addr, 0, sizeof addr);
+ 	addr.sun_family = AF_UNIX;
+-	strcpy(addr.sun_path, SOCK_NAME);
++	strcpy(addr.sun_path, sock_path);
+ 
+ 	prev_umask = umask(0);
+ 
+ 	if(bind(s, (struct sockaddr*)&addr, sizeof addr) == -1) {
+-		logmsg(LOG_ERR, "failed to bind unix socket: %s: %s\n", SOCK_NAME, strerror(errno));
++		logmsg(LOG_ERR, "failed to bind unix socket: %s: %s\n", sock_path, strerror(errno));
+ 		close(s);
+ 		return -1;
+ 	}
+@@ -68,7 +73,7 @@ int init_unix(void)
+ 	if(listen(s, 8) == -1) {
+ 		logmsg(LOG_ERR, "listen failed: %s\n", strerror(errno));
+ 		close(s);
+-		unlink(SOCK_NAME);
++		unlink(sock_path);
+ 		return -1;
+ 	}
+ 
+@@ -82,7 +87,7 @@ void close_unix(void)
+ 		close(lsock);
+ 		lsock = -1;
+ 
+-		unlink(SOCK_NAME);
++		unlink(socket_path());
+ 	}
+ }
+ 
+@@ -173,3 +178,19 @@ int handle_uevents(fd_set *rset)
+ 
+ 	return 0;
+ }
++
++char *socket_path(void)
++{
++	char *xdg_runtime_dir;
++	if((xdg_runtime_dir = getenv("XDG_RUNTIME_DIR"))) {
++		if ( spath == NULL ) {
++			spath = malloc(strlen(xdg_runtime_dir) + strlen("/spnav.sock") + 1);
++			if ( spath != NULL ) {
++				sprintf(spath, "%s/spnav.sock", xdg_runtime_dir);
++			}
++		};
++		return spath;
++	} else {
++		return DEFAULT_SOCK_NAME;
++	}
++}
+diff --git a/src/proto_unix.h b/src/proto_unix.h
+index 045b379..ec4509c 100644
+--- a/src/proto_unix.h
++++ b/src/proto_unix.h
+@@ -23,6 +23,7 @@ along with this program.  If not, see <http://www.gnu.org/licenses/>.
+ #include "event.h"
+ #include "client.h"
+ 
++char *socket_path(void);
+ int init_unix(void);
+ void close_unix(void);
+ int get_unix_socket(void);
+diff --git a/src/spnavd.c b/src/spnavd.c
+index cbea191..03080da 100644
+--- a/src/spnavd.c
++++ b/src/spnavd.c
+@@ -344,7 +344,7 @@ static int find_running_daemon(void)
+ 	}
+ 	memset(&addr, 0, sizeof addr);
+ 	addr.sun_family = AF_UNIX;
+-	strncpy(addr.sun_path, SOCK_NAME, sizeof addr.sun_path);
++	strncpy(addr.sun_path, socket_path(), sizeof addr.sun_path);
+ 
+ 	if(connect(s, (struct sockaddr*)&addr, sizeof addr) == -1) {
+ 		close(s);
+diff --git a/src/spnavd.h b/src/spnavd.h
+index fa0a916..deea4e0 100644
+--- a/src/spnavd.h
++++ b/src/spnavd.h
+@@ -26,7 +26,8 @@ along with this program.  If not, see <http://www.gnu.org/licenses/>.
+ #define DEF_CFGFILE		"/etc/spnavrc"
+ #define DEF_LOGFILE		"/var/log/spnavd.log"
+ 
+-#define SOCK_NAME	"/var/run/spnav.sock"
++#define DEFAULT_SOCK_NAME	"/run/spnav.sock"
++#define SOCK_NAME_ENV	"SPNAVD_SOCK_LOCATION"
+ #define PIDFILE		"/var/run/spnavd.pid"
+ #define SYSLOG_ID	"spnavd"
+ 
diff --git a/pkgs/misc/drivers/spacenavd/default.nix b/pkgs/misc/drivers/spacenavd/default.nix
new file mode 100644
index 00000000000..1051d469f61
--- /dev/null
+++ b/pkgs/misc/drivers/spacenavd/default.nix
@@ -0,0 +1,32 @@
+{ stdenv, lib, fetchFromGitHub, libX11 }:
+
+stdenv.mkDerivation rec {
+  version = "0.8";
+  pname = "spacenavd";
+
+  src = fetchFromGitHub {
+    owner = "FreeSpacenav";
+    repo = "spacenavd";
+    rev = "v${version}";
+    sha256 = "1zz0cm5cgvp9s5n4nzksl8rb11c7sw214bdafzra74smvqfjcjcf";
+  };
+
+  buildInputs = [ libX11 ];
+
+  patches = [
+    # Changes the socket path from /run/spnav.sock to $XDG_RUNTIME_DIR/spnav.sock
+    # to allow for a user service
+    ./configure-socket-path.patch
+  ];
+
+  configureFlags = [ "--disable-debug"];
+
+  meta = with lib; {
+    homepage = "http://spacenav.sourceforge.net/";
+    description = "Device driver and SDK for 3Dconnexion 3D input devices";
+    longDescription = "A free, compatible alternative, to the proprietary 3Dconnexion device driver and SDK, for their 3D input devices (called 'space navigator', 'space pilot', 'space traveller', etc)";
+    license = licenses.gpl3Plus;
+    platforms = platforms.unix;
+    maintainers = with maintainers; [ sohalt ];
+  };
+}