diff --git a/hosts/pianonix/default.nix b/hosts/pianonix/default.nix index dd2063b..792f002 100644 --- a/hosts/pianonix/default.nix +++ b/hosts/pianonix/default.nix @@ -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"; + }; + }; } diff --git a/hosts/pianonix/hardware-configuration.nix b/hosts/pianonix/hardware-configuration.nix index a2e2028..d106d57 100644 --- a/hosts/pianonix/hardware-configuration.nix +++ b/hosts/pianonix/hardware-configuration.nix @@ -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" diff --git a/modules/nixos/piano-led-visualizer.nix b/modules/nixos/piano-led-visualizer.nix index bb48e64..b035e20 100644 --- a/modules/nixos/piano-led-visualizer.nix +++ b/modules/nixos/piano-led-visualizer.nix @@ -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; }; }; }; diff --git a/pkgs/piano-led-visualizer/default.nix b/pkgs/piano-led-visualizer/default.nix index 915a90f..425dc59 100644 --- a/pkgs/piano-led-visualizer/default.nix +++ b/pkgs/piano-led-visualizer/default.nix @@ -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"; diff --git a/pkgs/rpi-ws281x-python/default.nix b/pkgs/rpi-ws281x-python/default.nix index c6e9917..eceacd3 100644 --- a/pkgs/rpi-ws281x-python/default.nix +++ b/pkgs/rpi-ws281x-python/default.nix @@ -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";