{ config, lib, pkgs, namespace, ... }: let cfg = config.${namespace}.hardware.raspberry-pi.modesetting; variant = config.${namespace}.hardware.raspberry-pi.variant; in { options.${namespace}.hardware.raspberry-pi.modesetting = { enable = lib.mkEnableOption "enable modesetting dt overlays"; }; config = lib.mkIf cfg.enable { hardware.deviceTree = { overlays = ( if (variant == "5") then [ { name = "vc4-kms-v3d-pi5-overlay"; dtsFile = "${ pkgs.${namespace}.raspberrypi-overlays }/dtbs/raspberrypi-overlays/vc4-kms-v3d-pi5-overlay.dts"; } ] else [ { name = "vc4-fkms-v3d-pi4-overlay"; dtsFile = "${ pkgs.${namespace}.raspberrypi-overlays }/dtbs/raspberrypi-overlays/vc4-fkms-v3d-pi4-overlay.dts"; } ] ); }; }; }