forked from NixOS/nix.dev
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add script to update Nix release branches
- Loading branch information
1 parent
926f8fa
commit 44c789f
Showing
2 changed files
with
43 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
{ writeShellApplication | ||
, git | ||
, gnused | ||
, niv | ||
, nix | ||
, ripgrep | ||
, coreutils | ||
}: | ||
# add or update Nix releases using `niv` in the current directory. | ||
# this will clone the entire Git repository of Nix. | ||
writeShellApplication { | ||
name = "update-nix-releases"; | ||
runtimeInputs = [ git gnused niv nix ripgrep ]; | ||
text = '' | ||
tmp=$(mktemp -d) | ||
trap 'rm -rf "$tmp"' EXIT | ||
git clone https://github.com/nixos/nix "$tmp" | ||
pushd "$tmp" > /dev/null | ||
git branch -r | rg 'origin/\d\.\d*-maintenance' | sed 's|.*origin/\(.*\)|\1|' > releases.txt | ||
while IFS= read -r branch; do | ||
git checkout "$branch" | ||
# very old versions don't have a `default.nix` | ||
if [ ! -f default.nix ]; then continue; fi | ||
doc=$(nix-store --query "$(nix-instantiate -A default 2> /dev/null)" | rg doc) | ||
# only use cached builds, to avoid building Nix locally | ||
if nix-store --query --size "$doc" --store https://cache.nixos.org > /dev/null 2>&1; then | ||
version="''${branch%-maintenance}" | ||
version="''${version//./-}" | ||
popd > /dev/null | ||
if niv show "nix_$version" > /dev/null 2>&1; then | ||
niv drop "nix_$version" | ||
fi | ||
niv add nixos/nix -n "nix_$version" -b "$branch" | ||
pushd "$tmp" > /dev/null | ||
fi | ||
done < releases.txt | ||
''; | ||
} |