pin yt-dlp version
This commit is contained in:
@@ -121,10 +121,9 @@ export class MediaPlayer {
|
||||
const socketFilename = Math.random().toString(36).substring(2, 10);
|
||||
const socketPath = `/tmp/mpv-${socketFilename}`;
|
||||
const enableVideo = process.env.ENABLE_VIDEO || false;
|
||||
const ytdlFormat = process.env.MPV_YTDL_FORMAT;
|
||||
const logfilePath = `/tmp/mpv-logfile.txt`;
|
||||
|
||||
console.log("Starting player process (video: " + (enableVideo ? "enabled" : "disabled") + ")");
|
||||
this.playerProcess = spawn("mpv", [
|
||||
const playerArgs = [
|
||||
"--video=" + (enableVideo ? "auto" : "no"),
|
||||
"--fullscreen",
|
||||
"--no-terminal",
|
||||
@@ -132,7 +131,14 @@ export class MediaPlayer {
|
||||
"--input-ipc-server=" + socketPath,
|
||||
"--log-file=" + logfilePath,
|
||||
"--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;
|
||||
|
||||
256
web/flake.nix
256
web/flake.nix
@@ -8,128 +8,7 @@
|
||||
|
||||
outputs = { self, nixpkgs, flake-utils }:
|
||||
let
|
||||
# Define the NixOS module for the systemd service
|
||||
nixosModule = { config, lib, pkgs, ... }:
|
||||
let
|
||||
cfg = config.services.queuecube;
|
||||
in {
|
||||
options.services.queuecube = {
|
||||
enable = lib.mkEnableOption "QueueCube media player service";
|
||||
|
||||
port = lib.mkOption {
|
||||
type = lib.types.port;
|
||||
default = 3000;
|
||||
description = "Port on which QueueCube will listen";
|
||||
};
|
||||
|
||||
enable_video = lib.mkOption {
|
||||
type = lib.types.bool;
|
||||
default = false;
|
||||
description = "Enable video playback";
|
||||
};
|
||||
|
||||
enable_screenshare = lib.mkOption {
|
||||
type = lib.types.bool;
|
||||
default = false;
|
||||
description = "Enable screensharing";
|
||||
};
|
||||
|
||||
store_path = lib.mkOption {
|
||||
type = lib.types.str;
|
||||
default = "/var/tmp/queuecube";
|
||||
description = "Path to the store for QueueCube";
|
||||
};
|
||||
|
||||
invidious = lib.mkOption {
|
||||
type = lib.types.submodule {
|
||||
options = {
|
||||
enable = lib.mkOption {
|
||||
type = lib.types.bool;
|
||||
default = false;
|
||||
description = "Enable Invidious";
|
||||
};
|
||||
|
||||
url = lib.mkOption {
|
||||
type = lib.types.str;
|
||||
default = "http://invidious.nor";
|
||||
description = "URL of the Invidious instance to use";
|
||||
};
|
||||
};
|
||||
};
|
||||
|
||||
default = {
|
||||
enable = false;
|
||||
url = "http://invidious.nor";
|
||||
};
|
||||
};
|
||||
|
||||
user = lib.mkOption {
|
||||
type = lib.types.str;
|
||||
description = "User account under which QueueCube runs (required)";
|
||||
};
|
||||
};
|
||||
|
||||
config = lib.mkIf cfg.enable {
|
||||
users.users.${cfg.user} = {
|
||||
packages = [ self.packages.${pkgs.system}.queuecube ];
|
||||
};
|
||||
|
||||
systemd.user.services.queuecube = {
|
||||
description = "QueueCube media player service";
|
||||
wantedBy = [ "default.target" ];
|
||||
after = [ "pipewire.service" "pipewire-pulse.service" ];
|
||||
|
||||
serviceConfig = {
|
||||
ExecStart = "${self.packages.${pkgs.system}.queuecube}/bin/queuecube";
|
||||
Restart = "on-failure";
|
||||
RestartSec = 5;
|
||||
|
||||
# Remove all resource limits for mpv to function properly
|
||||
LimitNOFILE = "infinity"; # No limit on file descriptors
|
||||
LimitMEMLOCK = "infinity"; # No limit on locked memory (for real-time audio)
|
||||
LimitNPROC = "infinity"; # No limit on number of processes
|
||||
LimitAS = "infinity"; # No limit on address space
|
||||
LimitRSS = "infinity"; # No limit on resident set size
|
||||
LimitCORE = "infinity"; # Allow core dumps for debugging
|
||||
LimitDATA = "infinity"; # No limit on data segment
|
||||
LimitSTACK = "infinity"; # No limit on stack size
|
||||
LimitCPU = "infinity"; # No limit on CPU time
|
||||
LimitRTPRIO = "99"; # Allow real-time priority
|
||||
LimitRTTIME = "infinity"; # No limit on real-time scheduling
|
||||
|
||||
# Nice level for better performance
|
||||
Nice = "-10";
|
||||
|
||||
# Allow access to necessary devices and features
|
||||
PrivateDevices = false;
|
||||
ProtectHome = false;
|
||||
ProtectSystem = false;
|
||||
NoNewPrivileges = false;
|
||||
|
||||
# Environment for X11 and runtime directories
|
||||
Environment = [
|
||||
"DISPLAY=:0"
|
||||
];
|
||||
};
|
||||
|
||||
environment = {
|
||||
PORT = toString cfg.port;
|
||||
ENABLE_VIDEO = if cfg.enable_video then "1" else "0";
|
||||
ENABLE_SCREENSHARE = if cfg.enable_screenshare then "1" else "0";
|
||||
USE_INVIDIOUS = if cfg.invidious.enable then "1" else "0";
|
||||
INVIDIOUS_BASE_URL = cfg.invidious.url;
|
||||
STORE_PATH = cfg.store_path;
|
||||
};
|
||||
};
|
||||
};
|
||||
};
|
||||
in
|
||||
flake-utils.lib.eachDefaultSystem (system:
|
||||
let
|
||||
pkgs = nixpkgs.legacyPackages.${system};
|
||||
|
||||
# Define the package using buildNpmPackage
|
||||
queuecube = pkgs.buildNpmPackage {
|
||||
mkQueuecube = pkgs: pkgs.buildNpmPackage {
|
||||
pname = "queuecube";
|
||||
version = "0.1.0";
|
||||
|
||||
@@ -194,6 +73,136 @@
|
||||
};
|
||||
};
|
||||
|
||||
# Define the NixOS module for the systemd service
|
||||
nixosModule = { config, lib, pkgs, ... }:
|
||||
let
|
||||
cfg = config.services.queuecube;
|
||||
package = mkQueuecube pkgs;
|
||||
in {
|
||||
options.services.queuecube = {
|
||||
enable = lib.mkEnableOption "QueueCube media player service";
|
||||
|
||||
port = lib.mkOption {
|
||||
type = lib.types.port;
|
||||
default = 3000;
|
||||
description = "Port on which QueueCube will listen";
|
||||
};
|
||||
|
||||
enable_video = lib.mkOption {
|
||||
type = lib.types.bool;
|
||||
default = false;
|
||||
description = "Enable video playback";
|
||||
};
|
||||
|
||||
enable_screenshare = lib.mkOption {
|
||||
type = lib.types.bool;
|
||||
default = false;
|
||||
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 {
|
||||
type = lib.types.str;
|
||||
default = "/var/tmp/queuecube";
|
||||
description = "Path to the store for QueueCube";
|
||||
};
|
||||
|
||||
invidious = lib.mkOption {
|
||||
type = lib.types.submodule {
|
||||
options = {
|
||||
enable = lib.mkOption {
|
||||
type = lib.types.bool;
|
||||
default = false;
|
||||
description = "Enable Invidious";
|
||||
};
|
||||
|
||||
url = lib.mkOption {
|
||||
type = lib.types.str;
|
||||
default = "http://invidious.nor";
|
||||
description = "URL of the Invidious instance to use";
|
||||
};
|
||||
};
|
||||
};
|
||||
|
||||
default = {
|
||||
enable = false;
|
||||
url = "http://invidious.nor";
|
||||
};
|
||||
};
|
||||
|
||||
user = lib.mkOption {
|
||||
type = lib.types.str;
|
||||
description = "User account under which QueueCube runs (required)";
|
||||
};
|
||||
};
|
||||
|
||||
config = lib.mkIf cfg.enable {
|
||||
users.users.${cfg.user} = {
|
||||
packages = [ package ];
|
||||
};
|
||||
|
||||
systemd.user.services.queuecube = {
|
||||
description = "QueueCube media player service";
|
||||
wantedBy = [ "default.target" ];
|
||||
after = [ "pipewire.service" "pipewire-pulse.service" ];
|
||||
|
||||
serviceConfig = {
|
||||
ExecStart = "${package}/bin/queuecube";
|
||||
Restart = "on-failure";
|
||||
RestartSec = 5;
|
||||
|
||||
# Remove all resource limits for mpv to function properly
|
||||
LimitNOFILE = "infinity"; # No limit on file descriptors
|
||||
LimitMEMLOCK = "infinity"; # No limit on locked memory (for real-time audio)
|
||||
LimitNPROC = "infinity"; # No limit on number of processes
|
||||
LimitAS = "infinity"; # No limit on address space
|
||||
LimitRSS = "infinity"; # No limit on resident set size
|
||||
LimitCORE = "infinity"; # Allow core dumps for debugging
|
||||
LimitDATA = "infinity"; # No limit on data segment
|
||||
LimitSTACK = "infinity"; # No limit on stack size
|
||||
LimitCPU = "infinity"; # No limit on CPU time
|
||||
LimitRTPRIO = "99"; # Allow real-time priority
|
||||
LimitRTTIME = "infinity"; # No limit on real-time scheduling
|
||||
|
||||
# Nice level for better performance
|
||||
Nice = "-10";
|
||||
|
||||
# Allow access to necessary devices and features
|
||||
PrivateDevices = false;
|
||||
ProtectHome = false;
|
||||
ProtectSystem = false;
|
||||
NoNewPrivileges = false;
|
||||
|
||||
# Environment for X11 and runtime directories
|
||||
Environment = [
|
||||
"DISPLAY=:0"
|
||||
];
|
||||
};
|
||||
|
||||
environment = {
|
||||
PORT = toString cfg.port;
|
||||
ENABLE_VIDEO = if cfg.enable_video then "1" else "0";
|
||||
ENABLE_SCREENSHARE = if cfg.enable_screenshare then "1" else "0";
|
||||
USE_INVIDIOUS = if cfg.invidious.enable then "1" else "0";
|
||||
INVIDIOUS_BASE_URL = cfg.invidious.url;
|
||||
STORE_PATH = cfg.store_path;
|
||||
} // lib.optionalAttrs (cfg.mpv_ytdl_format != null) {
|
||||
MPV_YTDL_FORMAT = cfg.mpv_ytdl_format;
|
||||
};
|
||||
};
|
||||
};
|
||||
};
|
||||
in
|
||||
flake-utils.lib.eachDefaultSystem (system:
|
||||
let
|
||||
pkgs = nixpkgs.legacyPackages.${system};
|
||||
queuecube = mkQueuecube pkgs;
|
||||
|
||||
in {
|
||||
packages = {
|
||||
default = queuecube;
|
||||
@@ -208,8 +217,7 @@
|
||||
# Development environment
|
||||
devShells.default = pkgs.mkShell {
|
||||
buildInputs = with pkgs; [
|
||||
nodejs_20
|
||||
nodePackages.npm
|
||||
nodejs
|
||||
mpv
|
||||
yt-dlp
|
||||
pulseaudio
|
||||
|
||||
Reference in New Issue
Block a user