Skip to content

Commit

Permalink
fetchFromGitHub add LFS support & Spacenav updates (#263120)
Browse files Browse the repository at this point in the history
  • Loading branch information
philiptaron authored Nov 4, 2024
2 parents e9eda50 + 6d3cc74 commit 464adc0
Show file tree
Hide file tree
Showing 6 changed files with 81 additions and 117 deletions.
24 changes: 13 additions & 11 deletions nixos/modules/services/hardware/spacenavd.nix
Original file line number Diff line number Diff line change
@@ -1,21 +1,23 @@
{ 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";
};
};

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;
};
};
}
51 changes: 31 additions & 20 deletions pkgs/applications/misc/spnavcfg/default.nix
Original file line number Diff line number Diff line change
@@ -1,33 +1,44 @@
{ 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/";
Expand All @@ -37,4 +48,4 @@ stdenv.mkDerivation rec {
maintainers = with maintainers; [ gebner ];
mainProgram = "spnavcfg";
};
}
})
5 changes: 3 additions & 2 deletions pkgs/build-support/fetchgithub/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -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 ? { }
Expand All @@ -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 =
Expand All @@ -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";
Expand Down
47 changes: 0 additions & 47 deletions pkgs/development/libraries/libspnav/configure-socket-path.patch

This file was deleted.

22 changes: 11 additions & 11 deletions pkgs/development/libraries/libspnav/default.nix
Original file line number Diff line number Diff line change
@@ -1,26 +1,26 @@
{ 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"];
configureFlags = [ "--disable-debug" ];
makeFlags = [
"CC=${stdenv.cc.targetPrefix}cc"
"AR=${stdenv.cc.targetPrefix}ar"
Expand Down
49 changes: 23 additions & 26 deletions pkgs/misc/drivers/spacenavd/default.nix
Original file line number Diff line number Diff line change
@@ -1,40 +1,37 @@
{ stdenv, lib, fetchFromGitHub, fetchpatch, libX11, IOKit }:

stdenv.mkDerivation rec {
version = "0.8";
{
stdenv,
lib,
fetchFromGitHub,
libXext,
libX11,
IOKit,
}:
stdenv.mkDerivation (finalAttrs: {
pname = "spacenavd";
version = "1.3";

src = fetchFromGitHub {
owner = "FreeSpacenav";
repo = "spacenavd";
rev = "v${version}";
sha256 = "1zz0cm5cgvp9s5n4nzksl8rb11c7sw214bdafzra74smvqfjcjcf";
rev = "refs/tags/v${finalAttrs.version}";
hash = "sha256-26geQYOXjMZZ/FpPpav7zfql0davTBwB4Ir+X1oep9Q=";
};

patches = [
# Fixes Darwin: https://github.com/FreeSpacenav/spacenavd/pull/38
(fetchpatch {
url = "https://github.com/FreeSpacenav/spacenavd/commit/d6a25d5c3f49b9676d039775efc8bf854737c43c.patch";
sha256 = "02pdgcvaqc20qf9hi3r73nb9ds7yk2ps9nnxaj0x9p50xjnhfg5c";
})
# Changes the socket path from /run/spnav.sock to $XDG_RUNTIME_DIR/spnav.sock
# to allow for a user service
./configure-socket-path.patch
# 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
];

buildInputs = [ libX11 ]
++ lib.optional stdenv.hostPlatform.isDarwin IOKit;
buildInputs = [
libX11
libXext
] ++ lib.optional stdenv.hostPlatform.isDarwin IOKit;

configureFlags = [ "--disable-debug" ];

makeFlags = [ "CC=${stdenv.cc.targetPrefix}cc" ];

postInstall = ''
install -Dm644 $src/contrib/systemd/spacenavd.service -t $out/lib/systemd/system
substituteInPlace $out/lib/systemd/system/spacenavd.service \
--replace-fail "/usr/local/bin/spacenavd" "$out/bin/spacenavd"
'';

meta = with lib; {
homepage = "https://spacenav.sourceforge.net/";
description = "Device driver and SDK for 3Dconnexion 3D input devices";
Expand All @@ -43,4 +40,4 @@ stdenv.mkDerivation rec {
platforms = platforms.unix;
maintainers = with maintainers; [ sohalt ];
};
}
})

0 comments on commit 464adc0

Please sign in to comment.