idfk
This commit is contained in:
parent
9a3493bf0c
commit
184afea0ee
18
flake.lock
18
flake.lock
|
@ -43,11 +43,11 @@
|
|||
"nixpkgs": "nixpkgs"
|
||||
},
|
||||
"locked": {
|
||||
"lastModified": 1642882610,
|
||||
"narHash": "sha256-pmdgeJ9v6y+T0UfNQ/Z+Hdv5tPshFFra5JLF/byUA/Y=",
|
||||
"lastModified": 1643307345,
|
||||
"narHash": "sha256-xiu7i6Q3Dqu4lLfDNaAL/f2DVewBxL+ysMuAyJiGv+4=",
|
||||
"owner": "nix-community",
|
||||
"repo": "home-manager",
|
||||
"rev": "c47c350f6518ed39c2a16e4fadf9137b6c559ddc",
|
||||
"rev": "4e92ec84f93a293042a64c3ed56ac8aee62fb6e1",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
|
@ -58,11 +58,11 @@
|
|||
},
|
||||
"nixpkgs": {
|
||||
"locked": {
|
||||
"lastModified": 1643000262,
|
||||
"narHash": "sha256-8hrbufiCcZgicU8UvHaRkruYuzM8z3lJvQkSh9ezMEg=",
|
||||
"lastModified": 1643202076,
|
||||
"narHash": "sha256-EcrUSBkBnw3KtDBoDwHvvwR1R6YF0axNFE4Vd2++iok=",
|
||||
"owner": "NixOS",
|
||||
"repo": "nixpkgs",
|
||||
"rev": "cc68710784ffe0ee035ee7b726656c44566cac94",
|
||||
"rev": "e722007bf05802573b41701c49da6c8814878171",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
|
@ -72,11 +72,11 @@
|
|||
},
|
||||
"nixpkgs_2": {
|
||||
"locked": {
|
||||
"lastModified": 1642903813,
|
||||
"narHash": "sha256-0lNfGW8sNfyTrixoQhVG00Drl/ECaf5GbfKAQ1ZDoyE=",
|
||||
"lastModified": 1643169865,
|
||||
"narHash": "sha256-+KIpNRazbc8Gac9jdWCKQkFv9bjceaLaLhlwqUEYu8c=",
|
||||
"owner": "nixos",
|
||||
"repo": "nixpkgs",
|
||||
"rev": "689b76bcf36055afdeb2e9852f5ecdd2bf483f87",
|
||||
"rev": "945ec499041db73043f745fad3b2a3a01e826081",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
|
|
|
@ -4,7 +4,9 @@
|
|||
programs.vscode = {
|
||||
enable = true;
|
||||
userSettings = {
|
||||
"window.zoomLevel" = -1;
|
||||
"editor.tabSize" = 4;
|
||||
"window.zoomLevel" = -3;
|
||||
"workbench.preferredDarkColorTheme" = "SynthWave '84";
|
||||
"editor.fontSize" = 24;
|
||||
"editor.fontFamily" = "'Comic Code'";
|
||||
"terminal.integrated.fontSize" = 24;
|
||||
|
|
|
@ -5,6 +5,6 @@
|
|||
# to broadcast to all speakers over rtp
|
||||
profiles.sound.pulseaudio.pulse-systemwide
|
||||
profiles.sound.pulseaudio.pulse-recv-native-localhost
|
||||
] ++ [ ./hosts/lappy.nix ./hosts/raspberry.nix ];
|
||||
] ++ [ ./hosts/lappy.nix ./hosts/raspberry.nix ];
|
||||
|
||||
}
|
||||
|
|
|
@ -1,21 +1,15 @@
|
|||
{ ... }:
|
||||
{ pkgs, ... }:
|
||||
let
|
||||
sink_name = "rtp-lappy";
|
||||
description = "Laptop Output";
|
||||
sink_name = "roc-lappy";
|
||||
description = "Lappy ROC Output";
|
||||
ip_addr = "100.115.10.34";
|
||||
in {
|
||||
hardware.pulseaudio = {
|
||||
extraConfig = ''
|
||||
load-module module-null-sink sink_name=${sink_name} sink_properties="device.description='${description}'"
|
||||
load-module module-rtp-send source=${sink_name}.monitor destination_ip=${ip_addr}
|
||||
'';
|
||||
};
|
||||
services.mpd.extraConfig = ''
|
||||
audio_output {
|
||||
type "pulse"
|
||||
type "pipe"
|
||||
name "${description}"
|
||||
target "${sink_name}"
|
||||
server "127.0.0.1"
|
||||
command "${pkgs.roc-send-pcm}/bin/roc-send-pcm s16le 44.1k 2 ${ip_addr}"
|
||||
}
|
||||
'';
|
||||
}
|
||||
|
||||
|
|
|
@ -74,10 +74,6 @@
|
|||
# let vscode, vivaldi, etc work.
|
||||
security.unprivilegedUsernsClone = true;
|
||||
|
||||
virtualisation.virtualbox.host.enable = true;
|
||||
#virtualisation.virtualbox.host.enableExtensionPack = true;
|
||||
users.extraGroups.vboxusers.members = [ "chaoticryptidz" ];
|
||||
|
||||
networking.hostName = "lappy";
|
||||
time.timeZone = "Europe/London";
|
||||
powerManagement.cpuFreqGovernor = lib.mkDefault "powersave";
|
||||
|
|
|
@ -1,7 +1,10 @@
|
|||
{ pkgs, tree, ... }: {
|
||||
imports = [ ./mpd-music-sync.nix ];
|
||||
imports = with tree; [
|
||||
./mpd-music-sync.nix
|
||||
profiles.sound.pulseaudio.pulse-recv-native-localhost
|
||||
];
|
||||
|
||||
environment.systemPackages = with pkgs; [ mpc_cli mpv roc-toolkit-patched ];
|
||||
environment.systemPackages = with pkgs; [ mpc_cli ];
|
||||
|
||||
systemd.tmpfiles.rules = [
|
||||
"d /var/lib/mpd 0755 mpd mpd -"
|
||||
|
|
|
@ -9,7 +9,7 @@
|
|||
profiles.tailscale
|
||||
profiles.sshd
|
||||
|
||||
hosts.raspberry.services.mpd-recv
|
||||
hosts.raspberry.services.music-friend
|
||||
|
||||
profiles.connectivity.bluetooth
|
||||
profiles.connectivity.ios
|
||||
|
|
|
@ -1,74 +0,0 @@
|
|||
{ tree, pkgs, ... }:
|
||||
let
|
||||
process-media-controls = pkgs.writeText "process-media-controls" ''
|
||||
import asyncio
|
||||
import os
|
||||
from evdev import InputDevice, categorize, ecodes
|
||||
|
||||
dev = InputDevice('/dev/input/event0')
|
||||
|
||||
async def scanner(dev):
|
||||
async for ev in dev.async_read_loop():
|
||||
if ev.type == ecodes.EV_KEY:
|
||||
if ev.code in [ecodes.KEY_PLAYCD, ecodes.KEY_PAUSECD] and ev.value == 0:
|
||||
print("Play/Pause Pressed")
|
||||
os.system("pactl set-sink-mute @DEFAULT_SINK@ toggle")
|
||||
|
||||
loop = asyncio.get_event_loop()
|
||||
loop.run_until_complete(scanner(dev))
|
||||
'';
|
||||
in {
|
||||
imports = with tree; [
|
||||
profiles.connectivity.bluetooth
|
||||
|
||||
profiles.sound.pulseaudio.pulse
|
||||
profiles.sound.pulseaudio.pulse-systemwide
|
||||
profiles.sound.pulseaudio.pulse-bluetooth
|
||||
profiles.sound.pulseaudio.pulse-recv-native-localhost
|
||||
];
|
||||
|
||||
systemd = {
|
||||
services.roc-recv = {
|
||||
requires = [ "network.target" "pulseaudio.service" ];
|
||||
after = [ "network.target" "pulseaudio.service" ];
|
||||
wantedBy = [ "multi-user.target" ];
|
||||
script = ''
|
||||
PULSE_SERVER=127.0.0.1 ${pkgs.roc-toolkit-patched}/bin/roc-recv --source "rtp:0.0.0.0:10001"
|
||||
'';
|
||||
serviceConfig = { Restart = "always"; };
|
||||
};
|
||||
|
||||
services.process-media-controls = {
|
||||
requires = [ "network.target" "pulseaudio.service" ];
|
||||
after = [ "network.target" "pulseaudio.service" ];
|
||||
wantedBy = [ "multi-user.target" ];
|
||||
path = [ pkgs.pulseaudio ];
|
||||
script = let
|
||||
python = pkgs.python39.withPackages
|
||||
(ps: with ps; [ pkgs.python39Packages.evdev ]);
|
||||
in ''
|
||||
(${python.interpreter} ${process-media-controls}) || true
|
||||
'';
|
||||
serviceConfig = {
|
||||
Restart = "always";
|
||||
StartLimitAction = "none";
|
||||
};
|
||||
};
|
||||
|
||||
timers.bt-autoconnect = {
|
||||
wantedBy = [ "timers.target" ];
|
||||
partOf = [ "bt-autoconnect.service" ];
|
||||
timerConfig.OnCalendar = "minutely";
|
||||
};
|
||||
services.bt-autoconnect = {
|
||||
serviceConfig.Type = "oneshot";
|
||||
script = ''
|
||||
${pkgs.bluez}/bin/bluetoothctl connect 3E:39:E7:B2:86:29 || true
|
||||
'';
|
||||
};
|
||||
};
|
||||
|
||||
hardware.pulseaudio.extraConfig = ''
|
||||
set-default-sink bluez_card.3E_39_E7_B2_86_29
|
||||
'';
|
||||
}
|
24
hosts/raspberry/services/music-friend/bluetooth.nix
Normal file
24
hosts/raspberry/services/music-friend/bluetooth.nix
Normal file
|
@ -0,0 +1,24 @@
|
|||
{ tree, pkgs, ... }: {
|
||||
imports = with tree; [
|
||||
profiles.connectivity.bluetooth
|
||||
profiles.sound.pulseaudio.pulse-bluetooth
|
||||
];
|
||||
|
||||
systemd = {
|
||||
timers.bt-autoconnect = {
|
||||
wantedBy = [ "timers.target" ];
|
||||
partOf = [ "bt-autoconnect.service" ];
|
||||
timerConfig.OnCalendar = "minutely";
|
||||
};
|
||||
services.bt-autoconnect = {
|
||||
serviceConfig.Type = "oneshot";
|
||||
script = ''
|
||||
${pkgs.bluez}/bin/bluetoothctl connect 3E:39:E7:B2:86:29 || true
|
||||
'';
|
||||
};
|
||||
};
|
||||
|
||||
hardware.pulseaudio.extraConfig = ''
|
||||
set-default-sink bluez_card.3E_39_E7_B2_86_29
|
||||
'';
|
||||
}
|
23
hosts/raspberry/services/music-friend/helper-scripts.nix
Normal file
23
hosts/raspberry/services/music-friend/helper-scripts.nix
Normal file
|
@ -0,0 +1,23 @@
|
|||
{ pkgs, ... }:
|
||||
let
|
||||
mpd-server = "hetzner-vm.tailscale-internal.genderfucked.monster";
|
||||
sync-with-mpd-server = pkgs.writeShellScriptBin "sync-with-mpd-server" ''
|
||||
#!/usr/bin/env bash
|
||||
set -x
|
||||
|
||||
vmMpc() {
|
||||
mpc -h "$(cat /secrets/mpd-password)@${mpd-server}" "$@"
|
||||
}
|
||||
|
||||
#mpc clear
|
||||
POSITION=$(vmMpc status -f "%position%" | head -n 1)
|
||||
CURRENT_TIMESTAMP=$(vmMpc status | awk '/^\[playing\]/ { sub(/\/.+/,"",$3); split($3,a,/:/); print a[1]*60+a[2] }')
|
||||
|
||||
mpc clear
|
||||
mpc rescan
|
||||
vmMpc -f "%file%" playlist | mpc add
|
||||
mpc play "$POSITION"
|
||||
mpc seek "$CURRENT_TIMESTAMP"
|
||||
mpc play
|
||||
'';
|
||||
in { environment.systemPackages = [ sync-with-mpd-server ]; }
|
4
hosts/raspberry/services/music-friend/local-mpd.nix
Normal file
4
hosts/raspberry/services/music-friend/local-mpd.nix
Normal file
|
@ -0,0 +1,4 @@
|
|||
{ tree, ... }: {
|
||||
# TODO: move this to its own profile
|
||||
imports = with tree; [ hosts.lappy.profiles.mpd ];
|
||||
}
|
|
@ -0,0 +1,23 @@
|
|||
{ pkgs, ... }:
|
||||
let
|
||||
process-media-controls = pkgs.writeText "process-media-controls"
|
||||
(builtins.readFile ./process-media-controls.py);
|
||||
in {
|
||||
systemd.services.process-media-controls = {
|
||||
requires = [ "network.target" "pulseaudio.service" ];
|
||||
after = [ "network.target" "pulseaudio.service" ];
|
||||
wantedBy = [ "multi-user.target" ];
|
||||
path = [ pkgs.pulseaudio ];
|
||||
script = let
|
||||
python = pkgs.python39.withPackages
|
||||
(ps: with ps; [ pkgs.python39Packages.evdev ]);
|
||||
in ''
|
||||
export PULSE_SERVER=127.0.0.1
|
||||
(${python.interpreter} ${process-media-controls}) || true
|
||||
'';
|
||||
serviceConfig = {
|
||||
Restart = "always";
|
||||
StartLimitAction = "none";
|
||||
};
|
||||
};
|
||||
}
|
7
hosts/raspberry/services/music-friend/pulseaudiio.nix
Normal file
7
hosts/raspberry/services/music-friend/pulseaudiio.nix
Normal file
|
@ -0,0 +1,7 @@
|
|||
{ tree, ... }: {
|
||||
imports = with tree; [
|
||||
profiles.sound.pulseaudio.pulse
|
||||
profiles.sound.pulseaudio.pulse-systemwide
|
||||
profiles.sound.pulseaudio.pulse-recv-native-localhost
|
||||
];
|
||||
}
|
|
@ -6,6 +6,7 @@ let
|
|||
folder = ./.;
|
||||
config = {
|
||||
"hosts/*/services".functor.enable = true;
|
||||
"hosts/raspberry/services/music-friend".functor.enable = true;
|
||||
"hosts/*/home".functor.enable = true;
|
||||
"hosts/*/profiles".functor.enable = true;
|
||||
"profiles/*".functor.enable = true;
|
||||
|
|
|
@ -6,8 +6,8 @@ buildGoModule rec {
|
|||
src = fetchFromGitLab {
|
||||
owner = "ChaotiCryptidz";
|
||||
repo = "gobar";
|
||||
rev = "c7891afcd92bf0a31077098c66cbc4070d8b9340";
|
||||
sha256 = "sha256-tuHHB7xX4vqsBwe/LsNg5+v+gzg6xotZ9MDK+fk3mR4=";
|
||||
rev = "34c807423e5ea1420dbe2c08574cdc234f9b0789";
|
||||
sha256 = "sha256-H+CjnkMde3rx7CoLKOluxHlYrhZGqzTnU8oOgkDEwsc=";
|
||||
#sha256 = lib.fakeSha256;
|
||||
};
|
||||
|
||||
|
|
|
@ -1,20 +1,6 @@
|
|||
{ stdenv,
|
||||
lib,
|
||||
fetchFromGitHub,
|
||||
sconsPackages,
|
||||
ragel,
|
||||
gengetopt,
|
||||
pkg-config,
|
||||
libuv,
|
||||
openfecSupport ? true,
|
||||
openfec,
|
||||
libunwindSupport ? true,
|
||||
libunwind,
|
||||
pulseaudioSupport ? true,
|
||||
libpulseaudio,
|
||||
soxSupport ? true,
|
||||
sox
|
||||
}:
|
||||
{ stdenv, lib, fetchFromGitHub, sconsPackages, ragel, gengetopt, pkg-config
|
||||
, libuv, openfecSupport ? true, openfec, libunwindSupport ? true, libunwind
|
||||
, pulseaudioSupport ? true, libpulseaudio, soxSupport ? true, sox }:
|
||||
|
||||
stdenv.mkDerivation rec {
|
||||
pname = "roc-toolkit";
|
||||
|
@ -27,42 +13,34 @@ stdenv.mkDerivation rec {
|
|||
sha256 = "sha256:1pld340zfch4p3qaf5anrspq7vmxrgf9ddsdsq92pk49axaaz19w";
|
||||
};
|
||||
|
||||
nativeBuildInputs = [
|
||||
sconsPackages.scons_3_0_1
|
||||
ragel
|
||||
gengetopt
|
||||
pkg-config
|
||||
];
|
||||
nativeBuildInputs = [ sconsPackages.scons_3_0_1 ragel gengetopt pkg-config ];
|
||||
|
||||
buildInputs = [
|
||||
libuv
|
||||
libunwind
|
||||
openfec
|
||||
libpulseaudio
|
||||
sox
|
||||
];
|
||||
buildInputs = [ libuv libunwind openfec libpulseaudio sox ];
|
||||
|
||||
sconsFlags =
|
||||
[ "--build=${stdenv.buildPlatform.config}"
|
||||
"--host=${stdenv.hostPlatform.config}"
|
||||
"--prefix=${placeholder "out"}"
|
||||
"--disable-tests" ] ++
|
||||
lib.optional (!soxSupport) "--disable-sox" ++
|
||||
lib.optional (!libunwindSupport) "--disable-libunwind" ++
|
||||
lib.optional (!pulseaudioSupport) "--disable-pulseaudio" ++
|
||||
(if (!openfecSupport)
|
||||
then ["--disable-openfec"]
|
||||
else [ "--with-libraries=${openfec}/lib"
|
||||
"--with-openfec-includes=${openfec.dev}/include" ]);
|
||||
sconsFlags = [
|
||||
"--build=${stdenv.buildPlatform.config}"
|
||||
"--host=${stdenv.hostPlatform.config}"
|
||||
"--prefix=${placeholder "out"}"
|
||||
"--disable-tests"
|
||||
] ++ lib.optional (!soxSupport) "--disable-sox"
|
||||
++ lib.optional (!libunwindSupport) "--disable-libunwind"
|
||||
++ lib.optional (!pulseaudioSupport) "--disable-pulseaudio"
|
||||
++ (if (!openfecSupport) then
|
||||
[ "--disable-openfec" ]
|
||||
else [
|
||||
"--with-libraries=${openfec}/lib"
|
||||
"--with-openfec-includes=${openfec.dev}/include"
|
||||
]);
|
||||
|
||||
prePatch = lib.optionalString stdenv.isAarch64
|
||||
"sed -i 's/c++98/c++11/g' SConstruct";
|
||||
prePatch =
|
||||
lib.optionalString stdenv.isAarch64 "sed -i 's/c++98/c++11/g' SConstruct";
|
||||
|
||||
meta = with lib; {
|
||||
description = "Roc is a toolkit for real-time audio streaming over the network";
|
||||
description =
|
||||
"Roc is a toolkit for real-time audio streaming over the network";
|
||||
homepage = "https://github.com/roc-streaming/roc-toolkit";
|
||||
license = licenses.mpl20;
|
||||
maintainers = with maintainers; [ bgamari ];
|
||||
platforms = platforms.unix;
|
||||
};
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
{ ... }: {
|
||||
{ lib, ... }: {
|
||||
services.openssh = {
|
||||
enable = true;
|
||||
passwordAuthentication = false;
|
||||
challengeResponseAuthentication = false;
|
||||
kbdInteractiveAuthentication = lib.mkDefault false;
|
||||
permitRootLogin = "prohibit-password";
|
||||
kexAlgorithms = [ "curve25519-sha256@libssh.org" ];
|
||||
extraConfig = ''
|
||||
|
|
Loading…
Reference in a new issue