nix: expose nixpkgs input on flake
This also moves the pin for nixpkgs into flake.lock instead of our custom file. Even for the classic interface via default.nix, the pin will be loaded from flake.lock, thus everything stays in-sync.
This commit is contained in:
+2
-4
@@ -379,10 +379,8 @@ that).
|
||||
|
||||
We also use `default.nix` to load our pinned version of the `nixpkgs`
|
||||
repository. This set of packages will always be the same, independently from
|
||||
where or when you use it. The pinned version can be upgraded with the small
|
||||
`nixpkgs-upgrade` utility. Running `nixpkgs-upgrade > nix/nixpkgs-version.nix`
|
||||
in `nix-shell` will upgrade the pinned version to the latest `nixpkgs-unstable`
|
||||
version.
|
||||
where or when you use it. The pinned version is taken from `flake.lock` and
|
||||
can be updated with `nix flake update`.
|
||||
|
||||
### `shell.nix`
|
||||
|
||||
|
||||
@@ -1,9 +0,0 @@
|
||||
# Pinned version of Nixpkgs, generated with postgrest-nixpkgs-upgrade.
|
||||
{
|
||||
owner = "NixOS";
|
||||
repo = "nixpkgs";
|
||||
ref = "refs/heads/nixpkgs-unstable-darwin";
|
||||
date = "2024-11-09";
|
||||
rev = "a90280100f41a10914edfe729a4053e60c92b8e3";
|
||||
tarballHash = "1vwr665b6l6gma24w45q5hic86vbd8alc01mziwwr621hwlca88f";
|
||||
}
|
||||
@@ -1,62 +0,0 @@
|
||||
{ buildToolbox
|
||||
, checkedShellScript
|
||||
, coreutils
|
||||
, curl
|
||||
, jq
|
||||
, nix
|
||||
}:
|
||||
# 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
|
||||
# to pin.
|
||||
let
|
||||
name =
|
||||
"postgrest-nixpkgs-upgrade";
|
||||
|
||||
refUrl =
|
||||
"https://api.github.com/repos/nixos/nixpkgs/git/matching-refs/heads/nixpkgs-";
|
||||
|
||||
githubV3Header =
|
||||
"Accept: application/vnd.github.v3+json";
|
||||
|
||||
tarballUrlBase =
|
||||
"https://github.com/nixos/nixpkgs/archive/";
|
||||
|
||||
upgrade =
|
||||
checkedShellScript
|
||||
{
|
||||
inherit name;
|
||||
docs = "Pin the newest stable version of Nixpkgs.";
|
||||
workingDir = "/";
|
||||
}
|
||||
''
|
||||
# The list of refs is sorted. The first result will be nixpkgs-unstable, the second the latest stable branch.
|
||||
# shellcheck disable=SC2207
|
||||
commit=($(${curl}/bin/curl "${refUrl}" -H "${githubV3Header}" | ${jq}/bin/jq -r 'sort_by(.ref) | reverse | [.[0].object.sha, .[0].ref] | @tsv'))
|
||||
tarballUrl="${tarballUrlBase}''${commit[0]}.tar.gz"
|
||||
tarballHash="$(${nix}/bin/nix-prefetch-url --unpack "$tarballUrl")"
|
||||
currentDate="$(${coreutils}/bin/date --iso)"
|
||||
|
||||
cat > nix/nixpkgs-version.nix << EOF
|
||||
# Pinned version of Nixpkgs, generated with ${name}.
|
||||
{
|
||||
owner = "NixOS";
|
||||
repo = "nixpkgs";
|
||||
ref = "''${commit[1]}";
|
||||
date = "$currentDate";
|
||||
rev = "''${commit[0]}";
|
||||
tarballHash = "$tarballHash";
|
||||
}
|
||||
EOF
|
||||
|
||||
echo "# This file is auto-generated by ${name}" > docs/requirements.txt
|
||||
cat "$(nix-build -A docs.requirements)" >> docs/requirements.txt
|
||||
'';
|
||||
|
||||
in
|
||||
buildToolbox
|
||||
{
|
||||
name = "postgrest-nixpkgs";
|
||||
tools = { inherit upgrade; };
|
||||
}
|
||||
Reference in New Issue
Block a user