Loading nixos/modules/services/hardware/spacenavd.nix +13 −11 Original line number Diff line number Diff line { config, lib, pkgs, ... }: let cfg = config.hardware.spacenavd; in { { config, lib, pkgs, ... }: let cfg = config.hardware.spacenavd; in { options = { hardware.spacenavd = { enable = lib.mkEnableOption "spacenavd to support 3DConnexion devices"; Loading @@ -10,12 +15,9 @@ in { }; config = lib.mkIf cfg.enable { systemd.user.services.spacenavd = { description = "Daemon for the Spacenavigator 6DOF mice by 3Dconnexion"; wantedBy = [ "graphical.target" ]; serviceConfig = { ExecStart = "${pkgs.spacenavd}/bin/spacenavd -d -l syslog"; }; systemd = { packages = [ pkgs.spacenavd ]; services.spacenavd.enable = true; }; }; } pkgs/applications/misc/spnavcfg/default.nix +31 −20 Original line number Diff line number Diff line { stdenv, lib, fetchFromGitHub, pkg-config, gtk2 }: { stdenv, lib, fetchFromGitHub, fetchpatch, pkg-config, libspnav, libX11, stdenv.mkDerivation rec { # Qt6 support is close: https://github.com/FreeSpacenav/spnavcfg/issues/43 libsForQt5, }: stdenv.mkDerivation (finalAttrs: { pname = "spnavcfg"; version = "0.3.1"; version = "1.1"; src = fetchFromGitHub { owner = "FreeSpacenav"; repo = pname; rev = "v${version}"; sha256 = "180mkdis15gxs79rr3f7hpwa1p6v81bybw37pzzdjnmqwqrc08a0"; repo = "spnavcfg"; rev = "refs/tags/v${finalAttrs.version}"; fetchLFS = true; hash = "sha256-P3JYhZnaCxzJETwC4g5m4xAGBk28/Va7Z/ybqwacIaA="; }; patches = [ # Changes the pidfile path from /run/spnavd.pid to $XDG_RUNTIME_DIR/spnavd.pid # to allow for a user service ./configure-pidfile-path.patch # Changes the config file path from /etc/spnavrc to $XDG_CONFIG_HOME/spnavrc or $HOME/.config/spnavrc # to allow for a user service ./configure-cfgfile-path.patch (fetchpatch { url = "https://github.com/FreeSpacenav/spnavcfg/commit/fd9aa10fb8e19a257398757943b3d8e79906e583.patch"; hash = "sha256-XKEyLAFrA4qRU3zkBozblb/fKtLKsaItze0xv1uLnq0="; }) ]; postPatch = '' sed -i s/4775/775/ Makefile.in ''; nativeBuildInputs = [ pkg-config ]; buildInputs = [ gtk2 ]; nativeBuildInputs = [ pkg-config libsForQt5.wrapQtAppsHook ]; makeFlags = [ "CC=${stdenv.cc.targetPrefix}cc" ]; buildInputs = [ libsForQt5.qtbase libspnav libX11 ]; meta = with lib; { homepage = "https://spacenav.sourceforge.net/"; Loading @@ -37,4 +48,4 @@ stdenv.mkDerivation rec { maintainers = with maintainers; [ gebner ]; mainProgram = "spnavcfg"; }; } }) pkgs/build-support/fetchgithub/default.nix +3 −2 Original line number Diff line number Diff line Loading @@ -4,6 +4,7 @@ lib.makeOverridable ( { owner, repo, rev, name ? "source" , fetchSubmodules ? false, leaveDotGit ? null , deepClone ? false, private ? false, forceFetchGit ? false , fetchLFS ? false , sparseCheckout ? [] , githubBase ? "github.com", varPrefix ? null , meta ? { } Loading @@ -25,7 +26,7 @@ let }; passthruAttrs = removeAttrs args [ "owner" "repo" "rev" "fetchSubmodules" "forceFetchGit" "private" "githubBase" "varPrefix" ]; varBase = "NIX${lib.optionalString (varPrefix != null) "_${varPrefix}"}_GITHUB_PRIVATE_"; useFetchGit = fetchSubmodules || (leaveDotGit == true) || deepClone || forceFetchGit || (sparseCheckout != []); useFetchGit = fetchSubmodules || (leaveDotGit == true) || deepClone || forceFetchGit || fetchLFS || (sparseCheckout != []); # We prefer fetchzip in cases we don't need submodules as the hash # is more stable in that case. fetcher = Loading @@ -52,7 +53,7 @@ let fetcherArgs = (if useFetchGit then { inherit rev deepClone fetchSubmodules sparseCheckout; url = gitRepoUrl; inherit rev deepClone fetchSubmodules sparseCheckout fetchLFS; url = gitRepoUrl; } // lib.optionalAttrs (leaveDotGit != null) { inherit leaveDotGit; } else { url = "${baseUrl}/archive/${rev}.tar.gz"; Loading pkgs/development/libraries/libspnav/configure-socket-path.patchdeleted 100644 → 0 +0 −47 Original line number Diff line number Diff line diff --git a/spnav.c b/spnav.c index f9e10f8..27149f7 100644 --- a/spnav.c +++ b/spnav.c @@ -36,7 +36,7 @@ OF SUCH DAMAGE. #include <sys/select.h> #include "spnav.h" -#define SPNAV_SOCK_PATH "/var/run/spnav.sock" +#define DEFAULT_SPNAV_SOCK_PATH "/run/spnav.sock" #ifdef USE_X11 #include <X11/Xlib.h> @@ -70,6 +70,24 @@ static struct event_node *ev_queue, *ev_queue_tail; /* AF_UNIX socket used for alternative communication with daemon */ static int sock = -1; +static char *spath = NULL; + +static char *socket_path() +{ + 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); + } + } + if(access(spath, F_OK) != -1){ + return spath; + } + } + return DEFAULT_SPNAV_SOCK_PATH; +} int spnav_open(void) { @@ -92,7 +110,7 @@ int spnav_open(void) memset(&addr, 0, sizeof addr); addr.sun_family = AF_UNIX; - strncpy(addr.sun_path, SPNAV_SOCK_PATH, sizeof(addr.sun_path)); + strncpy(addr.sun_path, socket_path(), sizeof(addr.sun_path)); if(connect(s, (struct sockaddr*)&addr, sizeof addr) == -1) { pkgs/development/libraries/libspnav/default.nix +11 −11 Original line number Diff line number Diff line { stdenv, lib, fetchFromGitHub, libX11, fixDarwinDylibNames }: { stdenv, lib, fetchFromGitHub, libX11, fixDarwinDylibNames, }: stdenv.mkDerivation rec { version = "0.2.3"; pname = "libspnav"; version = "1.1"; src = fetchFromGitHub { owner = "FreeSpacenav"; repo = "libspnav"; rev = "${pname}-${version}"; sha256 = "098h1jhlj87axpza5zgy58prp0zn94wyrbch6x0s7q4mzh7dc8ba"; rev = "refs/tags/v${version}"; hash = "sha256-qBewSOiwf5iaGKLGRWOQUoHkUADuH8Q1mJCLiWCXmuQ="; }; nativeBuildInputs = lib.optional stdenv.hostPlatform.isDarwin fixDarwinDylibNames; 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" ]; makeFlags = [ "CC=${stdenv.cc.targetPrefix}cc" Loading Loading
nixos/modules/services/hardware/spacenavd.nix +13 −11 Original line number Diff line number Diff line { config, lib, pkgs, ... }: let cfg = config.hardware.spacenavd; in { { config, lib, pkgs, ... }: let cfg = config.hardware.spacenavd; in { options = { hardware.spacenavd = { enable = lib.mkEnableOption "spacenavd to support 3DConnexion devices"; Loading @@ -10,12 +15,9 @@ in { }; config = lib.mkIf cfg.enable { systemd.user.services.spacenavd = { description = "Daemon for the Spacenavigator 6DOF mice by 3Dconnexion"; wantedBy = [ "graphical.target" ]; serviceConfig = { ExecStart = "${pkgs.spacenavd}/bin/spacenavd -d -l syslog"; }; systemd = { packages = [ pkgs.spacenavd ]; services.spacenavd.enable = true; }; }; }
pkgs/applications/misc/spnavcfg/default.nix +31 −20 Original line number Diff line number Diff line { stdenv, lib, fetchFromGitHub, pkg-config, gtk2 }: { stdenv, lib, fetchFromGitHub, fetchpatch, pkg-config, libspnav, libX11, stdenv.mkDerivation rec { # Qt6 support is close: https://github.com/FreeSpacenav/spnavcfg/issues/43 libsForQt5, }: stdenv.mkDerivation (finalAttrs: { pname = "spnavcfg"; version = "0.3.1"; version = "1.1"; src = fetchFromGitHub { owner = "FreeSpacenav"; repo = pname; rev = "v${version}"; sha256 = "180mkdis15gxs79rr3f7hpwa1p6v81bybw37pzzdjnmqwqrc08a0"; repo = "spnavcfg"; rev = "refs/tags/v${finalAttrs.version}"; fetchLFS = true; hash = "sha256-P3JYhZnaCxzJETwC4g5m4xAGBk28/Va7Z/ybqwacIaA="; }; patches = [ # Changes the pidfile path from /run/spnavd.pid to $XDG_RUNTIME_DIR/spnavd.pid # to allow for a user service ./configure-pidfile-path.patch # Changes the config file path from /etc/spnavrc to $XDG_CONFIG_HOME/spnavrc or $HOME/.config/spnavrc # to allow for a user service ./configure-cfgfile-path.patch (fetchpatch { url = "https://github.com/FreeSpacenav/spnavcfg/commit/fd9aa10fb8e19a257398757943b3d8e79906e583.patch"; hash = "sha256-XKEyLAFrA4qRU3zkBozblb/fKtLKsaItze0xv1uLnq0="; }) ]; postPatch = '' sed -i s/4775/775/ Makefile.in ''; nativeBuildInputs = [ pkg-config ]; buildInputs = [ gtk2 ]; nativeBuildInputs = [ pkg-config libsForQt5.wrapQtAppsHook ]; makeFlags = [ "CC=${stdenv.cc.targetPrefix}cc" ]; buildInputs = [ libsForQt5.qtbase libspnav libX11 ]; meta = with lib; { homepage = "https://spacenav.sourceforge.net/"; Loading @@ -37,4 +48,4 @@ stdenv.mkDerivation rec { maintainers = with maintainers; [ gebner ]; mainProgram = "spnavcfg"; }; } })
pkgs/build-support/fetchgithub/default.nix +3 −2 Original line number Diff line number Diff line Loading @@ -4,6 +4,7 @@ lib.makeOverridable ( { owner, repo, rev, name ? "source" , fetchSubmodules ? false, leaveDotGit ? null , deepClone ? false, private ? false, forceFetchGit ? false , fetchLFS ? false , sparseCheckout ? [] , githubBase ? "github.com", varPrefix ? null , meta ? { } Loading @@ -25,7 +26,7 @@ let }; passthruAttrs = removeAttrs args [ "owner" "repo" "rev" "fetchSubmodules" "forceFetchGit" "private" "githubBase" "varPrefix" ]; varBase = "NIX${lib.optionalString (varPrefix != null) "_${varPrefix}"}_GITHUB_PRIVATE_"; useFetchGit = fetchSubmodules || (leaveDotGit == true) || deepClone || forceFetchGit || (sparseCheckout != []); useFetchGit = fetchSubmodules || (leaveDotGit == true) || deepClone || forceFetchGit || fetchLFS || (sparseCheckout != []); # We prefer fetchzip in cases we don't need submodules as the hash # is more stable in that case. fetcher = Loading @@ -52,7 +53,7 @@ let fetcherArgs = (if useFetchGit then { inherit rev deepClone fetchSubmodules sparseCheckout; url = gitRepoUrl; inherit rev deepClone fetchSubmodules sparseCheckout fetchLFS; url = gitRepoUrl; } // lib.optionalAttrs (leaveDotGit != null) { inherit leaveDotGit; } else { url = "${baseUrl}/archive/${rev}.tar.gz"; Loading
pkgs/development/libraries/libspnav/configure-socket-path.patchdeleted 100644 → 0 +0 −47 Original line number Diff line number Diff line diff --git a/spnav.c b/spnav.c index f9e10f8..27149f7 100644 --- a/spnav.c +++ b/spnav.c @@ -36,7 +36,7 @@ OF SUCH DAMAGE. #include <sys/select.h> #include "spnav.h" -#define SPNAV_SOCK_PATH "/var/run/spnav.sock" +#define DEFAULT_SPNAV_SOCK_PATH "/run/spnav.sock" #ifdef USE_X11 #include <X11/Xlib.h> @@ -70,6 +70,24 @@ static struct event_node *ev_queue, *ev_queue_tail; /* AF_UNIX socket used for alternative communication with daemon */ static int sock = -1; +static char *spath = NULL; + +static char *socket_path() +{ + 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); + } + } + if(access(spath, F_OK) != -1){ + return spath; + } + } + return DEFAULT_SPNAV_SOCK_PATH; +} int spnav_open(void) { @@ -92,7 +110,7 @@ int spnav_open(void) memset(&addr, 0, sizeof addr); addr.sun_family = AF_UNIX; - strncpy(addr.sun_path, SPNAV_SOCK_PATH, sizeof(addr.sun_path)); + strncpy(addr.sun_path, socket_path(), sizeof(addr.sun_path)); if(connect(s, (struct sockaddr*)&addr, sizeof addr) == -1) {
pkgs/development/libraries/libspnav/default.nix +11 −11 Original line number Diff line number Diff line { stdenv, lib, fetchFromGitHub, libX11, fixDarwinDylibNames }: { stdenv, lib, fetchFromGitHub, libX11, fixDarwinDylibNames, }: stdenv.mkDerivation rec { version = "0.2.3"; pname = "libspnav"; version = "1.1"; src = fetchFromGitHub { owner = "FreeSpacenav"; repo = "libspnav"; rev = "${pname}-${version}"; sha256 = "098h1jhlj87axpza5zgy58prp0zn94wyrbch6x0s7q4mzh7dc8ba"; rev = "refs/tags/v${version}"; hash = "sha256-qBewSOiwf5iaGKLGRWOQUoHkUADuH8Q1mJCLiWCXmuQ="; }; nativeBuildInputs = lib.optional stdenv.hostPlatform.isDarwin fixDarwinDylibNames; 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" ]; makeFlags = [ "CC=${stdenv.cc.targetPrefix}cc" Loading