mirror of
https://github.com/NixOS/nixpkgs.git
synced 2024-11-24 07:53:19 +00:00
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
|
||||
# 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 {
|
||||
# FIXME: This should be removed when a complete fix is available
|
||||
# https://github.com/svanderburg/node2nix/issues/145
|
||||
@ -12,67 +33,73 @@ let
|
||||
chmod +x $out/bin/opencollective-postinstall
|
||||
'';
|
||||
};
|
||||
in
|
||||
nodePackages.epgstation.override (drv: {
|
||||
src = fetchFromGitHub {
|
||||
owner = "l3tnun";
|
||||
repo = "EPGStation";
|
||||
rev = "v${drv.version}"; # version specified in ./generate.sh
|
||||
sha256 = "15z1kdbamj97frp3dfnbm0h8krihmv2xdab4id0rxin29ibrw1k2";
|
||||
};
|
||||
|
||||
buildInputs = [ bash ];
|
||||
nativeBuildInputs = [
|
||||
workaround-opencollective-buildfailures
|
||||
makeWrapper
|
||||
nodePackages.node-pre-gyp
|
||||
];
|
||||
pkg = nodePackages.epgstation.override (drv: {
|
||||
inherit src;
|
||||
|
||||
preRebuild = ''
|
||||
# Fix for not being able to connect to mysql using domain sockets.
|
||||
patch -p1 ${./use-mysql-over-domain-socket.patch}
|
||||
'';
|
||||
buildInputs = [ bash ];
|
||||
nativeBuildInputs = [
|
||||
workaround-opencollective-buildfailures
|
||||
makeWrapper
|
||||
nodePackages.node-pre-gyp
|
||||
];
|
||||
|
||||
postInstall = let
|
||||
runtimeDeps = [ nodejs bash ];
|
||||
in
|
||||
''
|
||||
mkdir -p $out/{bin,libexec,share/doc/epgstation,share/man/man1}
|
||||
preRebuild = ''
|
||||
# Fix for not being able to connect to mysql using domain sockets.
|
||||
patch -p1 ${./use-mysql-over-domain-socket.patch}
|
||||
'';
|
||||
|
||||
pushd $out/lib/node_modules/EPGStation
|
||||
postInstall = let
|
||||
runtimeDeps = [ nodejs bash ];
|
||||
in
|
||||
''
|
||||
mkdir -p $out/{bin,libexec,share/doc/epgstation,share/man/man1}
|
||||
|
||||
npm run build
|
||||
npm prune --production
|
||||
pushd $out/lib/node_modules/EPGStation
|
||||
|
||||
mv config/{enc.sh,enc.js} $out/libexec
|
||||
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
|
||||
npm run build
|
||||
npm prune --production
|
||||
|
||||
# just log to stdout and let journald do its job
|
||||
rm -rf logs
|
||||
mv config/{enc.sh,enc.js} $out/libexec
|
||||
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
|
||||
|
||||
# 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
|
||||
# just log to stdout and let journald do its job
|
||||
rm -rf logs
|
||||
|
||||
makeWrapper ${nodejs}/bin/npm $out/bin/epgstation \
|
||||
--run "cd $out/lib/node_modules/EPGStation" \
|
||||
--prefix PATH : ${stdenv.lib.makeBinPath runtimeDeps}
|
||||
# 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
|
||||
|
||||
popd
|
||||
'';
|
||||
makeWrapper ${nodejs}/bin/npm $out/bin/epgstation \
|
||||
--run "cd $out/lib/node_modules/EPGStation" \
|
||||
--prefix PATH : ${stdenv.lib.makeBinPath runtimeDeps}
|
||||
|
||||
meta = with stdenv.lib; drv.meta // {
|
||||
maintainers = with maintainers; [ midchildan ];
|
||||
popd
|
||||
'';
|
||||
|
||||
# NOTE: this may take a while since it has to update all packages in
|
||||
# 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
|
||||
# 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
|
||||
# allows us to provide devDependencies for the epgstation build process
|
||||
# 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