Add colorchord service to raven

This commit is contained in:
Jakob Lechner 2022-11-04 22:42:45 +00:00
parent 7f2e0ea8e9
commit a3ce6223b1
No known key found for this signature in database
GPG key ID: 996082EFB5906C10
4 changed files with 115 additions and 22 deletions

View file

@ -1,31 +1,10 @@
{ inputs, lib, pkgs, ... }:
let
ledDevices = {
traverse = {
leds = 116;
host = "wled-Traverse";
};
nhecke = {
leds = 75;
host = "wled-Nhecke";
};
printerbench = {
leds = 80;
host = "wled-Printerbench";
};
resedaraum = {
leds = 285;
host = "wled-Resedaraum";
loop = true;
};
kanister = {
leds = 43;
host = "wled-Kanister";
};
dj-table-floor-02 = {
leds = 300;
host = "wled-DJ-Table-Floor-02";
};
bar = {
leds = 300;
host = "wled-Bar";

View file

@ -72,7 +72,7 @@
};
jalr = {
isNormalUser = true;
extraGroups = [ "wheel" "docker" ];
extraGroups = [ "wheel" "docker" "audio" ];
openssh.authorizedKeys.keys = config.fablab.pubkeys.users.jalr;
};
};

View file

@ -0,0 +1,113 @@
{ inputs, lib, pkgs, ... }:
let
ledDevices = {
workbench-1 = {
leds = 87 * 2;
host = "wled-Workbench-1";
};
workbench-2 = {
leds = 87 * 2;
host = "wled-Workbench-2";
};
elektrodecke = {
leds = 87 * 2;
host = "wled-Elektrodecke";
};
traverse = {
leds = 235;
host = "wled-Traverse";
};
nhecke = {
leds = 75;
host = "wled-Nhecke";
};
printerbench = {
leds = 80;
host = "wled-Printerbench";
};
resedaraum = {
leds = 285;
host = "wled-Resedaraum";
loop = true;
};
};
soundDevices = {
sink = "alsa_output.usb-Burr-Brown_from_TI_USB_Audio_DAC-00.analog-stereo";
};
devicesProduct = lib.fold
(soundDevice: acc: acc // lib.mapAttrs'
(ledDevice: value: lib.nameValuePair "${ledDevice}-${soundDevice.name}" (value // {
source = soundDevice.id;
}))
ledDevices)
{ }
(lib.attrValues (lib.mapAttrs (n: v: { name = n; id = v; }) soundDevices));
in
{
environment.systemPackages = with pkgs; [
colorchord2
];
environment.etc = lib.mapAttrs'
(name: config: lib.nameValuePair
"colorchord/${name}.conf"
{
text = ''
# Basic
outdrivers = DisplayNetwork, OutputLinear
headless = 1
# Audio input
amplify = 10
samplerate = 48000
devrecord = ${config.source}
# Visualiser
cpu_autolimit = 1
satamp = 1
# LED config
leds = ${toString config.leds}
is_loop = ${if config ? loop && config.loop then "1" else "0"}
light_siding = 1.5
led_floor = 0.1
steady_bright = 1
fliprg = 0
# WLED
wled_realtime = 1
port = 19446
address = ${config.host}
wled_timeout = 2
skipfirst = 0
'';
})
devicesProduct;
systemd.user.services = builtins.listToAttrs (map
(soundDevice: lib.nameValuePair
"colorchord-${soundDevice}@"
{
partOf = [ "colorchord-${soundDevice}.target" ];
serviceConfig = {
ExecStart = ''
${pkgs.colorchord2}/bin/colorchord /etc/colorchord/%i-${soundDevice}.conf
'';
Restart = "always";
};
})
(lib.attrNames soundDevices));
systemd.user.targets = builtins.listToAttrs (map
(soundDevice: lib.nameValuePair
"colorchord-${soundDevice}"
{
wants = map (ledDevice: "colorchord-${soundDevice}@${ledDevice}.service") (lib.attrNames ledDevices);
})
(lib.attrNames soundDevices));
nixpkgs.overlays = with inputs; [
sbruder-overlay.overlay
];
}

View file

@ -1,6 +1,7 @@
{
imports = [
./asterisk.nix
./colorchord.nix
./dnsmasq.nix
./dyndns.nix
./freeradius.nix