Merge pull request #194648 from jtojnar/epgstation-updatescript

epgstation.updateScript: Fix eval and clean up
This commit is contained in:
Jan Tojnar 2022-10-06 21:18:23 +02:00 committed by GitHub
commit c72f22fd77
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 50 additions and 67 deletions

View file

@ -1,14 +1,11 @@
{ lib
, stdenv
, fetchFromGitHub
, gitUpdater
, writers
, makeWrapper
, bash
, nodejs
, gzip
, jq
, yq
, callPackage
}:
let
@ -33,7 +30,8 @@ let
});
server = nodejs.pkgs.epgstation.override (drv: {
inherit src;
# NOTE: updateScript relies on version matching the src.
inherit version src;
# This is set to false to keep devDependencies at build time. Build time
# dependencies are pruned afterwards.
@ -108,17 +106,7 @@ let
# NOTE: this may take a while since it has to update all packages in
# nixpkgs.nodePackages
passthru.updateScript = import ./update.nix {
inherit lib;
inherit (src.meta) homepage;
inherit
pname
version
gitUpdater
writers
jq
yq;
};
passthru.updateScript = callPackage ./update.nix { };
# nodePackages.epgstation is a stub package to fetch npm dependencies and
# its meta.platforms is made empty to prevent users from installing it

View file

@ -1,36 +1,26 @@
{ pname
, version
, homepage
, lib
, gitUpdater
{ gitUpdater
, writers
, jq
, yq
, gnused
, _experimental-update-script-combinators
}:
let
updater = gitUpdater {
inherit pname version;
attrPath = lib.toLower pname;
updateSource = gitUpdater {
rev-prefix = "v";
};
updateScript = builtins.elemAt updater.command 0;
updateArgs = map (lib.escapeShellArg) (builtins.tail updater.command);
in writers.writeBash "update-epgstation" ''
updateLocks = writers.writeBash "update-epgstation" ''
set -euxo pipefail
# bump the version
${updateScript} ${lib.concatStringsSep " " updateArgs}
cd "${toString ./.}"
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 [[ "${version}" == "$(${jq}/bin/jq -r .version "$SRC/package.json")" ]]; then
echo "[INFO] Already using the latest version of ${pname}" >&2
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
@ -64,4 +54,9 @@ in writers.writeBash "update-epgstation" ''
# Fix generated output for EditorConfig compliance
printf '\n' >> streaming.json # rule: insert_final_newline
popd
''
'';
in
_experimental-update-script-combinators.sequence [
updateSource
[updateLocks ./.]
]