sublime4.updateScript: Pass versionFile path through arguments

That way, `maintainers/scripts/update.nix` will be able to turn
the path to relative and be able to update it even with `--argstr commit true`.
This commit is contained in:
Jan Tojnar 2022-08-16 12:13:06 +02:00
parent 98584efa4b
commit 75dc7411ab

View file

@ -122,24 +122,28 @@ in stdenv.mkDerivation (rec {
'';
passthru = {
updateScript = writeShellScript "${packageAttribute}-update-script" ''
set -o errexit
PATH=${lib.makeBinPath [ common-updater-scripts curl ]}
updateScript =
let
script = writeShellScript "${packageAttribute}-update-script" ''
set -o errexit
PATH=${lib.makeBinPath [ common-updater-scripts curl ]}
latestVersion=$(curl -s "${versionUrl}")
versionFile=$1
latestVersion=$(curl -s "${versionUrl}")
if [[ "${buildVersion}" = "$latestVersion" ]]; then
echo "The new version same as the old version."
exit 0
fi
if [[ "${buildVersion}" = "$latestVersion" ]]; then
echo "The new version same as the old version."
exit 0
fi
for platform in ${lib.escapeShellArgs meta.platforms}; do
# The script will not perform an update when the version attribute is up to date from previous platform run
# We need to clear it before each run
update-source-version "${packageAttribute}.${primaryBinary}" 0 "${lib.fakeSha256}" --file=${versionFile} --version-key=buildVersion --source-key="sources.$platform"
update-source-version "${packageAttribute}.${primaryBinary}" "$latestVersion" --file=${versionFile} --version-key=buildVersion --source-key="sources.$platform"
done
'';
for platform in ${lib.escapeShellArgs meta.platforms}; do
# The script will not perform an update when the version attribute is up to date from previous platform run
# We need to clear it before each run
update-source-version "${packageAttribute}.${primaryBinary}" 0 "${lib.fakeSha256}" --file="$versionFile" --version-key=buildVersion --source-key="sources.$platform"
update-source-version "${packageAttribute}.${primaryBinary}" "$latestVersion" --file="$versionFile" --version-key=buildVersion --source-key="sources.$platform"
done
'';
in [ script versionFile ];
};
meta = with lib; {