Loading pkgs/by-name/le/lemminx/package.nix +41 −19 Original line number Diff line number Diff line Loading @@ -5,8 +5,12 @@ jdk_headless, jre_minimal, maven, writeScript, lemminx, writeShellApplication, curl, pcre, common-updater-scripts, jq, gnused, }: let Loading Loading @@ -79,26 +83,44 @@ maven.buildMavenPackage rec { nativeBuildInputs = [ makeWrapper ]; passthru.updateScript = writeScript "update-lemminx" '' #!/usr/bin/env nix-shell #!nix-shell -i bash -p curl pcre common-updater-scripts jq gnused set -eu -o pipefail passthru = { updateScript = let pkgFile = builtins.toString ./package.nix; in lib.getExe (writeShellApplication { name = "update-${pname}"; runtimeInputs = [ curl pcre common-updater-scripts jq gnused ]; text = '' if [ -z "''${GITHUB_TOKEN:-}" ]; then echo "no GITHUB_TOKEN provided - you could meet API request limiting" >&2 fi LATEST_TAG=$(curl https://api.github.com/repos/eclipse/lemminx/tags | \ LATEST_TAG=$(curl -H "Accept: application/vnd.github+json" \ ''${GITHUB_TOKEN:+-H "Authorization: bearer $GITHUB_TOKEN"} \ -Lsf https://api.github.com/repos/${src.owner}/${src.repo}/tags | \ jq -r '[.[] | select(.name | test("^[0-9]"))] | sort_by(.name | split(".") | map(tonumber)) | reverse | .[0].name') update-source-version lemminx "$LATEST_TAG" sed -i '0,/mvnHash *= *"[^"]*"/{s/mvnHash = "[^"]*"/mvnHash = ""/}' ${lemminx} update-source-version ${pname} "$LATEST_TAG" sed -i '0,/mvnHash *= *"[^"]*"/{s/mvnHash = "[^"]*"/mvnHash = ""/}' ${pkgFile} echo -e "\nFetching all mvn dependencies to calculate the mvnHash. This may take a while ..." nix-build -A lemminx.fetchedMavenDeps 2> lemminx-stderr.log || true nix-build -A ${pname}.fetchedMavenDeps 2> ${pname}-stderr.log || true NEW_MVN_HASH=$(cat lemminx-stderr.log | grep "got:" | awk '{print ''$2}') rm lemminx-stderr.log NEW_MVN_HASH=$(grep "got:" ${pname}-stderr.log | awk '{print ''$2}') rm ${pname}-stderr.log # escaping double quotes looks ugly but is needed for variable substitution # use # instead of / as separator because the sha256 might contain the / character sed -i "0,/mvnHash *= *\"[^\"]*\"/{s#mvnHash = \"[^\"]*\"#mvnHash = \"$NEW_MVN_HASH\"#}" ${lemminx} sed -i "0,/mvnHash *= *\"[^\"]*\"/{s#mvnHash = \"[^\"]*\"#mvnHash = \"$NEW_MVN_HASH\"#}" ${pkgFile} ''; }); }; meta = with lib; { description = "XML Language Server"; Loading Loading
pkgs/by-name/le/lemminx/package.nix +41 −19 Original line number Diff line number Diff line Loading @@ -5,8 +5,12 @@ jdk_headless, jre_minimal, maven, writeScript, lemminx, writeShellApplication, curl, pcre, common-updater-scripts, jq, gnused, }: let Loading Loading @@ -79,26 +83,44 @@ maven.buildMavenPackage rec { nativeBuildInputs = [ makeWrapper ]; passthru.updateScript = writeScript "update-lemminx" '' #!/usr/bin/env nix-shell #!nix-shell -i bash -p curl pcre common-updater-scripts jq gnused set -eu -o pipefail passthru = { updateScript = let pkgFile = builtins.toString ./package.nix; in lib.getExe (writeShellApplication { name = "update-${pname}"; runtimeInputs = [ curl pcre common-updater-scripts jq gnused ]; text = '' if [ -z "''${GITHUB_TOKEN:-}" ]; then echo "no GITHUB_TOKEN provided - you could meet API request limiting" >&2 fi LATEST_TAG=$(curl https://api.github.com/repos/eclipse/lemminx/tags | \ LATEST_TAG=$(curl -H "Accept: application/vnd.github+json" \ ''${GITHUB_TOKEN:+-H "Authorization: bearer $GITHUB_TOKEN"} \ -Lsf https://api.github.com/repos/${src.owner}/${src.repo}/tags | \ jq -r '[.[] | select(.name | test("^[0-9]"))] | sort_by(.name | split(".") | map(tonumber)) | reverse | .[0].name') update-source-version lemminx "$LATEST_TAG" sed -i '0,/mvnHash *= *"[^"]*"/{s/mvnHash = "[^"]*"/mvnHash = ""/}' ${lemminx} update-source-version ${pname} "$LATEST_TAG" sed -i '0,/mvnHash *= *"[^"]*"/{s/mvnHash = "[^"]*"/mvnHash = ""/}' ${pkgFile} echo -e "\nFetching all mvn dependencies to calculate the mvnHash. This may take a while ..." nix-build -A lemminx.fetchedMavenDeps 2> lemminx-stderr.log || true nix-build -A ${pname}.fetchedMavenDeps 2> ${pname}-stderr.log || true NEW_MVN_HASH=$(cat lemminx-stderr.log | grep "got:" | awk '{print ''$2}') rm lemminx-stderr.log NEW_MVN_HASH=$(grep "got:" ${pname}-stderr.log | awk '{print ''$2}') rm ${pname}-stderr.log # escaping double quotes looks ugly but is needed for variable substitution # use # instead of / as separator because the sha256 might contain the / character sed -i "0,/mvnHash *= *\"[^\"]*\"/{s#mvnHash = \"[^\"]*\"#mvnHash = \"$NEW_MVN_HASH\"#}" ${lemminx} sed -i "0,/mvnHash *= *\"[^\"]*\"/{s#mvnHash = \"[^\"]*\"#mvnHash = \"$NEW_MVN_HASH\"#}" ${pkgFile} ''; }); }; meta = with lib; { description = "XML Language Server"; Loading