From e4c60889eeeca00d5f5f538373bb937106926189 Mon Sep 17 00:00:00 2001 From: Wolfgang Walther Date: Sat, 6 Jan 2024 19:19:18 +0100 Subject: [PATCH] nix: Make postgrest-nixpkgs-upgrade take the latest stable version Previously this command upgraded to the latest unstable version of nixpkgs, but this was often broken. Taking the latest stable branch should give better results. --- nix/tools/nixpkgsTools.nix | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/nix/tools/nixpkgsTools.nix b/nix/tools/nixpkgsTools.nix index c4128e5b9..6f4d04269 100644 --- a/nix/tools/nixpkgsTools.nix +++ b/nix/tools/nixpkgsTools.nix @@ -5,7 +5,7 @@ , jq , nix }: -# Utility script for pinning the latest unstable version of Nixpkgs. +# Utility script for pinning the latest stable version of Nixpkgs. # Instead of pinning Nixpkgs based on the huge Git repository, we reference a # specific tarball that only contains the source of the revision that we want @@ -15,7 +15,7 @@ let "postgrest-nixpkgs-upgrade"; refUrl = - "https://api.github.com/repos/nixos/nixpkgs/git/ref/heads/nixpkgs-unstable"; + "https://api.github.com/repos/nixos/nixpkgs/git/matching-refs/heads/nixpkgs-"; githubV3Header = "Accept: application/vnd.github.v3+json"; @@ -27,11 +27,12 @@ let checkedShellScript { inherit name; - docs = "Pin the newest unstable version of Nixpkgs."; + docs = "Pin the newest stable version of Nixpkgs."; inRootDir = true; } '' - commitHash="$(${curl}/bin/curl "${refUrl}" -H "${githubV3Header}" | ${jq}/bin/jq -r .object.sha)" + # The list of refs is sorted. The first result will be nixpkgs-unstable, the second the latest stable branch. + commitHash="$(${curl}/bin/curl "${refUrl}" -H "${githubV3Header}" | ${jq}/bin/jq -r 'sort_by(.ref) | reverse | .[1].object.sha')" tarballUrl="${tarballUrlBase}$commitHash.tar.gz" tarballHash="$(${nix}/bin/nix-prefetch-url --unpack "$tarballUrl")" currentDate="$(${coreutils}/bin/date --iso)"