blast: port from my own blast-ugjka to the out-for-PR sblast

This commit is contained in:
2024-12-02 23:12:04 +00:00
parent 7affd0f343
commit 2ac3a755e0
7 changed files with 21 additions and 15 deletions

View File

@@ -204,8 +204,8 @@ in
];
consoleMediaUtils = declPackageSet [
# "blast-ugjka" # cast audio to UPNP/DLNA devices (via pulseaudio sink)
# "catt" # cast videos to chromecast
# "sblast" # cast audio to UPNP/DLNA devices (via pulseaudio sink)
"ffmpeg"
"go2tv" # cast videos to UPNP/DLNA device (i.e. tv).
"imagemagick"
@@ -1030,8 +1030,8 @@ in
sane-cast.sandbox.net = "clearnet";
sane-cast.sandbox.autodetectCliPaths = "existingFile";
sane-cast.sandbox.whitelistAudio = true; #< for blast audio casting
sane-cast.suggestedPrograms = [ "blast-ugjka" "go2tv" ];
sane-cast.sandbox.whitelistAudio = true; #< for sblast audio casting
sane-cast.suggestedPrograms = [ "go2tv" "sblast" ];
sane-die-with-parent.sandbox.enable = false; #< it's a launcher; can't sandbox

View File

@@ -13,7 +13,6 @@
./avahi.nix
./bemenu.nix
./bitcoin-cli.nix
./blast-ugjka
./bonsai.nix
./brave.nix
./brightnessctl.nix
@@ -163,6 +162,7 @@
./sane-sysload.nix
./sane-theme.nix
./satellite.nix
./sblast
./schlock.nix
./seatd.nix
./sfeed.nix

View File

@@ -1,5 +1,5 @@
#!/usr/bin/env nix-shell
#!nix-shell -i python3 -p blast-ugjka -p python3
#!nix-shell -i python3 -p python3 -p sblast
# vim: set filetype=python :
import logging
@@ -45,7 +45,7 @@ class BlastDriver:
def __init__(self, blast_flags: list[str] = []):
self.ranked_ips = get_ranked_ip_addrs()
self.blast = subprocess.Popen(
["blast", "-source", "blast.monitor"] + blast_flags,
["sblast", "-source", "blast.monitor"] + blast_flags,
stdin=subprocess.PIPE,
stdout=subprocess.PIPE,
stderr=subprocess.PIPE,
@@ -138,7 +138,7 @@ def try_blast(*args, **kwargs) -> BlastDriver | None:
if status == Status.RedoWithFlags:
dev = blast.receiver_names[0]
blast_flags = DEVICE_MAP[dev]
logger.info("re-exec blast for %s with flags: %r", dev, blast_flags)
logger.info("re-exec sblast for %s with flags: %r", dev, blast_flags)
blast.blast.terminate()
return try_blast(blast_flags=blast_flags)
elif status == Status.Error:

View File

@@ -20,10 +20,10 @@
# - `-mime audio/ac3 -format ac3`: FAILS
{ config, lib, pkgs, ... }:
let
cfg = config.sane.programs.blast-ugjka;
cfg = config.sane.programs.sblast;
in
{
sane.programs.blast-ugjka = {
sane.programs.sblast = {
sandbox.whitelistAudio = true;
sandbox.net = "clearnet";
};
@@ -32,7 +32,7 @@ in
# helper to deal with blast's interactive CLI
packageUnwrapped = pkgs.static-nix-shell.mkPython3 {
pname = "blast-to-default";
pkgs = [ "blast-ugjka" ];
pkgs = [ "sblast" ];
srcRoot = ./.;
};
sandbox.whitelistAudio = true;
@@ -40,7 +40,7 @@ in
#v else it fails to reap its children (or, maybe, it fails to hook its parent's death signal?)
#v might be possible to remove this, but kinda hard to see a clean way.
sandbox.keepPidsAndProc = true;
suggestedPrograms = [ "blast-ugjka" "sane-die-with-parent" ];
suggestedPrograms = [ "sane-die-with-parent" "sblast" ];
};
networking.firewall.allowedTCPPorts = lib.mkIf cfg.enabled [ 9000 ];

View File

@@ -71,6 +71,12 @@ in
hash = "sha256-3Yv6Yy1K2dNrrduM2XTEDjSmkysguTbqb8T7mDK2ubI=";
})
(fetchpatch' {
name = "sblast: init at 0.7.0";
prUrl = "https://github.com/NixOS/nixpkgs/pull/343460";
hash = "sha256-tp6D0XDPAvIv36XNr09bbw1Xs3kodxxKJbNn8NAas0k=";
})
# (fetchpatch' {
# name = "nixos/buffyboard: init";

View File

@@ -1,7 +1,7 @@
{ static-nix-shell }:
static-nix-shell.mkPython3 {
pname = "sane-cast";
pkgs = [ "blast-ugjka" "go2tv" ];
pkgs = [ "go2tv" "sblast" ];
srcRoot = ./.;
}

View File

@@ -1,5 +1,5 @@
#!/usr/bin/env nix-shell
#!nix-shell -i python3 -p blast-ugjka -p go2tv -p python3
#!nix-shell -i python3 -p go2tv -p python3 -p sblast
# vim: set filetype=python :
"""
cast media (local video or audio files) to a device on the same network
@@ -129,7 +129,7 @@ class Go2TvDriver:
class BlastDriver:
def cast_to(self, dev: Device) -> None:
blast_args = [
"blast",
"sblast",
# "blast.monitor" source will create a new output, or we can do that in pipewire config for better predictability.
"-source", "effect_input.virtual.monitor",
"-device", dev.model,
@@ -138,7 +138,7 @@ class BlastDriver:
if dev.compat != Compat.RenameToMp4:
blast_args += [ "-usewav" ];
os.execvp("blast", blast_args)
os.execvp("sblast", blast_args)
def get_ranked_ip_addrs():
"""