NixOS / nixpkgs

Nix Packages collection & NixOS
MIT License
18.39k stars 14.34k forks source link

Package request: hid-fanatecff #271117

Open rake5k opened 1 year ago

rake5k commented 1 year ago

Project description

Linux module driver for Fanatec driving wheels.

Metadata

Priorities

Add a :+1: reaction to issues you find important.

PhilT commented 12 months ago

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

rake5k commented 11 months ago

Not at all, thank you a lot for looking into it! But I am glad to help out with testing if it would help. On Thursday, December 7th, 2023 at 23:00, Phil A Thompson @.***> wrote:

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

— Reply to this email directly, view it on GitHub, or unsubscribe. You are receiving this because you were mentioned.[https://mail.proton.me/api/core/v4/images?Url=https%3A%2F%2Fgithub.com%2Fnotifications%2Fbeacon%2FADDHT4KBWIOCXWOVJS5F2IDYII4A7A5CNFSM6AAAAABAATPINGWGG33NNVSW45C7OR4XAZNMJFZXG5LFINXW23LFNZ2KUY3PNVWWK3TUL5UWJTTOBJUL4.gif&DryRun=0&UID=33ljwl65sijafmrg6zc75tlsrz6a2iji]

PhilT commented 11 months ago

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 commented 11 months ago

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

PhilT commented 10 months ago

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 commented 6 months ago

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

sigonze commented 4 months ago

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

I have tested it and it is working for me. I only had to use the default kernel instead of xanmod to avoid an error during kernel version check. Since I am a newcomer on NixOS I did not figure out how to deal with it yet. Thanks for the sharing.

sigonze commented 4 months ago

Finally I was able to make it work with xanmod. The solution is to replace ${kernel.version} by ${kernel.modDirVersion}. https://github.com/sigonze/nixos-config/blob/main/hid-fanatecff/default.nix For udev rules, games group has to be created and linuxConsoleTools has to be installed.