mirakurun: build with yarn2nix
This commit is contained in:
parent
9cbdd2655c
commit
21a7695b8a
10 changed files with 7324 additions and 33 deletions
|
@ -173,7 +173,7 @@ in
|
|||
wantedBy = [ "multi-user.target" ];
|
||||
after = [ "network.target" ];
|
||||
serviceConfig = {
|
||||
ExecStart = "${mirakurun}/bin/mirakurun";
|
||||
ExecStart = "${mirakurun}/bin/mirakurun-start";
|
||||
User = username;
|
||||
Group = groupname;
|
||||
RuntimeDirectory="mirakurun";
|
||||
|
|
95
pkgs/applications/video/mirakurun/default.nix
Normal file
95
pkgs/applications/video/mirakurun/default.nix
Normal file
|
@ -0,0 +1,95 @@
|
|||
# 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
|
||||
, bash
|
||||
, common-updater-scripts
|
||||
, fetchFromGitHub
|
||||
, genericUpdater
|
||||
, jq
|
||||
, makeWrapper
|
||||
, mkYarnPackage
|
||||
, which
|
||||
, writers
|
||||
, v4l-utils
|
||||
, yarn
|
||||
, yarn2nix
|
||||
}:
|
||||
|
||||
stdenvNoCC.mkDerivation rec {
|
||||
pname = "mirakurun";
|
||||
version = "3.8.0";
|
||||
|
||||
src = fetchFromGitHub {
|
||||
owner = "Chinachu";
|
||||
repo = "Mirakurun";
|
||||
rev = version;
|
||||
sha256 = "1fmzi3jc3havvpc1kz5z16k52lnrsmc3b5yqyxc7i911gqyjsxzr";
|
||||
};
|
||||
|
||||
nativeBuildInputs = [ makeWrapper ];
|
||||
|
||||
mirakurun = mkYarnPackage rec {
|
||||
name = "${pname}-${version}";
|
||||
inherit version src;
|
||||
|
||||
yarnNix = ./yarn.nix;
|
||||
yarnLock = ./yarn.lock;
|
||||
packageJSON = ./package.json;
|
||||
|
||||
patches = [
|
||||
# NOTE: fixes for hardcoded paths and assumptions about filesystem
|
||||
# permissions
|
||||
./nix-filesystem.patch
|
||||
];
|
||||
|
||||
buildPhase = ''
|
||||
yarn --offline build
|
||||
'';
|
||||
|
||||
distPhase = "true";
|
||||
};
|
||||
|
||||
installPhase =
|
||||
let
|
||||
runtimeDeps = [ bash which v4l-utils ];
|
||||
in
|
||||
''
|
||||
mkdir -p $out/bin
|
||||
|
||||
makeWrapper ${mirakurun}/bin/mirakurun-epgdump $out/bin/mirakurun-epgdump \
|
||||
--run "cd ${mirakurun}/libexec/mirakurun/node_modules/mirakurun" \
|
||||
--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" \
|
||||
--run "cd ${mirakurun}/libexec/mirakurun/node_modules/mirakurun" \
|
||||
--prefix PATH : ${lib.makeBinPath runtimeDeps}
|
||||
'';
|
||||
|
||||
passthru.updateScript = import ./update.nix {
|
||||
inherit lib;
|
||||
inherit (src.meta) homepage;
|
||||
inherit
|
||||
pname
|
||||
version
|
||||
common-updater-scripts
|
||||
genericUpdater
|
||||
writers
|
||||
jq
|
||||
yarn
|
||||
yarn2nix;
|
||||
};
|
||||
|
||||
meta = {
|
||||
inherit (mirakurun.meta) description platforms;
|
||||
maintainers = with lib.maintainers; [ midchildan ];
|
||||
};
|
||||
}
|
46
pkgs/applications/video/mirakurun/nix-filesystem.patch
Normal file
46
pkgs/applications/video/mirakurun/nix-filesystem.patch
Normal file
|
@ -0,0 +1,46 @@
|
|||
diff --git a/processes.json b/processes.json
|
||||
index b54d404..a40dfab 100644
|
||||
--- a/processes.json
|
||||
+++ b/processes.json
|
||||
@@ -4,10 +4,10 @@
|
||||
"name": "mirakurun-server",
|
||||
"script": "lib/server.js",
|
||||
"node_args" : "-r source-map-support/register",
|
||||
- "error_file": "/usr/local/var/log/mirakurun.stderr.log",
|
||||
- "out_file": "/usr/local/var/log/mirakurun.stdout.log",
|
||||
+ "error_file": "/var/log/mirakurun.stderr.log",
|
||||
+ "out_file": "/var/log/mirakurun.stdout.log",
|
||||
"merge_logs": true,
|
||||
- "pid_file": "/usr/local/var/run/mirakurun.pid",
|
||||
+ "pid_file": "/var/run/mirakurun.pid",
|
||||
"exec_mode": "fork",
|
||||
"autorestart": true,
|
||||
"env": {
|
||||
diff --git a/src/Mirakurun/config.ts b/src/Mirakurun/config.ts
|
||||
index 0b8a1a2..ff02fda 100644
|
||||
--- a/src/Mirakurun/config.ts
|
||||
+++ b/src/Mirakurun/config.ts
|
||||
@@ -146,6 +146,7 @@ export function loadServer(): Server {
|
||||
fs.copyFileSync("config/server.win32.yml", path);
|
||||
} else {
|
||||
fs.copyFileSync("config/server.yml", path);
|
||||
+ fs.chmodSync(path, 0o644);
|
||||
}
|
||||
} catch (e) {
|
||||
log.fatal("failed to copy server config to `%s`", path);
|
||||
@@ -300,6 +301,7 @@ export function loadTuners(): Tuner[] {
|
||||
fs.copyFileSync("config/tuners.win32.yml", path);
|
||||
} else {
|
||||
fs.copyFileSync("config/tuners.yml", path);
|
||||
+ fs.chmodSync(path, 0o644);
|
||||
}
|
||||
} catch (e) {
|
||||
log.fatal("failed to copy tuners config to `%s`", path);
|
||||
@@ -342,6 +344,7 @@ export function loadChannels(): Channel[] {
|
||||
fs.copyFileSync("config/channels.win32.yml", path);
|
||||
} else {
|
||||
fs.copyFileSync("config/channels.yml", path);
|
||||
+ fs.chmodSync(path, 0o644);
|
||||
}
|
||||
} catch (e) {
|
||||
log.fatal("failed to copy channels config to `%s`", path);
|
129
pkgs/applications/video/mirakurun/package.json
Normal file
129
pkgs/applications/video/mirakurun/package.json
Normal file
|
@ -0,0 +1,129 @@
|
|||
{
|
||||
"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"
|
||||
}
|
||||
}
|
55
pkgs/applications/video/mirakurun/update.nix
Normal file
55
pkgs/applications/video/mirakurun/update.nix
Normal file
|
@ -0,0 +1,55 @@
|
|||
{ pname
|
||||
, version
|
||||
, homepage
|
||||
, lib
|
||||
, common-updater-scripts
|
||||
, genericUpdater
|
||||
, writers
|
||||
, jq
|
||||
, yarn
|
||||
, yarn2nix
|
||||
}:
|
||||
|
||||
let
|
||||
updater = genericUpdater {
|
||||
inherit pname version;
|
||||
attrPath = lib.toLower pname;
|
||||
|
||||
# exclude prerelease versions
|
||||
versionLister = writers.writeBash "list-mirakurun-versions" ''
|
||||
${common-updater-scripts}/bin/list-git-tags ${homepage} \
|
||||
| grep '^[0-9]\+\.[0-9]\+\.[0-9]\+$'
|
||||
'';
|
||||
};
|
||||
updateScript = builtins.elemAt updater 0;
|
||||
updateArgs = map (lib.escapeShellArg) (builtins.tail updater);
|
||||
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"
|
||||
''
|
3232
pkgs/applications/video/mirakurun/yarn.lock
Normal file
3232
pkgs/applications/video/mirakurun/yarn.lock
Normal file
File diff suppressed because it is too large
Load diff
3765
pkgs/applications/video/mirakurun/yarn.nix
Normal file
3765
pkgs/applications/video/mirakurun/yarn.nix
Normal file
File diff suppressed because it is too large
Load diff
|
@ -168,36 +168,6 @@ let
|
|||
meta.mainProgram = "markdownlint";
|
||||
};
|
||||
|
||||
mirakurun = super.mirakurun.override rec {
|
||||
nativeBuildInputs = with pkgs; [ makeWrapper ];
|
||||
postInstall = let
|
||||
runtimeDeps = [ nodejs ] ++ (with pkgs; [ bash which v4l-utils ]);
|
||||
in
|
||||
''
|
||||
substituteInPlace $out/lib/node_modules/mirakurun/processes.json \
|
||||
--replace "/usr/local" ""
|
||||
|
||||
# XXX: Files copied from the Nix store are non-writable, so they need
|
||||
# to be given explicit write permissions
|
||||
substituteInPlace $out/lib/node_modules/mirakurun/lib/Mirakurun/config.js \
|
||||
--replace 'fs.copyFileSync("config/server.yml", path);' \
|
||||
'fs.copyFileSync("config/server.yml", path); fs.chmodSync(path, 0o644);' \
|
||||
--replace 'fs.copyFileSync("config/tuners.yml", path);' \
|
||||
'fs.copyFileSync("config/tuners.yml", path); fs.chmodSync(path, 0o644);' \
|
||||
--replace 'fs.copyFileSync("config/channels.yml", path);' \
|
||||
'fs.copyFileSync("config/channels.yml", path); fs.chmodSync(path, 0o644);'
|
||||
|
||||
# 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 ${nodejs}/bin/npm $out/bin/mirakurun \
|
||||
--add-flags "start" \
|
||||
--run "cd $out/lib/node_modules/mirakurun" \
|
||||
--prefix PATH : ${pkgs.lib.makeBinPath runtimeDeps}
|
||||
'';
|
||||
};
|
||||
|
||||
node-gyp = super.node-gyp.override {
|
||||
nativeBuildInputs = [ pkgs.makeWrapper ];
|
||||
# Teach node-gyp to use nodejs headers locally rather that download them form https://nodejs.org.
|
||||
|
|
|
@ -173,7 +173,6 @@
|
|||
, "mathjax"
|
||||
, "meat"
|
||||
, "@mermaid-js/mermaid-cli"
|
||||
, "mirakurun"
|
||||
, "mocha"
|
||||
, "multi-file-swagger"
|
||||
, "musescore-downloader"
|
||||
|
|
|
@ -7215,7 +7215,7 @@ with pkgs;
|
|||
pythonPackages = python3Packages;
|
||||
};
|
||||
|
||||
mirakurun = nodePackages.mirakurun;
|
||||
mirakurun = callPackage ../applications/video/mirakurun { };
|
||||
|
||||
miredo = callPackage ../tools/networking/miredo { };
|
||||
|
||||
|
|
Loading…
Reference in a new issue