Merge pull request #233092 from midchildan/chore/mirakurun/node18

This commit is contained in:
Sandro 2023-05-25 14:47:50 +02:00 committed by GitHub
commit 1b40315504
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
9 changed files with 117 additions and 7245 deletions

View File

@ -154,6 +154,9 @@ in
description = "Mirakurun user";
group = "video";
isSystemUser = true;
# NPM insists on creating ~/.npm
home = "/var/cache/mirakurun";
};
services.mirakurun.serverSettings = {
@ -171,9 +174,10 @@ in
wantedBy = [ "multi-user.target" ];
after = [ "network.target" ];
serviceConfig = {
ExecStart = "${mirakurun}/bin/mirakurun-start";
ExecStart = "${mirakurun}/bin/mirakurun start";
User = username;
Group = groupname;
CacheDirectory = "mirakurun";
RuntimeDirectory="mirakurun";
StateDirectory="mirakurun";
Nice = -10;

View File

@ -1,96 +1,74 @@
# NOTE: Mirakurun is packaged outside of nodePackages because Node2nix can't
# handle one of its subdependencies. See below link for details.
#
# https://github.com/Chinachu/node-aribts/blob/af84dbbbd81ea80b946e538083b64b5b2dc7e8f2/package.json#L26
{ lib
, stdenvNoCC
, stdenv
, bash
, buildNpmPackage
, fetchFromGitHub
, gitUpdater
, jq
, installShellFiles
, makeWrapper
, mkYarnPackage
, which
, writers
, nodejs
, substituteAll
, v4l-utils
, yarn
, yarn2nix
, which
}:
stdenvNoCC.mkDerivation rec {
buildNpmPackage rec {
pname = "mirakurun";
version = "3.8.0";
version = "3.9.0-rc.4";
src = fetchFromGitHub {
owner = "Chinachu";
repo = "Mirakurun";
rev = version;
sha256 = "1fmzi3jc3havvpc1kz5z16k52lnrsmc3b5yqyxc7i911gqyjsxzr";
sha256 = "sha256-Qg+wET5H9t3Mv2Hv0iT/C85/SEaQ+BHSBL3JjMQW5+Q=";
};
nativeBuildInputs = [ makeWrapper ];
patches = [
# NOTE: fixes for hardcoded paths and assumptions about filesystem
# permissions
./nix-filesystem.patch
];
mirakurun = mkYarnPackage rec {
name = "${pname}-${version}";
inherit version src;
npmDepsHash = "sha256-e7m7xb7p1SBzLAyQ82TTR/qLXv4lRm37x0JJPWYYGvI=";
yarnNix = ./yarn.nix;
yarnLock = ./yarn.lock;
packageJSON = ./package.json;
nativeBuildInputs = [ installShellFiles makeWrapper ];
# workaround for https://github.com/webpack/webpack/issues/14532
NODE_OPTIONS = "--openssl-legacy-provider";
# workaround for https://github.com/webpack/webpack/issues/14532
NODE_OPTIONS = "--openssl-legacy-provider";
patches = [
# NOTE: fixes for hardcoded paths and assumptions about filesystem
# permissions
./nix-filesystem.patch
];
buildPhase = ''
yarn --offline build
'';
distPhase = "true";
};
installPhase =
postInstall =
let
runtimeDeps = [ bash which v4l-utils ];
runtimeDeps = [
bash
nodejs
which
] ++ lib.optionals stdenv.isLinux [ v4l-utils ];
crc32Patch = substituteAll {
src = ./fix-musl-detection.patch;
isMusl = if stdenv.hostPlatform.isMusl then "true" else "false";
};
in
''
mkdir -p $out/bin
sed 's/@DESCRIPTION@/${meta.description}/g' ${./mirakurun.1} > mirakurun.1
installManPage mirakurun.1
makeWrapper ${mirakurun}/bin/mirakurun-epgdump $out/bin/mirakurun-epgdump \
--chdir "${mirakurun}/libexec/mirakurun/node_modules/mirakurun" \
wrapProgram $out/bin/mirakurun-epgdump \
--prefix PATH : ${lib.makeBinPath runtimeDeps}
# XXX: The original mirakurun command uses PM2 to manage the Mirakurun
# server. However, we invoke the server directly and let systemd
# manage it to avoid complication. This is okay since no features
# unique to PM2 is currently being used.
makeWrapper ${yarn}/bin/yarn $out/bin/mirakurun-start \
--add-flags "start" \
--chdir "${mirakurun}/libexec/mirakurun/node_modules/mirakurun" \
makeWrapper ${nodejs}/bin/npm $out/bin/mirakurun \
--chdir "$out/lib/node_modules/mirakurun" \
--prefix PATH : ${lib.makeBinPath runtimeDeps}
pushd $out/lib/node_modules/mirakurun/node_modules/@node-rs/crc32
patch -p3 < ${crc32Patch}
popd
'';
passthru.updateScript = import ./update.nix {
inherit lib;
inherit (src.meta) homepage;
inherit
pname
version
gitUpdater
writers
jq
yarn
yarn2nix;
};
meta = with lib; {
inherit (mirakurun.meta) description platforms;
description = "Resource manager for TV tuners.";
license = licenses.asl20;
maintainers = with maintainers; [ midchildan ];
};

View File

@ -0,0 +1,29 @@
diff --git a/packages/crc32/index.js b/packages/crc32/index.js
index cdc7519..7b05930 100644
--- a/packages/crc32/index.js
+++ b/packages/crc32/index.js
@@ -5,7 +5,7 @@ const { platform, arch } = process
let nativeBinding = null
let localFileExisted = false
-let isMusl = false
+let isMusl = @isMusl@
let loadError = null
switch (platform) {
@@ -114,7 +114,6 @@ switch (platform) {
case 'linux':
switch (arch) {
case 'x64':
- isMusl = readFileSync('/usr/bin/ldd', 'utf8').includes('musl')
if (isMusl) {
localFileExisted = existsSync(join(__dirname, 'crc32.linux-x64-musl.node'))
try {
@@ -140,7 +139,6 @@ switch (platform) {
}
break
case 'arm64':
- isMusl = readFileSync('/usr/bin/ldd', 'utf8').includes('musl')
if (isMusl) {
localFileExisted = existsSync(join(__dirname, 'crc32.linux-arm64-musl.node'))
try {

View File

@ -0,0 +1,44 @@
.Dd $Mdocdate$
.Dt MIRAKURUN 1
.Os
.Sh NAME
.Nm mirakurun
.Nd @DESCRIPTION@
.Sh SYNOPSIS
.Nm
.Bk -words
.Op Ar command Op Ar args
.Ek
.Sh DESCRIPTION
.Nm
is a wrapper command for Mirakurun provided by Nix. It's actually a thin
wrapper around the
.Xr npm 1
command line tool which you can use to invoke npm commands from the Mirakurun
project directory. The command line arguments are simply passed as-is to
.Xr npm 1 .
.Pp
On NixOS, it is strongly recommended that you enable the mirakurun module
instead of invoking this command directly to launch Mirakurun. On other
platforms, run
.Pp
.Dl $ mirakurun start
.Pp
to start Mirakurun.
.Sh FILES
.Bl -tag -width Ds -compact
.It Pa /etc/mirakurun
.Nm
configuration directory.
.El
.Sh EXAMPLES
Start Mirakurun.
.Pp
.Dl $ mirakurun start
.Pp
Start Mirakurun in development mode.
.Pp
.Dl $ mirakurun run debug
.Pp
.Sh SEE ALSO
.Xr npm 1

View File

@ -1,129 +0,0 @@
{
"name": "mirakurun",
"preferGlobal": true,
"description": "Japanese DTV Tuner Server Service.",
"version": "3.8.0",
"homepage": "https://github.com/Chinachu/Mirakurun",
"keywords": [
"mirakurun",
"chinachu",
"rivarun",
"arib",
"isdb",
"dvb",
"dvr",
"dtv",
"tv"
],
"author": {
"name": "kanreisa",
"url": "https://github.com/kanreisa"
},
"contributors": [
"rndomhack"
],
"repository": {
"type": "git",
"url": "https://github.com/Chinachu/Mirakurun.git"
},
"bugs": {
"url": "https://github.com/Chinachu/Mirakurun/issues"
},
"license": "Apache-2.0",
"bin": {
"mirakurun": "bin/cli.sh",
"mirakurun-epgdump": "bin/epgdump.js"
},
"main": "lib/client.js",
"scripts": {
"start": "node -r source-map-support/register lib/server.js",
"debug": "node -r source-map-support/register --inspect=0.0.0.0:9229 lib/server.js",
"start.win32": "node.exe -r source-map-support/register bin/init.win32.js",
"debug.win32": "node.exe -r source-map-support/register --inspect bin/init.win32.js",
"build": "tslint --project . && tsc --declaration && webpack",
"watch": "tsc -w --declaration",
"watch-webpack": "webpack -w",
"test": "tslint --project . && mocha --exit test/*.spec.js",
"clean": "rimraf lib/*",
"prepublishOnly": "npm run clean && npm run build",
"preinstall": "node bin/preinstall.js",
"postinstall": "node bin/postinstall.js && opencollective-postinstall",
"preuninstall": "node bin/preuninstall.js",
"docker-build": "docker-compose -f docker/docker-compose.yml build",
"docker-run": "docker-compose -f docker/docker-compose.yml run --rm --service-ports mirakurun",
"docker-debug": "docker-compose -f docker/docker-compose.yml run --rm --service-ports -e DEBUG=true mirakurun"
},
"directories": {
"doc": "doc",
"lib": "lib"
},
"dependencies": {
"@fluentui/react": "8.27.0",
"aribts": "^1.3.5",
"colors": "^1.4.0",
"cors": "^2.8.5",
"dotenv": "^8.6.0",
"eventemitter3": "^4.0.7",
"express": "^4.17.1",
"express-openapi": "^8.0.0",
"glob": "^7.1.7",
"ip": "^1.1.4",
"js-yaml": "^4.1.0",
"latest-version": "^5.1.0",
"morgan": "^1.10.0",
"openapi-types": "^7.2.3",
"opencollective": "^1.0.3",
"opencollective-postinstall": "^2.0.3",
"promise-queue": "^2.2.3",
"react": "^17.0.2",
"react-dom": "^17.0.2",
"semver": "^7.3.5",
"sift": "^7.0.1",
"source-map-support": "^0.5.19",
"stream-http": "^3.2.0",
"swagger-ui-dist": "3.51.2",
"tail": "^2.2.3"
},
"devDependencies": {
"@types/cors": "^2.8.12",
"@types/express": "^4.17.13",
"@types/ip": "^1.1.0",
"@types/js-yaml": "^4.0.2",
"@types/morgan": "^1.9.3",
"@types/node": "^12.20.17",
"@types/promise-queue": "^2.2.0",
"@types/react": "^17.0.14",
"@types/react-dom": "^17.0.9",
"buffer": "^6.0.3",
"copy-webpack-plugin": "^9.0.1",
"css-loader": "5.2.7",
"mocha": "^8.4.0",
"process": "^0.11.10",
"rimraf": "^3.0.2",
"style-loader": "^2.0.0",
"ts-loader": "^9.2.3",
"tslint": "^6.1.3",
"tslint-config-prettier": "^1.18.0",
"typescript": "^4.3.5",
"url": "^0.11.0",
"webpack": "5.48.0",
"webpack-cli": "^4.7.2"
},
"engines": {
"node": "^12 || ^14 || ^16"
},
"engineStrict": true,
"os": [
"linux",
"darwin",
"win32"
],
"funding": {
"type": "opencollective",
"url": "https://opencollective.com/Mirakurun"
},
"collective": {
"type": "opencollective",
"url": "https://opencollective.com/Mirakurun"
}
}

View File

@ -1,51 +0,0 @@
{ pname
, version
, homepage
, lib
, gitUpdater
, writers
, jq
, yarn
, yarn2nix
}:
let
updater = gitUpdater {
inherit pname version;
attrPath = lib.toLower pname;
# exclude prerelease versions
ignoredVersions = "-";
};
updateScript = builtins.elemAt updater.command 0;
updateArgs = map (lib.escapeShellArg) (builtins.tail updater.command);
in writers.writeBash "update-mirakurun" ''
set -euxo pipefail
WORKDIR="$(mktemp -d)"
cleanup() {
rm -rf "$WORKDIR"
}
trap cleanup EXIT
# bump the version
${updateScript} ${lib.concatStringsSep " " updateArgs}
# Get the path to the latest source. Note that we can't just pass the value
# of mirakurun.src directly because it'd be evaluated before we can run
# updateScript.
SRC="$(nix-build "${toString ../../../..}" --no-out-link -A mirakurun.src)"
if [[ "${version}" == "$(${jq}/bin/jq -r .version "$SRC/package.json")" ]]; then
echo "[INFO] Already using the latest version of ${pname}" >&2
exit
fi
cd "$WORKDIR"
cp "$SRC/package.json" package.json
"${yarn}/bin/yarn" install --ignore-scripts
"${yarn2nix}/bin/yarn2nix" > "${toString ./.}/yarn.nix"
cp yarn.lock "${toString ./.}/yarn.lock"
cp package.json "${toString ./.}/package.json"
''

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -10122,13 +10122,7 @@ with pkgs;
pythonPackages = python3Packages;
};
mirakurun = callPackage ../applications/video/mirakurun {
yarn = yarn.override { nodejs = nodejs_16; };
inherit (callPackage ../development/tools/yarn2nix-moretea/yarn2nix {
nodejs = nodejs_16;
yarn = yarn.override { nodejs = nodejs_16; };
}) mkYarnPackage;
};
mirakurun = callPackage ../applications/video/mirakurun { };
miredo = callPackage ../tools/networking/miredo { };