epgstation: add updateScript
This commit is contained in:
parent
038afc6906
commit
323b47d96e
@ -1,31 +0,0 @@
|
|||||||
#!/usr/bin/env -S nix-build --no-out-link
|
|
||||||
|
|
||||||
# Script to generate default streaming configurations for EPGStation. There's
|
|
||||||
# no need to run this script directly since generate.sh in the EPGStation
|
|
||||||
# package directory would run this script for you.
|
|
||||||
#
|
|
||||||
# Usage: ./generate | xargs cat > streaming.json
|
|
||||||
|
|
||||||
{ pkgs ? (import ../../../../.. {}) }:
|
|
||||||
|
|
||||||
let
|
|
||||||
sampleConfigPath = "${pkgs.epgstation.src}/config/config.sample.json";
|
|
||||||
sampleConfig = builtins.fromJSON (builtins.readFile sampleConfigPath);
|
|
||||||
streamingConfig = {
|
|
||||||
inherit (sampleConfig)
|
|
||||||
mpegTsStreaming
|
|
||||||
mpegTsViewer
|
|
||||||
liveHLS
|
|
||||||
liveMP4
|
|
||||||
liveWebM
|
|
||||||
recordedDownloader
|
|
||||||
recordedStreaming
|
|
||||||
recordedViewer
|
|
||||||
recordedHLS;
|
|
||||||
};
|
|
||||||
in
|
|
||||||
pkgs.runCommand "streaming.json" { nativeBuildInputs = [ pkgs.jq ]; } ''
|
|
||||||
jq . <<<'${builtins.toJSON streamingConfig}' > $out
|
|
||||||
''
|
|
||||||
|
|
||||||
# vim:set ft=nix:
|
|
@ -1,6 +1,27 @@
|
|||||||
{ stdenv, fetchFromGitHub, makeWrapper, bash, nodejs, nodePackages, gzip }:
|
{ stdenv
|
||||||
|
, fetchFromGitHub
|
||||||
|
, common-updater-scripts
|
||||||
|
, genericUpdater
|
||||||
|
, writers
|
||||||
|
, makeWrapper
|
||||||
|
, bash
|
||||||
|
, nodejs
|
||||||
|
, nodePackages
|
||||||
|
, gzip
|
||||||
|
, jq
|
||||||
|
}:
|
||||||
|
|
||||||
let
|
let
|
||||||
|
# NOTE: use updateScript to bump the package version
|
||||||
|
pname = "EPGStation";
|
||||||
|
version = "1.7.4";
|
||||||
|
src = fetchFromGitHub {
|
||||||
|
owner = "l3tnun";
|
||||||
|
repo = "EPGStation";
|
||||||
|
rev = "v${version}";
|
||||||
|
sha256 = "15z1kdbamj97frp3dfnbm0h8krihmv2xdab4id0rxin29ibrw1k2";
|
||||||
|
};
|
||||||
|
|
||||||
workaround-opencollective-buildfailures = stdenv.mkDerivation {
|
workaround-opencollective-buildfailures = stdenv.mkDerivation {
|
||||||
# FIXME: This should be removed when a complete fix is available
|
# FIXME: This should be removed when a complete fix is available
|
||||||
# https://github.com/svanderburg/node2nix/issues/145
|
# https://github.com/svanderburg/node2nix/issues/145
|
||||||
@ -12,14 +33,9 @@ let
|
|||||||
chmod +x $out/bin/opencollective-postinstall
|
chmod +x $out/bin/opencollective-postinstall
|
||||||
'';
|
'';
|
||||||
};
|
};
|
||||||
in
|
|
||||||
nodePackages.epgstation.override (drv: {
|
pkg = nodePackages.epgstation.override (drv: {
|
||||||
src = fetchFromGitHub {
|
inherit src;
|
||||||
owner = "l3tnun";
|
|
||||||
repo = "EPGStation";
|
|
||||||
rev = "v${drv.version}"; # version specified in ./generate.sh
|
|
||||||
sha256 = "15z1kdbamj97frp3dfnbm0h8krihmv2xdab4id0rxin29ibrw1k2";
|
|
||||||
};
|
|
||||||
|
|
||||||
buildInputs = [ bash ];
|
buildInputs = [ bash ];
|
||||||
nativeBuildInputs = [
|
nativeBuildInputs = [
|
||||||
@ -55,9 +71,9 @@ nodePackages.epgstation.override (drv: {
|
|||||||
rm -rf logs
|
rm -rf logs
|
||||||
|
|
||||||
# Replace the existing configuration and runtime state directories with
|
# Replace the existing configuration and runtime state directories with
|
||||||
# symlinks. Without this, they would all be non-writable because they reside
|
# symlinks. Without this, they would all be non-writable because they
|
||||||
# in the Nix store. Note that the source path won't be accessible at build
|
# reside in the Nix store. Note that the source path won't be accessible
|
||||||
# time.
|
# at build time.
|
||||||
rm -r config data recorded thumbnail
|
rm -r config data recorded thumbnail
|
||||||
ln -sfT /etc/epgstation config
|
ln -sfT /etc/epgstation config
|
||||||
ln -sfT /var/lib/epgstation data
|
ln -sfT /var/lib/epgstation data
|
||||||
@ -71,8 +87,19 @@ nodePackages.epgstation.override (drv: {
|
|||||||
popd
|
popd
|
||||||
'';
|
'';
|
||||||
|
|
||||||
meta = with stdenv.lib; drv.meta // {
|
# NOTE: this may take a while since it has to update all packages in
|
||||||
maintainers = with maintainers; [ midchildan ];
|
# nixpkgs.nodePackages
|
||||||
|
passthru.updateScript = import ./update.nix {
|
||||||
|
inherit (stdenv) lib;
|
||||||
|
inherit (src.meta) homepage;
|
||||||
|
inherit
|
||||||
|
pname
|
||||||
|
version
|
||||||
|
common-updater-scripts
|
||||||
|
genericUpdater
|
||||||
|
writers
|
||||||
|
jq;
|
||||||
|
};
|
||||||
|
|
||||||
# nodePackages.epgstation is a stub package to fetch npm dependencies and
|
# nodePackages.epgstation is a stub package to fetch npm dependencies and
|
||||||
# is marked as broken to prevent users from installing it directly. This
|
# is marked as broken to prevent users from installing it directly. This
|
||||||
@ -80,6 +107,16 @@ nodePackages.epgstation.override (drv: {
|
|||||||
# nixpkgs while still allowing us to heavily customize the build. It also
|
# nixpkgs while still allowing us to heavily customize the build. It also
|
||||||
# allows us to provide devDependencies for the epgstation build process
|
# allows us to provide devDependencies for the epgstation build process
|
||||||
# without doing the same for all the other node packages.
|
# without doing the same for all the other node packages.
|
||||||
broken = false;
|
meta = drv.meta // { broken = false; };
|
||||||
|
});
|
||||||
|
in
|
||||||
|
pkg // {
|
||||||
|
name = "${pname}-${version}";
|
||||||
|
|
||||||
|
meta = with stdenv.lib; pkg.meta // {
|
||||||
|
maintainers = with maintainers; [ midchildan ];
|
||||||
|
|
||||||
|
# NOTE: updateScript relies on this being correct
|
||||||
|
position = toString ./default.nix + ":1";
|
||||||
};
|
};
|
||||||
})
|
}
|
||||||
|
@ -1,34 +0,0 @@
|
|||||||
#!/usr/bin/env bash
|
|
||||||
|
|
||||||
# Script to generate the Nix package definition for EPGStation. Run this script
|
|
||||||
# when bumping the package version.
|
|
||||||
|
|
||||||
VERSION="1.7.4"
|
|
||||||
URL="https://raw.githubusercontent.com/l3tnun/EPGStation/v$VERSION/package.json"
|
|
||||||
JQ_BIN="$(nix-build ../../../.. --no-out-link -A jq)/bin/jq"
|
|
||||||
|
|
||||||
set -eu -o pipefail
|
|
||||||
cd "$(dirname "${BASH_SOURCE[0]}")"
|
|
||||||
|
|
||||||
main() {
|
|
||||||
# update package.json
|
|
||||||
curl -sSfL "$URL" \
|
|
||||||
| jq '. + {"dependencies": (.devDependencies + .dependencies)} | del(.devDependencies)' \
|
|
||||||
> package.json
|
|
||||||
|
|
||||||
# regenerate node packages to update the actual Nix package
|
|
||||||
pushd ../../../development/node-packages \
|
|
||||||
&& ./generate.sh
|
|
||||||
popd
|
|
||||||
|
|
||||||
# generate default streaming settings for EPGStation
|
|
||||||
pushd ../../../../nixos/modules/services/video/epgstation \
|
|
||||||
&& cat "$(./generate)" > streaming.json
|
|
||||||
popd
|
|
||||||
}
|
|
||||||
|
|
||||||
jq() {
|
|
||||||
"$JQ_BIN" "$@"
|
|
||||||
}
|
|
||||||
|
|
||||||
main "@"
|
|
66
pkgs/applications/video/epgstation/update.nix
Normal file
66
pkgs/applications/video/epgstation/update.nix
Normal file
@ -0,0 +1,66 @@
|
|||||||
|
{ pname
|
||||||
|
, version
|
||||||
|
, homepage
|
||||||
|
, lib
|
||||||
|
, common-updater-scripts
|
||||||
|
, genericUpdater
|
||||||
|
, writers
|
||||||
|
, jq
|
||||||
|
}:
|
||||||
|
|
||||||
|
let
|
||||||
|
updater = genericUpdater {
|
||||||
|
inherit pname version;
|
||||||
|
attrPath = lib.toLower pname;
|
||||||
|
rev-prefix = "v";
|
||||||
|
versionLister = "${common-updater-scripts}/bin/list-git-tags ${homepage}";
|
||||||
|
};
|
||||||
|
updateScript = builtins.elemAt updater 0;
|
||||||
|
updateArgs = map (lib.escapeShellArg) (builtins.tail updater);
|
||||||
|
in writers.writeBash "update-epgstation" ''
|
||||||
|
set -euxo pipefail
|
||||||
|
|
||||||
|
# bump the version
|
||||||
|
${updateScript} ${lib.concatStringsSep " " updateArgs}
|
||||||
|
|
||||||
|
cd "${toString ./.}"
|
||||||
|
|
||||||
|
# Get the path to the latest source. Note that we can't just pass the value
|
||||||
|
# of epgstation.src directly because it'd be evaluated before we can run
|
||||||
|
# updateScript.
|
||||||
|
SRC="$(nix-build ../../../.. --no-out-link -A epgstation.src)"
|
||||||
|
if [[ "${version}" == "$(${jq}/bin/jq -r .version "$SRC/package.json")" ]]; then
|
||||||
|
echo "[INFO] Already using the latest version of ${pname}" >&2
|
||||||
|
exit
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Regenerate package.json from the latest source.
|
||||||
|
${jq}/bin/jq '. + {
|
||||||
|
dependencies: (.dependencies + .devDependencies),
|
||||||
|
} | del(.devDependencies, .main, .scripts)' \
|
||||||
|
"$SRC/package.json" \
|
||||||
|
> package.json
|
||||||
|
|
||||||
|
# Regenerate node packages to update the pre-overriden epgstation derivation.
|
||||||
|
# This must come *after* package.json has been regenerated.
|
||||||
|
pushd ../../../development/node-packages
|
||||||
|
./generate.sh
|
||||||
|
popd
|
||||||
|
|
||||||
|
# Generate default streaming settings for the nixos module.
|
||||||
|
pushd ../../../../nixos/modules/services/video/epgstation
|
||||||
|
${jq}/bin/jq '
|
||||||
|
{ liveHLS
|
||||||
|
, liveMP4
|
||||||
|
, liveWebM
|
||||||
|
, mpegTsStreaming
|
||||||
|
, mpegTsViewer
|
||||||
|
, recordedDownloader
|
||||||
|
, recordedStreaming
|
||||||
|
, recordedHLS
|
||||||
|
, recordedViewer
|
||||||
|
}' \
|
||||||
|
"$SRC/config/config.sample.json" \
|
||||||
|
> streaming.json
|
||||||
|
popd
|
||||||
|
''
|
Loading…
Reference in New Issue
Block a user