hostconfig/minus: Add the CEC environnement

This commit is contained in:
Quentin Boyer 2024-07-27 21:56:35 +02:00
parent f1b7eaaa4a
commit 00330b4102
3 changed files with 89 additions and 6 deletions

View file

@ -1,5 +1,13 @@
{ config, pkgs, ... }:
{
config,
pkgs,
lib,
...
}:
{
boot.extraModulePackages = [
(pkgs.pulse8-cec.override { inherit (config.boot.kernelPackages) kernel; })
];
boot.loader.systemd-boot.enable = true;
boot.loader.efi.canTouchEfiVariables = true;
@ -28,7 +36,6 @@
xkbVariant = "dvp";
};
sound.enable = true;
hardware.pulseaudio.enable = false;
security.rtkit.enable = true;
services.pipewire = {
@ -53,10 +60,37 @@
enable = true;
};
environment.systemPackages = [
pkgs.moonlight-qt
pkgs.jstest-gtk
(pkgs.kodi.withPackages (
services.udev.extraRules = ''
SUBSYSTEM=="tty" ACTION=="add" \
ATTRS{manufacturer}=="Pulse-Eight" ATTRS{product}=="CEC Adapter" \
TAG+="systemd" ENV{SYSTEMD_WANTS}="pulse8-cec-attach@$devnode.service"
'';
systemd.services."pulse8-cec-attach@" = {
description = "Configure USB Pulse-Eight serial device at %I";
unitConfig = {
ConditionPathExists = "%I";
};
serviceConfig =
let
systemdLinuxConsoleTools = pkgs.linuxConsoleTools.overrideAttrs (oa: {
makeFlags = oa.makeFlags ++ [ "SYSTEMD_SUPPORT=1" ];
buildInputs = oa.buildInputs ++ (with pkgs; [ systemdLibs ]);
});
in
{
Type = "forking";
ExecStart = "${lib.getExe' systemdLinuxConsoleTools "inputattach"} --daemon --pulse8-cec %I";
};
};
environment.systemPackages = with pkgs; [
moonlight-qt
jstest-gtk
libcec
(kodi.withPackages (
p: with p; [
jellyfin
youtube

View file

@ -26,6 +26,7 @@
flex-launcher = pkgs.callPackage ./flex-launcher.nix { };
mesonlsp = pkgs.callPackage ./mesonlsp { };
push-to-talk = pkgs.callPackage ./push-to-talk.nix { };
pulse8-cec = pkgs.callPackage ./pulse8-cec.nix { };
};
};
}

48
pkgs/pulse8-cec.nix Normal file
View file

@ -0,0 +1,48 @@
{
stdenv,
lib,
linuxPackages,
kernel ? linuxPackages.kernel,
}:
stdenv.mkDerivation {
pname = "pulse8-cec-module";
inherit (kernel)
src
version
postPatch
nativeBuildInputs
;
kernel_dev = kernel.dev;
kernelVersion = kernel.modDirVersion;
modulePath = "drivers/media/cec/usb/pulse8";
buildPhase = ''
BUILT_KERNEL=$kernel_dev/lib/modules/$kernelVersion/build
cp $BUILT_KERNEL/Module.symvers .
cat $BUILT_KERNEL/.config >.config
cp $kernel_dev/vmlinux .
./scripts/config --enable CONFIG_MEDIA_CEC_SUPPORT
./scripts/config --module CONFIG_USB_PULSE8_CEC
make "-j$NIX_BUILD_CORES" modules_prepare
make "-j$NIX_BUILD_CORES" M=$modulePath modules
'';
installPhase = ''
make \
INSTALL_MOD_PATH="$out" \
XZ="xz -T$NIX_BUILD_CORES" \
M="$modulePath" \
modules_install
'';
meta = {
description = "Pulse 8 CEC kernel module";
license = lib.licenses.gpl2;
};
}