pianonix: try getting piano-led-visualizer to run

Still did not work, using raspberrypi os
This commit is contained in:
2025-12-06 09:20:52 +01:00
parent 194d4bcec0
commit a12b50edfa
5 changed files with 54 additions and 13 deletions

View File

@@ -26,6 +26,26 @@
../common/optional/avahi.nix
];
environment.systemPackages = [
(pkgs.python3.withPackages (p:
with p; [
numpy
pillow
flask
rpi-gpio
webcolors
psutil
mido
rtmidi-python
spidev
waitress
websockets
werkzeug
pkgs.frajul.rpi-ws281x-python
]))
];
# disko.devices.disk.main.device = "/dev/mmcblk1";
# enabled by fish, disabling speeds up builds
@@ -169,7 +189,7 @@
};
};
networking.firewall.enable = true;
networking.firewall.enable = false;
networking.firewall.allowedTCPPorts = [
5900 # for vnc
];
@@ -201,7 +221,7 @@
hardware.raspberry-pi."4".apply-overlays-dtmerge.enable = true;
hardware.deviceTree = {
enable = true;
filter = lib.mkForce "*-rpi-*.dtb";
filter = lib.mkForce "*-rpi-4*.dtb";
overlays = [
{
name = "spi";
@@ -234,4 +254,23 @@
## My own Piano LED Visualizer
services.piano-led-visualizer.enable = true;
## Crude fix for avahi
systemd.timers.avahiRestart = {
description = "Restart avahi-daemon every 5 minutes";
wantedBy = ["timers.target"];
timerConfig = {
OnBootSec = "5min";
OnUnitActiveSec = "5min";
Unit = "avahiRestart.service";
};
};
systemd.services.avahiRestart = {
description = "Restart avahi-daemon service";
serviceConfig = {
Type = "oneshot";
ExecStart = "${pkgs.systemd}/bin/systemctl restart avahi-daemon.service";
};
};
}

View File

@@ -15,6 +15,7 @@
boot.kernelModules = [];
boot.extraModulePackages = [];
boot.kernelPackages = pkgs.linuxKernel.packages.linux_rpi4;
boot.blacklistedKernelModules = ["snd_bcm2835"]; # Disables sound, required for ws281x to work
# boot.supportedFilesystems = lib.mkForce [
# # remove zfs, since its incompatible with latest kernel
# "vfat"

View File

@@ -26,6 +26,9 @@ in {
users.users.${cfg.user} = {
isSystemUser = true;
group = cfg.group;
createHome = true;
home = "/home/${cfg.user}";
extraGroups = ["wheel" "gpio"];
};
users.groups.${cfg.group} = {};
@@ -36,11 +39,12 @@ in {
wantedBy = ["multi-user.target"];
serviceConfig = {
WorkingDirectory = "/home/${cfg.user}/Piano-LED-Visualizer";
ExecStart = "${pkgs.frajul.piano-led-visualizer}/bin/piano-led-visualizer";
Restart = "always";
Type = "simple";
User = cfg.user;
Group = cfg.group;
# User = cfg.user;
# Group = cfg.group;
};
};
};

View File

@@ -1,10 +1,12 @@
{
lib,
python3,
callPackage,
fetchFromGitHub,
...
}: let
pythonPackages = python3.pkgs;
rpi-ws281x-python = callPackage ../rpi-ws281x-python {inherit python3;};
in
pythonPackages.buildPythonApplication rec {
pname = "piano-led-visualizer";
@@ -36,7 +38,8 @@ in
waitress
websockets
werkzeug
# rpi_ws281x
rpi-ws281x-python
];
format = "setuptools";

View File

@@ -10,15 +10,12 @@ python3.pkgs.buildPythonPackage rec {
src = fetchFromGitHub {
owner = "rpi-ws281x";
repo = "rpi-ws281x-pytho";
repo = "rpi-ws281x-python";
rev = "v${version}";
sha256 = "sha256-tnjvFDBa+sNX6dK6/I1/rRt62k15kTP+9J8eyFRFs/I=";
sha256 = "sha256-CVPibDs1QLeXhtoEBw3JplKIIUpzahjgJKy8GVy99Wk=";
fetchSubmodules = true;
deepClone = true;
};
# sourceRoot = "${src}/library";
format = "setuptools";
propagatedBuildInputs = with python3.pkgs; [
@@ -30,9 +27,6 @@ python3.pkgs.buildPythonPackage rec {
sourceRoot="$sourceRoot/library"
'';
# Some of the bindings compile C code, so you may need these
nativeBuildInputs = [python3.pkgs.setuptools pkgs.scons];
meta = with lib; {
description = "Python bindings for the rpi_ws281x C library";
homepage = "https://github.com/rpi-ws281x/rpi-ws281x-python";