2021-01-15 22:18:51 +00:00
|
|
|
{ lib
|
2023-05-24 13:37:59 +00:00
|
|
|
, fetchpatch
|
2020-11-06 00:33:48 +00:00
|
|
|
, fetchFromGitHub
|
2023-05-24 13:37:59 +00:00
|
|
|
, buildNpmPackage
|
|
|
|
, installShellFiles
|
2020-11-06 00:33:48 +00:00
|
|
|
, makeWrapper
|
|
|
|
, bash
|
|
|
|
, nodejs
|
|
|
|
, gzip
|
2023-05-24 13:37:59 +00:00
|
|
|
, python3
|
2020-11-06 00:33:48 +00:00
|
|
|
}:
|
2020-09-25 04:45:31 +00:00
|
|
|
|
2023-05-24 13:37:59 +00:00
|
|
|
buildNpmPackage rec {
|
|
|
|
pname = "epgstation";
|
2022-03-30 09:31:56 +00:00
|
|
|
version = "2.6.20";
|
2023-05-24 13:37:59 +00:00
|
|
|
|
2020-11-06 00:33:48 +00:00
|
|
|
src = fetchFromGitHub {
|
|
|
|
owner = "l3tnun";
|
|
|
|
repo = "EPGStation";
|
|
|
|
rev = "v${version}";
|
2022-03-30 09:31:56 +00:00
|
|
|
sha256 = "K1cAvmqWEfS6EY4MKAtjXb388XLYHtouxNM70PWgFig=";
|
2020-11-06 00:33:48 +00:00
|
|
|
};
|
|
|
|
|
2023-05-24 13:37:59 +00:00
|
|
|
patches = [
|
|
|
|
./use-mysql-over-domain-socket.patch
|
2022-03-30 09:31:56 +00:00
|
|
|
|
2023-05-24 13:37:59 +00:00
|
|
|
# upgrade dependencies to make it compatible with node 18
|
|
|
|
(fetchpatch {
|
|
|
|
url = "https://github.com/midchildan/EPGStation/commit/5d6cad746b7d9b6d246adcdecf9c991b77c9d89e.patch";
|
|
|
|
sha256 = "sha256-9a8VUjczlyQHVO7w9MYorPIZunAuBuif1HNmtp1yMk8=";
|
|
|
|
})
|
|
|
|
(fetchpatch {
|
|
|
|
url = "https://github.com/midchildan/EPGStation/commit/c948e833e485c2b7cb7fb33b953cca1e20de3a70.patch";
|
|
|
|
sha256 = "sha256-nM6KkVRURuQFZLXZ2etLU1a1+BoaJnfjngo07TFbe58=";
|
|
|
|
})
|
|
|
|
];
|
2022-03-30 09:31:56 +00:00
|
|
|
|
2023-05-24 13:37:59 +00:00
|
|
|
npmDepsHash = "sha256-dohencRGuvc+vSoclLVn5iles4GOuTq26BrEVeJ4GC4=";
|
|
|
|
npmBuildScript = "build-server";
|
|
|
|
npmRootPath = "/lib/node_modules/epgstation";
|
2020-11-06 00:33:48 +00:00
|
|
|
|
2023-05-24 13:37:59 +00:00
|
|
|
buildInputs = [ bash ];
|
|
|
|
nativeBuildInputs = [ installShellFiles makeWrapper python3 ];
|
2022-03-30 09:31:56 +00:00
|
|
|
|
2023-05-24 13:37:59 +00:00
|
|
|
clientDir = buildNpmPackage {
|
|
|
|
pname = "${pname}-client";
|
|
|
|
inherit version src installPhase meta;
|
2020-11-06 00:33:48 +00:00
|
|
|
|
2023-05-24 13:37:59 +00:00
|
|
|
npmDepsHash = "sha256-a/cDPABWI4lPxvSOI4D90O71A9lm8icPMak/g6DPYQY=";
|
|
|
|
npmRootPath = "";
|
2022-09-30 11:47:45 +00:00
|
|
|
|
2023-05-24 13:37:59 +00:00
|
|
|
sourceRoot = "source/client";
|
|
|
|
NODE_OPTIONS = "--openssl-legacy-provider";
|
|
|
|
};
|
2022-03-30 09:31:56 +00:00
|
|
|
|
2023-05-24 13:37:59 +00:00
|
|
|
postBuild = ''
|
|
|
|
rm -rf client
|
|
|
|
cp -r ${clientDir} client
|
|
|
|
'';
|
2022-03-30 09:31:56 +00:00
|
|
|
|
2023-05-24 13:37:59 +00:00
|
|
|
# installPhase is shared with clientDir
|
|
|
|
installPhase = ''
|
|
|
|
runHook preInstall
|
2022-10-06 18:32:54 +00:00
|
|
|
|
2023-05-24 13:37:59 +00:00
|
|
|
npm prune --omit dev --no-save \
|
|
|
|
$npmInstallFlags \
|
|
|
|
"''${npmInstallFlagsArray[@]}" \
|
|
|
|
$npmFlags \
|
|
|
|
"''${npmFlagsArray[@]}"
|
|
|
|
|
|
|
|
mkdir -p $out$npmRootPath
|
|
|
|
cp -r . $out$npmRootPath
|
|
|
|
|
|
|
|
runHook postInstall
|
|
|
|
'';
|
2020-11-06 00:33:48 +00:00
|
|
|
|
2023-05-24 13:37:59 +00:00
|
|
|
postInstall =
|
|
|
|
let
|
2020-11-06 00:33:48 +00:00
|
|
|
runtimeDeps = [ nodejs bash ];
|
|
|
|
in
|
|
|
|
''
|
2023-05-24 13:37:59 +00:00
|
|
|
mkdir -p $out/{bin,libexec,share/doc/epgstation}
|
2020-11-06 00:33:48 +00:00
|
|
|
|
2023-05-24 13:37:59 +00:00
|
|
|
pushd $out$npmRootPath
|
2020-11-06 00:33:48 +00:00
|
|
|
|
2022-03-30 09:31:56 +00:00
|
|
|
mv config/enc.js.template $out/libexec/enc.js
|
2020-11-06 00:33:48 +00:00
|
|
|
mv LICENSE Readme.md $out/share/doc/epgstation
|
|
|
|
mv doc/* $out/share/doc/epgstation
|
2023-05-24 13:37:59 +00:00
|
|
|
sed 's/@DESCRIPTION@/${meta.description}/g' ${./epgstation.1} > doc/epgstation.1
|
|
|
|
installManPage doc/epgstation.1
|
2020-11-06 00:33:48 +00:00
|
|
|
rm -rf doc
|
|
|
|
|
|
|
|
# just log to stdout and let journald do its job
|
|
|
|
rm -rf logs
|
|
|
|
|
|
|
|
# Replace the existing configuration and runtime state directories with
|
|
|
|
# symlinks. Without this, they would all be non-writable because they
|
|
|
|
# reside in the Nix store. Note that the source path won't be accessible
|
|
|
|
# at build time.
|
2023-05-24 13:37:59 +00:00
|
|
|
rm -r config data drop recorded thumbnail src/db/subscribers src/db/migrations
|
2020-11-06 00:33:48 +00:00
|
|
|
ln -sfT /etc/epgstation config
|
|
|
|
ln -sfT /var/lib/epgstation data
|
2023-05-24 13:37:59 +00:00
|
|
|
ln -sfT /var/lib/epgstation/drop drop
|
2020-11-06 00:33:48 +00:00
|
|
|
ln -sfT /var/lib/epgstation/recorded recorded
|
|
|
|
ln -sfT /var/lib/epgstation/thumbnail thumbnail
|
2023-05-24 13:37:59 +00:00
|
|
|
ln -sfT /var/lib/epgstation/db/subscribers src/db/subscribers
|
|
|
|
ln -sfT /var/lib/epgstation/db/migrations src/db/migrations
|
2020-11-06 00:33:48 +00:00
|
|
|
|
|
|
|
makeWrapper ${nodejs}/bin/npm $out/bin/epgstation \
|
2023-05-24 13:37:59 +00:00
|
|
|
--chdir $out$npmRootPath \
|
2022-03-30 09:31:56 +00:00
|
|
|
--prefix PATH : ${lib.makeBinPath runtimeDeps} \
|
2023-05-24 13:37:59 +00:00
|
|
|
--set APP_ROOT_PATH $out$npmRootPath
|
2020-11-06 00:33:48 +00:00
|
|
|
|
|
|
|
popd
|
|
|
|
'';
|
|
|
|
|
2023-05-24 13:37:59 +00:00
|
|
|
meta = with lib; {
|
|
|
|
description = "DVR software compatible with Mirakurun.";
|
|
|
|
homepage = "https://github.com/l3tnun/EPGStation";
|
|
|
|
license = licenses.mit;
|
2020-11-06 00:33:48 +00:00
|
|
|
maintainers = with maintainers; [ midchildan ];
|
2020-09-25 04:45:31 +00:00
|
|
|
};
|
2020-11-06 00:33:48 +00:00
|
|
|
}
|