aboutsummaryrefslogtreecommitdiff
path: root/infra/libkookie/nixpkgs/pkgs/applications/video/epgstation/update.nix
blob: 9faa83c64f9e076d4e6e470a1500de65e38afebb (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
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
''