mirror of
https://github.com/NixOS/nix.dev.git
synced 2024-10-18 00:06:26 -04:00
deep clone, optimise checkouts
This commit is contained in:
parent
a7fb1513b5
commit
0a70dbf90c
10
default.nix
10
default.nix
|
@ -10,6 +10,12 @@ let
|
|||
};
|
||||
lib = pkgs.lib;
|
||||
|
||||
nix-releases = with lib.attrsets;
|
||||
mapAttrs (_: input: (import input).default)
|
||||
(filterAttrs
|
||||
(name: _: lib.strings.match "^nix_([0-9]+)-([0-9]+)$" name != null)
|
||||
inputs);
|
||||
|
||||
nix-dev =
|
||||
let
|
||||
# Various versions of the Nix manuals, grep for (nix-manual)= to find where they are displayed.
|
||||
|
@ -18,10 +24,11 @@ let
|
|||
nixpkgs-rolling = import inputs.nixpkgs-rolling { } // { inherit (nixpkgs-rolling.lib) version; };
|
||||
nixpkgs-stable = import inputs.nixpkgs-stable { } // { inherit (nixpkgs-stable.lib) version; };
|
||||
nixpkgs-prev-stable = import inputs.nixpkgs-prev-stable { } // { inherit (nixpkgs-prev-stable.lib) version; };
|
||||
nix-latest = (import inputs.nix-latest).default;
|
||||
#nix-latest = with lib; nix-releases.${last (lists.naturalSort (attrNames nix-releases))};
|
||||
# TODO: to further simplify this and get Nix from Nixpkgs with all required files present,
|
||||
# make a patch release of Nix after https://github.com/NixOS/nix/pull/9949 lands,
|
||||
# and bump the respective version in the respective Nixpkgs `release-*` branch.
|
||||
nix-latest = (import inputs.nix-rolling).default;
|
||||
nix-rolling = (import inputs.nix-rolling).default;
|
||||
nix-stable = (import inputs.nix-stable).default;
|
||||
nix-prev-stable = (import inputs.nix-prev-stable).default;
|
||||
|
@ -146,6 +153,7 @@ in
|
|||
# build with `nix-build -A build`
|
||||
build = nix-dev;
|
||||
|
||||
inherit lib nix-releases inputs;
|
||||
shell = pkgs.mkShell {
|
||||
inputsFrom = [ nix-dev ];
|
||||
packages = [
|
||||
|
|
120
nix/sources.json
120
nix/sources.json
|
@ -1,4 +1,16 @@
|
|||
{
|
||||
"nix-latest": {
|
||||
"branch": "2.19-maintenance",
|
||||
"description": "Nix, the purely functional package manager",
|
||||
"homepage": "https://nixos.org/",
|
||||
"owner": "nixos",
|
||||
"repo": "nix",
|
||||
"rev": "dc09e6193bffcab37d3d43107eae9464395ab51d",
|
||||
"sha256": "0n117h0jz3aih41mg0kns8v6rjhmrg7r6p8azl55p32zrj02zyvm",
|
||||
"type": "tarball",
|
||||
"url": "https://github.com/nixos/nix/archive/dc09e6193bffcab37d3d43107eae9464395ab51d.tar.gz",
|
||||
"url_template": "https://github.com/<owner>/<repo>/archive/<rev>.tar.gz"
|
||||
},
|
||||
"nix-prev-stable": {
|
||||
"branch": "2.13-maintenance",
|
||||
"description": "Nix, the purely functional package manager",
|
||||
|
@ -23,18 +35,6 @@
|
|||
"url": "https://github.com/nixos/nix/archive/60eb80593f3a18aebc7672ad7007cb23c14db061.tar.gz",
|
||||
"url_template": "https://github.com/<owner>/<repo>/archive/<rev>.tar.gz"
|
||||
},
|
||||
"nix-latest": {
|
||||
"branch": "2.19-maintenance",
|
||||
"description": "Nix, the purely functional package manager",
|
||||
"homepage": "https://nixos.org/",
|
||||
"owner": "nixos",
|
||||
"repo": "nix",
|
||||
"rev": "dc09e6193bffcab37d3d43107eae9464395ab51d",
|
||||
"sha256": "0n117h0jz3aih41mg0kns8v6rjhmrg7r6p8azl55p32zrj02zyvm",
|
||||
"type": "tarball",
|
||||
"url": "https://github.com/nixos/nix/archive/dc09e6193bffcab37d3d43107eae9464395ab51d.tar.gz",
|
||||
"url_template": "https://github.com/<owner>/<repo>/archive/<rev>.tar.gz"
|
||||
},
|
||||
"nix-stable": {
|
||||
"branch": "2.18-maintenance",
|
||||
"description": "Nix, the purely functional package manager",
|
||||
|
@ -47,6 +47,102 @@
|
|||
"url": "https://github.com/nixos/nix/archive/60eb80593f3a18aebc7672ad7007cb23c14db061.tar.gz",
|
||||
"url_template": "https://github.com/<owner>/<repo>/archive/<rev>.tar.gz"
|
||||
},
|
||||
"nix_2-14": {
|
||||
"branch": "2.14-maintenance",
|
||||
"description": "Nix, the purely functional package manager",
|
||||
"homepage": "https://nixos.org/",
|
||||
"owner": "nixos",
|
||||
"repo": "nix",
|
||||
"rev": "9e19aca31bc9237d699b86bce1d31aa099f09121",
|
||||
"sha256": "1wnaah9bpycl89bjv85b967vxvgrppfl1a8f1h7vvavhb2fcgxkb",
|
||||
"type": "tarball",
|
||||
"url": "https://github.com/nixos/nix/archive/9e19aca31bc9237d699b86bce1d31aa099f09121.tar.gz",
|
||||
"url_template": "https://github.com/<owner>/<repo>/archive/<rev>.tar.gz"
|
||||
},
|
||||
"nix_2-15": {
|
||||
"branch": "2.15-maintenance",
|
||||
"description": "Nix, the purely functional package manager",
|
||||
"homepage": "https://nixos.org/",
|
||||
"owner": "nixos",
|
||||
"repo": "nix",
|
||||
"rev": "3d21bb8464fa5fe7f61a02336924ce448f66f78e",
|
||||
"sha256": "11v15mgpi8sn124jzpii4cd54ylr0x9znhcdq4gwrvmrx8732j8h",
|
||||
"type": "tarball",
|
||||
"url": "https://github.com/nixos/nix/archive/3d21bb8464fa5fe7f61a02336924ce448f66f78e.tar.gz",
|
||||
"url_template": "https://github.com/<owner>/<repo>/archive/<rev>.tar.gz"
|
||||
},
|
||||
"nix_2-16": {
|
||||
"branch": "2.16-maintenance",
|
||||
"description": "Nix, the purely functional package manager",
|
||||
"homepage": "https://nixos.org/",
|
||||
"owner": "nixos",
|
||||
"repo": "nix",
|
||||
"rev": "d9c204fafcbb5a05aef5c36fc83f4c3d6cc4749d",
|
||||
"sha256": "0m3x4qgp2m61d1dd5mfqwxw5r0dgy7pzdc7zg0z9x9l7slghx3ma",
|
||||
"type": "tarball",
|
||||
"url": "https://github.com/nixos/nix/archive/d9c204fafcbb5a05aef5c36fc83f4c3d6cc4749d.tar.gz",
|
||||
"url_template": "https://github.com/<owner>/<repo>/archive/<rev>.tar.gz"
|
||||
},
|
||||
"nix_2-17": {
|
||||
"branch": "2.17-maintenance",
|
||||
"description": "Nix, the purely functional package manager",
|
||||
"homepage": "https://nixos.org/",
|
||||
"owner": "nixos",
|
||||
"repo": "nix",
|
||||
"rev": "27c8b92f31fc4fb1d5be28d5196dc5ac0da58aee",
|
||||
"sha256": "1v1nw39j67y34hjnh9126975j1l1ha4ysfr70mnvpvsl3zb6mjvv",
|
||||
"type": "tarball",
|
||||
"url": "https://github.com/nixos/nix/archive/27c8b92f31fc4fb1d5be28d5196dc5ac0da58aee.tar.gz",
|
||||
"url_template": "https://github.com/<owner>/<repo>/archive/<rev>.tar.gz"
|
||||
},
|
||||
"nix_2-18": {
|
||||
"branch": "2.18-maintenance",
|
||||
"description": "Nix, the purely functional package manager",
|
||||
"homepage": "https://nixos.org/",
|
||||
"owner": "nixos",
|
||||
"repo": "nix",
|
||||
"rev": "d13707727182d3e3d62d71be45a0aa1321ba2a91",
|
||||
"sha256": "1lq14chg9my4q5vjzkzfwkjs4l4c8s7vr5ahfbzrfg5f00sqwcx3",
|
||||
"type": "tarball",
|
||||
"url": "https://github.com/nixos/nix/archive/d13707727182d3e3d62d71be45a0aa1321ba2a91.tar.gz",
|
||||
"url_template": "https://github.com/<owner>/<repo>/archive/<rev>.tar.gz"
|
||||
},
|
||||
"nix_2-19": {
|
||||
"branch": "2.19-maintenance",
|
||||
"description": "Nix, the purely functional package manager",
|
||||
"homepage": "https://nixos.org/",
|
||||
"owner": "nixos",
|
||||
"repo": "nix",
|
||||
"rev": "dd0ba589f4f346a3aaaeb9c0322f7d0e7e4ab3d1",
|
||||
"sha256": "16i44x4jb6s7516jb6p9w49f94va3hh34hs1n3i1sknib4px29w4",
|
||||
"type": "tarball",
|
||||
"url": "https://github.com/nixos/nix/archive/dd0ba589f4f346a3aaaeb9c0322f7d0e7e4ab3d1.tar.gz",
|
||||
"url_template": "https://github.com/<owner>/<repo>/archive/<rev>.tar.gz"
|
||||
},
|
||||
"nix_2-20": {
|
||||
"branch": "2.20-maintenance",
|
||||
"description": "Nix, the purely functional package manager",
|
||||
"homepage": "https://nixos.org/",
|
||||
"owner": "nixos",
|
||||
"repo": "nix",
|
||||
"rev": "ac9bedda2c00c855c63b496bb891689c8d9c0ad5",
|
||||
"sha256": "03xxqclc5j2300qzg5cxhxxbmn1r9navql9wiq69py1b9p2f3q0m",
|
||||
"type": "tarball",
|
||||
"url": "https://github.com/nixos/nix/archive/ac9bedda2c00c855c63b496bb891689c8d9c0ad5.tar.gz",
|
||||
"url_template": "https://github.com/<owner>/<repo>/archive/<rev>.tar.gz"
|
||||
},
|
||||
"nix_2-21": {
|
||||
"branch": "2.21-maintenance",
|
||||
"description": "Nix, the purely functional package manager",
|
||||
"homepage": "https://nixos.org/",
|
||||
"owner": "nixos",
|
||||
"repo": "nix",
|
||||
"rev": "057ffc2e8e94abb4036866aa4819381f445dbdfb",
|
||||
"sha256": "0l91g9bmfd68j1rz6m252w5ngv1gsg1wfys4nlifaimcvqpllvxn",
|
||||
"type": "tarball",
|
||||
"url": "https://github.com/nixos/nix/archive/057ffc2e8e94abb4036866aa4819381f445dbdfb.tar.gz",
|
||||
"url_template": "https://github.com/<owner>/<repo>/archive/<rev>.tar.gz"
|
||||
},
|
||||
"nixpkgs-prev-stable": {
|
||||
"branch": "nixos-23.05",
|
||||
"description": "Nix Packages collection & NixOS",
|
||||
|
|
|
@ -12,37 +12,55 @@ writeShellApplication {
|
|||
name = "update-nix-releases";
|
||||
runtimeInputs = [ git gnused niv nix ripgrep ];
|
||||
text = ''
|
||||
tmp=$(mktemp -d)
|
||||
nix=$(mktemp -d)
|
||||
trap 'rm -rf $"tmp" "$nix"' EXIT
|
||||
|
||||
# get release branches
|
||||
git ls-remote https://github.com/nixos/nix "refs/heads/*" \
|
||||
| rg '/\d(.*)-maintenance' | awk '{sub(/\s*refs\/heads\//, "", $2); print $2, $1}' \
|
||||
| sort --reverse --version-sort > releases
|
||||
| sort --reverse --version-sort > "$tmp"/releases
|
||||
|
||||
niv show | awk '/branch:/ {branch = $2} /rev:/ {print branch, $2}' > pinned
|
||||
niv show | awk '!/^[[:space:]]/ {pin = $1} /branch:/ {branch = $2} /rev:/ {print branch, $2, pin}' > "$tmp"/pinned
|
||||
|
||||
tmp=$(mktemp -d)
|
||||
trap 'rm -rf "$tmp"' EXIT
|
||||
git clone https://github.com/nixos/nix "$tmp" --depth 1 --quiet
|
||||
# we *must* download the entire history.
|
||||
# prior to 2.17 the source files for the build were obtained with `cleanSourceWith`.
|
||||
# it is based on `builtins.filterSource` that incorporates the `.git` directory:
|
||||
# https://github.com/NixOS/nix/commit/b13fc7101fb06a65935d145081319145f7fef6f9
|
||||
# this means that all Hydra builds prior to 2.18 are based on deep clones.
|
||||
# evaluating a shallow clone will produce different derivation hashes.
|
||||
git clone https://github.com/nixos/nix "$nix" --quiet
|
||||
|
||||
# only update releases where pins don't match the latest revision
|
||||
rg --invert-match --file pinned releases | cut -d' ' -f1 | while read -r branch; do
|
||||
version="''${branch%-maintenance}"
|
||||
version="''${version//./-}"
|
||||
rg --invert-match --file <(awk '{print $1, $2}' "$tmp"/pinned) "$tmp"/releases | cut -d' ' -f1 | while read -r branch; do
|
||||
pushd "$nix" > /dev/null
|
||||
git checkout -b "$branch" origin/"$branch" --quiet
|
||||
|
||||
pushd "$tmp" > /dev/null
|
||||
git fetch origin "$branch" --depth 1 --quiet
|
||||
git checkout -b "$branch" FETCH_HEAD
|
||||
# only use versions recent enough to have the same structure
|
||||
if ! default=$(nix-instantiate -A default 2> /dev/null); then
|
||||
continue
|
||||
fi
|
||||
if ! doc=$(nix-store --query "$default" | rg doc); then
|
||||
continue
|
||||
fi
|
||||
|
||||
# only use cached builds, to avoid building Nix locally
|
||||
if default=$(nix-instantiate -A default 2> /dev/null) \
|
||||
&& doc=$(nix-store --query "$default" | rg doc) \
|
||||
&& nix-store --query --size "$doc" --store https://cache.nixos.org > /dev/null 2>&1
|
||||
then
|
||||
popd > /dev/null
|
||||
niv drop "nix_$version"
|
||||
niv add nixos/nix -n "nix_$version" -b "$branch"
|
||||
else
|
||||
popd > /dev/null
|
||||
while true; do
|
||||
if nix-store --query --size "$doc" --store https://cache.nixos.org > /dev/null 2>&1; then
|
||||
break
|
||||
fi
|
||||
git checkout HEAD~ --quiet
|
||||
done
|
||||
|
||||
popd > /dev/null
|
||||
version="''${branch%-maintenance}"
|
||||
version="''${version//./-}"
|
||||
pin=nix_"$version"
|
||||
|
||||
if rg -q "$pin" "$tmp"/pinned; then
|
||||
niv drop "$pin"
|
||||
fi
|
||||
niv add nixos/nix -n "$pin" -b "$branch"
|
||||
done
|
||||
'';
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue