diff --git a/flake.lock b/flake.lock index 0620b30..56fb8ed 100644 --- a/flake.lock +++ b/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": { diff --git a/home/programming/code.nix b/home/programming/code.nix index b874ea2..02a9850 100644 --- a/home/programming/code.nix +++ b/home/programming/code.nix @@ -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; diff --git a/hosts/hetzner-vm/services/mpd-broadcast/broadcast.nix b/hosts/hetzner-vm/services/mpd-broadcast/broadcast.nix index c21f77a..e9b23b4 100644 --- a/hosts/hetzner-vm/services/mpd-broadcast/broadcast.nix +++ b/hosts/hetzner-vm/services/mpd-broadcast/broadcast.nix @@ -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 ]; } diff --git a/hosts/hetzner-vm/services/mpd-broadcast/hosts/lappy.nix b/hosts/hetzner-vm/services/mpd-broadcast/hosts/lappy.nix index e5bde1a..0bca443 100644 --- a/hosts/hetzner-vm/services/mpd-broadcast/hosts/lappy.nix +++ b/hosts/hetzner-vm/services/mpd-broadcast/hosts/lappy.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}" } ''; } + diff --git a/hosts/lappy/lappy.nix b/hosts/lappy/lappy.nix index 7f02e00..4a5c47a 100644 --- a/hosts/lappy/lappy.nix +++ b/hosts/lappy/lappy.nix @@ -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"; diff --git a/hosts/lappy/profiles/mpd.nix b/hosts/lappy/profiles/mpd.nix index 87f85fb..da7fba7 100644 --- a/hosts/lappy/profiles/mpd.nix +++ b/hosts/lappy/profiles/mpd.nix @@ -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 -" diff --git a/hosts/raspberry/raspberry.nix b/hosts/raspberry/raspberry.nix index 1dab67f..e8c49ed 100644 --- a/hosts/raspberry/raspberry.nix +++ b/hosts/raspberry/raspberry.nix @@ -9,7 +9,7 @@ profiles.tailscale profiles.sshd - hosts.raspberry.services.mpd-recv + hosts.raspberry.services.music-friend profiles.connectivity.bluetooth profiles.connectivity.ios diff --git a/hosts/raspberry/services/mpd-recv.nix b/hosts/raspberry/services/mpd-recv.nix deleted file mode 100644 index b67bbf1..0000000 --- a/hosts/raspberry/services/mpd-recv.nix +++ /dev/null @@ -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 - ''; -} diff --git a/hosts/raspberry/services/music-friend/bluetooth.nix b/hosts/raspberry/services/music-friend/bluetooth.nix new file mode 100644 index 0000000..c58433b --- /dev/null +++ b/hosts/raspberry/services/music-friend/bluetooth.nix @@ -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 + ''; +} diff --git a/hosts/raspberry/services/music-friend/helper-scripts.nix b/hosts/raspberry/services/music-friend/helper-scripts.nix new file mode 100644 index 0000000..79a08e6 --- /dev/null +++ b/hosts/raspberry/services/music-friend/helper-scripts.nix @@ -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 ]; } diff --git a/hosts/raspberry/services/music-friend/local-mpd.nix b/hosts/raspberry/services/music-friend/local-mpd.nix new file mode 100644 index 0000000..b73d751 --- /dev/null +++ b/hosts/raspberry/services/music-friend/local-mpd.nix @@ -0,0 +1,4 @@ +{ tree, ... }: { + # TODO: move this to its own profile + imports = with tree; [ hosts.lappy.profiles.mpd ]; +} diff --git a/hosts/raspberry/services/music-friend/process-media-controls.nix b/hosts/raspberry/services/music-friend/process-media-controls.nix new file mode 100644 index 0000000..e5bc42f --- /dev/null +++ b/hosts/raspberry/services/music-friend/process-media-controls.nix @@ -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"; + }; + }; +} diff --git a/hosts/raspberry/services/process-media-controls.py b/hosts/raspberry/services/music-friend/process-media-controls.py similarity index 100% rename from hosts/raspberry/services/process-media-controls.py rename to hosts/raspberry/services/music-friend/process-media-controls.py diff --git a/hosts/raspberry/services/music-friend/pulseaudiio.nix b/hosts/raspberry/services/music-friend/pulseaudiio.nix new file mode 100644 index 0000000..fa1bb1b --- /dev/null +++ b/hosts/raspberry/services/music-friend/pulseaudiio.nix @@ -0,0 +1,7 @@ +{ tree, ... }: { + imports = with tree; [ + profiles.sound.pulseaudio.pulse + profiles.sound.pulseaudio.pulse-systemwide + profiles.sound.pulseaudio.pulse-recv-native-localhost + ]; +} diff --git a/outputs.nix b/outputs.nix index 3cbedc3..944f3d3 100644 --- a/outputs.nix +++ b/outputs.nix @@ -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; diff --git a/overlay/gobar/default.nix b/overlay/gobar/default.nix index 0777b6a..35cebd4 100644 --- a/overlay/gobar/default.nix +++ b/overlay/gobar/default.nix @@ -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; }; diff --git a/overlay/roc-toolkit-patched/default.nix b/overlay/roc-toolkit-patched/default.nix index f445117..891c311 100644 --- a/overlay/roc-toolkit-patched/default.nix +++ b/overlay/roc-toolkit-patched/default.nix @@ -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; }; -} \ No newline at end of file +} diff --git a/profiles/sshd/sshd.nix b/profiles/sshd/sshd.nix index 7cc94de..01443a1 100644 --- a/profiles/sshd/sshd.nix +++ b/profiles/sshd/sshd.nix @@ -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 = ''