about summary refs log tree commit diff
path: root/pkgs/applications/video/epgstation/update.nix
blob: 4b9907384e58d0c20259219a40755f1f65c658d0 (plain) (blame)
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
{ gitUpdater
, writers
, jq
, yq
, gnused
, _experimental-update-script-combinators
}:

let
  updateSource = gitUpdater {
    rev-prefix = "v";
  };
  updateLocks = writers.writeBash "update-epgstation" ''
    set -euxo pipefail

    cd "$1"

    # 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 [[ "$UPDATE_NIX_OLD_VERSION" == "$(${jq}/bin/jq -r .version "$SRC/package.json")" ]]; then
      echo "[INFO] Already using the latest version of $UPDATE_NIX_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
    ${jq}/bin/jq '. + {
        dependencies: (.dependencies + .devDependencies),
      } | del(.devDependencies, .main, .scripts)' \
      "$SRC/client/package.json" \
      > client/package.json

    # Fix issue with old sqlite3 version pinned that depends on very old node-gyp 3.x
    ${gnused}/bin/sed -i -e 's/"sqlite3":\s*"5.0.[0-9]\+"/"sqlite3": "5.0.11"/' package.json

    # Regenerate node packages to update the pre-overridden 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
    ${yq}/bin/yq -j '{ urlscheme , stream }' \
      "$SRC/config/config.yml.template" \
      > streaming.json

    # Fix generated output for EditorConfig compliance
    printf '\n' >> streaming.json  # rule: insert_final_newline
    popd
  '';
in
_experimental-update-script-combinators.sequence [
  updateSource
  [updateLocks ./.]
]