pin yt-dlp version

This commit is contained in:
2026-05-28 23:00:10 -07:00
parent 26a13c27d6
commit f4d0bd7ca0
2 changed files with 88 additions and 74 deletions

View File

@@ -121,10 +121,9 @@ export class MediaPlayer {
const socketFilename = Math.random().toString(36).substring(2, 10); const socketFilename = Math.random().toString(36).substring(2, 10);
const socketPath = `/tmp/mpv-${socketFilename}`; const socketPath = `/tmp/mpv-${socketFilename}`;
const enableVideo = process.env.ENABLE_VIDEO || false; const enableVideo = process.env.ENABLE_VIDEO || false;
const ytdlFormat = process.env.MPV_YTDL_FORMAT;
const logfilePath = `/tmp/mpv-logfile.txt`; const logfilePath = `/tmp/mpv-logfile.txt`;
const playerArgs = [
console.log("Starting player process (video: " + (enableVideo ? "enabled" : "disabled") + ")");
this.playerProcess = spawn("mpv", [
"--video=" + (enableVideo ? "auto" : "no"), "--video=" + (enableVideo ? "auto" : "no"),
"--fullscreen", "--fullscreen",
"--no-terminal", "--no-terminal",
@@ -132,7 +131,14 @@ export class MediaPlayer {
"--input-ipc-server=" + socketPath, "--input-ipc-server=" + socketPath,
"--log-file=" + logfilePath, "--log-file=" + logfilePath,
"--msg-level=all=v" "--msg-level=all=v"
]); ];
if (ytdlFormat) {
playerArgs.push("--ytdl-format=" + ytdlFormat);
}
console.log("Starting player process (video: " + (enableVideo ? "enabled" : "disabled") + ")");
this.playerProcess = spawn("mpv", playerArgs);
let socketReady!: (s: Socket) => void; let socketReady!: (s: Socket) => void;

View File

@@ -8,10 +8,76 @@
outputs = { self, nixpkgs, flake-utils }: outputs = { self, nixpkgs, flake-utils }:
let let
mkQueuecube = pkgs: pkgs.buildNpmPackage {
pname = "queuecube";
version = "0.1.0";
src = ./.;
# Skip the standard buildPhase and provide our own
dontNpmBuild = true;
buildPhase = ''
# First install all dependencies
npm install
# Then run the build with workspaces flag
npm run build --workspaces
'';
# Runtime dependencies
buildInputs = with pkgs; [
mpv
yt-dlp
pulseaudio
];
# Create a wrapper script to ensure runtime deps are available
postInstall = ''
# Create the necessary directories
mkdir -p $out/lib/node_modules/queuecube
# Copy the entire project with built files
cp -r . $out/lib/node_modules/queuecube
# Install the frontend build to the backend dist directory
mkdir -p $out/lib/node_modules/queuecube/backend/dist/
cp -r frontend/dist $out/lib/node_modules/queuecube/backend/dist/frontend
# Create bin directory if it doesn't exist
mkdir -p $out/bin
# Create executable script
cat > $out/bin/queuecube <<EOF
#!/bin/sh
exec ${pkgs.nodejs}/bin/node $out/lib/node_modules/queuecube/backend/build/server.js
EOF
# Make it executable
chmod +x $out/bin/queuecube
# Wrap the program to include runtime deps in PATH
wrapProgram $out/bin/queuecube \
--prefix PATH : ${pkgs.lib.makeBinPath [
pkgs.mpv
pkgs.yt-dlp
pkgs.pulseaudio
]}
'';
# Let buildNpmPackage handle npm package hash
npmDepsHash = "sha256-kwbWqNqji0EcBeRuc/sqQUuGQkE+P8puLTfpAyRRzgY=";
meta = with pkgs.lib; {
description = "NodeJS application with media playback capabilities";
platforms = platforms.linux;
};
};
# Define the NixOS module for the systemd service # Define the NixOS module for the systemd service
nixosModule = { config, lib, pkgs, ... }: nixosModule = { config, lib, pkgs, ... }:
let let
cfg = config.services.queuecube; cfg = config.services.queuecube;
package = mkQueuecube pkgs;
in { in {
options.services.queuecube = { options.services.queuecube = {
enable = lib.mkEnableOption "QueueCube media player service"; enable = lib.mkEnableOption "QueueCube media player service";
@@ -34,6 +100,12 @@
description = "Enable screensharing"; description = "Enable screensharing";
}; };
mpv_ytdl_format = lib.mkOption {
type = lib.types.nullOr lib.types.str;
default = "best";
description = "yt-dlp format selector passed to mpv. Set to null to use mpv's default format selection.";
};
store_path = lib.mkOption { store_path = lib.mkOption {
type = lib.types.str; type = lib.types.str;
default = "/var/tmp/queuecube"; default = "/var/tmp/queuecube";
@@ -71,7 +143,7 @@
config = lib.mkIf cfg.enable { config = lib.mkIf cfg.enable {
users.users.${cfg.user} = { users.users.${cfg.user} = {
packages = [ self.packages.${pkgs.system}.queuecube ]; packages = [ package ];
}; };
systemd.user.services.queuecube = { systemd.user.services.queuecube = {
@@ -80,7 +152,7 @@
after = [ "pipewire.service" "pipewire-pulse.service" ]; after = [ "pipewire.service" "pipewire-pulse.service" ];
serviceConfig = { serviceConfig = {
ExecStart = "${self.packages.${pkgs.system}.queuecube}/bin/queuecube"; ExecStart = "${package}/bin/queuecube";
Restart = "on-failure"; Restart = "on-failure";
RestartSec = 5; RestartSec = 5;
@@ -119,6 +191,8 @@
USE_INVIDIOUS = if cfg.invidious.enable then "1" else "0"; USE_INVIDIOUS = if cfg.invidious.enable then "1" else "0";
INVIDIOUS_BASE_URL = cfg.invidious.url; INVIDIOUS_BASE_URL = cfg.invidious.url;
STORE_PATH = cfg.store_path; STORE_PATH = cfg.store_path;
} // lib.optionalAttrs (cfg.mpv_ytdl_format != null) {
MPV_YTDL_FORMAT = cfg.mpv_ytdl_format;
}; };
}; };
}; };
@@ -127,72 +201,7 @@
flake-utils.lib.eachDefaultSystem (system: flake-utils.lib.eachDefaultSystem (system:
let let
pkgs = nixpkgs.legacyPackages.${system}; pkgs = nixpkgs.legacyPackages.${system};
queuecube = mkQueuecube pkgs;
# Define the package using buildNpmPackage
queuecube = pkgs.buildNpmPackage {
pname = "queuecube";
version = "0.1.0";
src = ./.;
# Skip the standard buildPhase and provide our own
dontNpmBuild = true;
buildPhase = ''
# First install all dependencies
npm install
# Then run the build with workspaces flag
npm run build --workspaces
'';
# Runtime dependencies
buildInputs = with pkgs; [
mpv
yt-dlp
pulseaudio
];
# Create a wrapper script to ensure runtime deps are available
postInstall = ''
# Create the necessary directories
mkdir -p $out/lib/node_modules/queuecube
# Copy the entire project with built files
cp -r . $out/lib/node_modules/queuecube
# Install the frontend build to the backend dist directory
mkdir -p $out/lib/node_modules/queuecube/backend/dist/
cp -r frontend/dist $out/lib/node_modules/queuecube/backend/dist/frontend
# Create bin directory if it doesn't exist
mkdir -p $out/bin
# Create executable script
cat > $out/bin/queuecube <<EOF
#!/bin/sh
exec ${pkgs.nodejs}/bin/node $out/lib/node_modules/queuecube/backend/build/server.js
EOF
# Make it executable
chmod +x $out/bin/queuecube
# Wrap the program to include runtime deps in PATH
wrapProgram $out/bin/queuecube \
--prefix PATH : ${pkgs.lib.makeBinPath [
pkgs.mpv
pkgs.yt-dlp
pkgs.pulseaudio
]}
'';
# Let buildNpmPackage handle npm package hash
npmDepsHash = "sha256-kwbWqNqji0EcBeRuc/sqQUuGQkE+P8puLTfpAyRRzgY=";
meta = with pkgs.lib; {
description = "NodeJS application with media playback capabilities";
platforms = platforms.linux;
};
};
in { in {
packages = { packages = {
@@ -208,8 +217,7 @@
# Development environment # Development environment
devShells.default = pkgs.mkShell { devShells.default = pkgs.mkShell {
buildInputs = with pkgs; [ buildInputs = with pkgs; [
nodejs_20 nodejs
nodePackages.npm
mpv mpv
yt-dlp yt-dlp
pulseaudio pulseaudio