Skip to content

Commit

Permalink
nix: Make postgrest-nixpkgs-upgrade take the latest stable version
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
wolfgangwalther committed Jan 18, 2024
1 parent c070cb9 commit e4c6088
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions nix/tools/nixpkgsTools.nix
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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";
Expand All @@ -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)"
Expand Down

0 comments on commit e4c6088

Please sign in to comment.