2021-01-15 22:18:51 +00:00
|
|
|
{ lib
|
|
|
|
, stdenv
|
2020-11-06 00:33:48 +00:00
|
|
|
, fetchFromGitHub
|
2022-04-27 09:35:20 +00:00
|
|
|
, gitUpdater
|
2020-11-06 00:33:48 +00:00
|
|
|
, writers
|
|
|
|
, makeWrapper
|
|
|
|
, bash
|
|
|
|
, nodejs
|
|
|
|
, nodePackages
|
|
|
|
, gzip
|
|
|
|
, jq
|
2022-03-30 09:31:56 +00:00
|
|
|
, yq
|
2020-11-06 00:33:48 +00:00
|
|
|
}:
|
2020-09-25 04:45:31 +00:00
|
|
|
|
|
|
|
let
|
2020-11-06 00:33:48 +00:00
|
|
|
# NOTE: use updateScript to bump the package version
|
|
|
|
pname = "EPGStation";
|
2022-03-30 09:31:56 +00:00
|
|
|
version = "2.6.20";
|
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
|
|
|
};
|
|
|
|
|
2022-03-30 09:31:56 +00:00
|
|
|
client = nodePackages.epgstation-client.override (drv: {
|
|
|
|
# FIXME: remove this option if possible
|
|
|
|
#
|
|
|
|
# Unsetting this option resulted NPM attempting to re-download packages.
|
|
|
|
dontNpmInstall = true;
|
|
|
|
|
|
|
|
meta = drv.meta // {
|
|
|
|
inherit (nodejs.meta) platforms;
|
|
|
|
};
|
|
|
|
});
|
|
|
|
|
|
|
|
server = nodePackages.epgstation.override (drv: {
|
2020-11-06 00:33:48 +00:00
|
|
|
inherit src;
|
|
|
|
|
2022-03-30 09:31:56 +00:00
|
|
|
# This is set to false to keep devDependencies at build time. Build time
|
|
|
|
# dependencies are pruned afterwards.
|
|
|
|
production = false;
|
|
|
|
|
2022-05-18 14:49:53 +00:00
|
|
|
buildInputs = (drv.buildInputs or [ ]) ++ [ bash ];
|
|
|
|
nativeBuildInputs = (drv.nativeBuildInputs or [ ]) ++ [
|
2020-11-06 00:33:48 +00:00
|
|
|
makeWrapper
|
2022-05-18 14:49:53 +00:00
|
|
|
];
|
2020-11-06 00:33:48 +00:00
|
|
|
|
|
|
|
preRebuild = ''
|
|
|
|
# Fix for not being able to connect to mysql using domain sockets.
|
2022-03-30 09:31:56 +00:00
|
|
|
patch -p1 < ${./use-mysql-over-domain-socket.patch}
|
|
|
|
|
|
|
|
# Workaround for https://github.com/svanderburg/node2nix/issues/275
|
|
|
|
sed -i -e "s|#!/usr/bin/env node|#! ${nodejs}/bin/node|" node_modules/node-gyp-build/bin.js
|
|
|
|
|
|
|
|
find . -name package-lock.json -delete
|
2020-11-06 00:33:48 +00:00
|
|
|
'';
|
|
|
|
|
|
|
|
postInstall = let
|
|
|
|
runtimeDeps = [ nodejs bash ];
|
|
|
|
in
|
|
|
|
''
|
|
|
|
mkdir -p $out/{bin,libexec,share/doc/epgstation,share/man/man1}
|
|
|
|
|
2022-03-30 09:31:56 +00:00
|
|
|
pushd $out/lib/node_modules/epgstation
|
|
|
|
|
|
|
|
cp -r ${client}/lib/node_modules/epgstation-client/node_modules client/node_modules
|
|
|
|
chmod -R u+w client/node_modules
|
2020-11-06 00:33:48 +00:00
|
|
|
|
|
|
|
npm run build
|
2022-03-30 09:31:56 +00:00
|
|
|
|
2020-11-06 00:33:48 +00:00
|
|
|
npm prune --production
|
2022-03-30 09:31:56 +00:00
|
|
|
pushd client
|
|
|
|
npm prune --production
|
|
|
|
popd
|
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
|
|
|
|
sed 's/@DESCRIPTION@/${drv.meta.description}/g' ${./epgstation.1} \
|
|
|
|
| ${gzip}/bin/gzip > $out/share/man/man1/epgstation.1.gz
|
|
|
|
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.
|
|
|
|
rm -r config data recorded thumbnail
|
|
|
|
ln -sfT /etc/epgstation config
|
|
|
|
ln -sfT /var/lib/epgstation data
|
|
|
|
ln -sfT /var/lib/epgstation/recorded recorded
|
|
|
|
ln -sfT /var/lib/epgstation/thumbnail thumbnail
|
|
|
|
|
|
|
|
makeWrapper ${nodejs}/bin/npm $out/bin/epgstation \
|
2022-04-27 09:35:20 +00:00
|
|
|
--chdir "$out/lib/node_modules/epgstation" \
|
2022-03-30 09:31:56 +00:00
|
|
|
--prefix PATH : ${lib.makeBinPath runtimeDeps} \
|
|
|
|
--set APP_ROOT_PATH "$out/lib/node_modules/epgstation"
|
2020-11-06 00:33:48 +00:00
|
|
|
|
|
|
|
popd
|
|
|
|
'';
|
|
|
|
|
|
|
|
# NOTE: this may take a while since it has to update all packages in
|
|
|
|
# nixpkgs.nodePackages
|
|
|
|
passthru.updateScript = import ./update.nix {
|
2021-02-05 17:12:51 +00:00
|
|
|
inherit lib;
|
2020-11-06 00:33:48 +00:00
|
|
|
inherit (src.meta) homepage;
|
|
|
|
inherit
|
|
|
|
pname
|
|
|
|
version
|
2022-04-27 09:35:20 +00:00
|
|
|
gitUpdater
|
2020-11-06 00:33:48 +00:00
|
|
|
writers
|
2022-03-30 09:31:56 +00:00
|
|
|
jq
|
|
|
|
yq;
|
2020-11-06 00:33:48 +00:00
|
|
|
};
|
2020-09-25 04:45:31 +00:00
|
|
|
|
|
|
|
# nodePackages.epgstation is a stub package to fetch npm dependencies and
|
2022-03-30 09:31:56 +00:00
|
|
|
# its meta.platforms is made empty to prevent users from installing it
|
|
|
|
# directly. This technique ensures epgstation can share npm packages with
|
|
|
|
# the rest of nixpkgs while still allowing us to heavily customize the
|
|
|
|
# build. It also allows us to provide devDependencies for the epgstation
|
|
|
|
# build process without doing the same for all the other node packages.
|
|
|
|
meta = drv.meta // {
|
|
|
|
inherit (nodejs.meta) platforms;
|
|
|
|
};
|
2020-11-06 00:33:48 +00:00
|
|
|
});
|
|
|
|
in
|
2022-03-30 09:31:56 +00:00
|
|
|
server // {
|
2020-11-06 00:33:48 +00:00
|
|
|
name = "${pname}-${version}";
|
|
|
|
|
2022-03-30 09:31:56 +00:00
|
|
|
meta = with lib; server.meta // {
|
2020-11-06 00:33:48 +00:00
|
|
|
maintainers = with maintainers; [ midchildan ];
|
|
|
|
|
|
|
|
# NOTE: updateScript relies on this being correct
|
|
|
|
position = toString ./default.nix + ":1";
|
2020-09-25 04:45:31 +00:00
|
|
|
};
|
2020-11-06 00:33:48 +00:00
|
|
|
}
|