Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Package request: hid-fanatecff #271117

Open
rake5k opened this issue Nov 30, 2023 · 6 comments
Open

Package request: hid-fanatecff #271117

rake5k opened this issue Nov 30, 2023 · 6 comments

Comments

@rake5k
Copy link
Contributor

rake5k commented Nov 30, 2023

Project description

Linux module driver for Fanatec driving wheels.

Metadata

Priorities

Add a 👍 reaction to issues you find important.

@PhilT
Copy link

PhilT commented Dec 7, 2023

@rake5k Have you got a working config for this? If not I'm working on it.

@rake5k
Copy link
Contributor Author

rake5k commented Dec 10, 2023 via email

@PhilT
Copy link

PhilT commented Dec 11, 2023

I've never packaged anything in NixOS before (only been using it for a couple of months) but I managed to get a derivation working locally. Tested with fftest (linuxConsoleTools) and rFactor 2 (Needs a negative value for Steering effects strength (I used -60% or -6000 in Controller.JSON).

❯ cat src/hid-fanatecff/default.nix

{ lib
, stdenv
, fetchFromGitHub
, kernel
, kmod
, linuxConsoleTools
}:

let moduledir = "lib/modules/${kernel.version}/kernel/drivers/hid";
in
stdenv.mkDerivation rec {
  pname = "hid-fanatecff";
  version = "0.0.2";
  name = "hid-fanatecff-${version}-${kernel.version}";

  src = fetchFromGitHub {
    owner = "gotzl";
    repo = "hid-fanatecff";
    rev = "next";
    sha256 = "hHxh0VFHwLyAxUkXSpjc2VlXdyoABoenc2sAsewhLhs=";
  };

  hardeningDisable = [ "pic" "format" ];
  nativeBuildInputs = kernel.moduleBuildDependencies;

  patchPhase = ''
    mkdir -p $out/lib/udev/rules.d
    mkdir -p $out/${moduledir}
    substituteInPlace Makefile --replace "/etc/udev/rules.d" "$out/lib/udev/rules.d"
    substituteInPlace fanatec.rules --replace "/usr/bin/evdev-joystick" "${linuxConsoleTools}/bin/evdev-joystick" --replace "GROUP:=\"plugdev\"" "TAG+=\"uaccess\""
    sed -i '/depmod/d' Makefile
  '';

  makeFlags = [
    "KVERSION=${kernel.modDirVersion}"
    "KDIR=${kernel.dev}/lib/modules/${kernel.modDirVersion}/build"
    "MODULEDIR=$(out)/${moduledir}"
  ];
}
❯ cat src/configuration.nix
{ config, pkgs, ... }:

let fanatecff = pkgs.linuxPackages.callPackage ./hid-fanatecff/default.nix {};
in
{
  boot.extraModulePackages = [ fanatecff ];
  services.udev.packages = [ fanatecff ];
  boot.kernelModules = [ "hid-fanatec" ];

  environment.systemPackages = with pkgs; [
  ];
}

Full repo is here and that configuration.nix file is actually part of a bigger config here.

I will be taking a look into packaging it into nixpkgs when I get the chance.

@PhilT
Copy link

PhilT commented Dec 12, 2023

I'm going to hold off adding this to nixpkgs for now until more people here request it. Happy to do it once more 👍 are added.

@PhilT
Copy link

PhilT commented Jan 11, 2024

I've updated my nix config to work with the latest hid-fanatecff
https://github.com/PhilT/nixos-files/blob/main/src/hid-fanatecff/default.nix

@nixos-discourse
Copy link

This issue has been mentioned on NixOS Discourse. There might be relevant details there:

https://discourse.nixos.org/t/how-to-add-a-local-package-to-boot-extramodulepackages/36614/12

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants