Official 7" Touchscreen & Raspberry Pi 4

Dear NixOS community,

I’m struggling to get the official Raspberrypi 7" touchscreen to work on a Raspberry Pi 4.
On Raspbian it works out of the box but on NixOS only the display output works.
The touchscreen isn’t recognized as input device…

xinput list on NixOS:

⎡ Virtual core pointer                           id=2    [master pointer  (3)]
⎜   ↳ Virtual core XTEST pointer                 id=4    [slave  pointer  (2)]
⎣ Virtual core keyboard                          id=3    [master keyboard (2)]
    ↳ Virtual core XTEST keyboard                id=5    [slave  keyboard (3)]
    ↳ Cherry USB Keyboard                        id=6    [slave  keyboard (3)]
    ↳ Cherry USB Keyboard System Control         id=7    [slave  keyboard (3)]
    ↳ Cherry USB Keyboard Consumer Control       id=8    [slave  keyboard (3)]

xinput list on Raspbian:

pi@raspberrypi:~ $ DISPLAY=:0.0 xinput -list
⎡ Virtual core pointer                    	id=2	[master pointer  (3)]
⎜   ↳ Virtual core XTEST pointer              	id=4	[slave  pointer  (2)]
⎜   ↳ FT5406 memory based driver              	id=7	[slave  pointer  (2)]
⎣ Virtual core keyboard                   	id=3	[master keyboard (2)]
    ↳ Virtual core XTEST keyboard             	id=5	[slave  keyboard (3)]
    ↳ Cherry GmbH SmartBoard XX44             	id=6	[slave  keyboard (3)]

The NixOS installation was done by following this guide so the current configuration looks similar:

  { config, pkgs, lib, ... }:

  let
    user = "guest";
    password = "guest";
    hostname = "nixos";
  in {
    imports = ["${fetchTarball "https://github.com/NixOS/nixos-hardware/archive/342048461da7fc743e588ee744080c045613a226.tar.gz" }/raspberry-pi/4"];

    fileSystems = {
      "/" = {
        device = "/dev/disk/by-label/NIXOS_SD";
        fsType = "ext4";
        options = [ "noatime" ];
      };
    };

    networking.networkmanager.enable = true;

    environment.systemPackages = with pkgs; [
      vim
    ];

    services.openssh.enable = true;

    users = {
      mutableUsers = false;
      users."${user}" = {
        isNormalUser = true;
        password = password;
        extraGroups = [ "networkmanager" "wheel" ];
      };
    };

    # Enable GPU acceleration
    hardware.raspberry-pi."4".fkms-3d.enable = true;

    services.xserver = {
      enable = true;
      displayManager.lightdm.enable = true;
      desktopManager.xfce.enable = true;
    };

    hardware.pulseaudio.enable = true;
  }

The config.txt file on the boot partition wasn’t changed.

I recognized that the kernel version differs (NixOS: 5.10.52, Raspbian: 4.19.97-v7+).
Does this have something to do with it?
The drivers for the official touchscreen should be in the mainline kernel since 4.21 (source).
Or is a kernel module missing?

And did anybody manage to successfully use a touchscreen with NixOS on the Raspberry Pi 4?

Thanks in advance and best regards!

1 Like

Have you tried linuxPackages_latest, just in case 4.21 support was a backport or somesuch? It seems unlikely, but…

The alternative is that the module to support that touch screen might not be built for nixos, so sleuthing into what that is with modprobe could help.