nixpkgs-bootstrap: make the updater atomic, thereby allowing update of nixpkgs-bootstrap.master in parallel with anything else

This commit is contained in:
2025-05-13 04:30:55 +00:00
parent 22cf60914b
commit f8fb4b9ef4
4 changed files with 55 additions and 8 deletions

View File

@@ -40,13 +40,14 @@
applyPatches ? null,
fetchpatch2 ? null,
fetchzip ? null,
nixpkgs-bootstrap-updater ? null,
stdenv ? null,
unstableGitUpdater ? null,
#VVV config
localSystem ? if stdenv != null then stdenv.buildPlatform.system else builtins.currentSystem, #< not available in pure mode
system ? if stdenv != null then stdenv.hostPlatform.system else localSystem,
}:
let
optionalAttrs = cond: attrs: if cond then attrs else {};
# nixpkgs' update-source-version (updateScript) calculates the new hash for a `src` by specifying this hardcoded bogus hash and then attempting to realize it.
sentinelSha256 = "sha256-AzH1rZFqEH8sovZZfJykvsEmCedEZWigQFHWHl6/PdE=";
fetchBootstrap = { url, pname, version, ... }@args: {
@@ -128,14 +129,16 @@ let
in
"${position.file}:${toString position.line}";
# while we could *technically* use `nixpkgs.<...>` updateScript
# that can force maaany rebuilds on staging/staging-next.
# updateScript = nix-update-script {
# extraArgs = [ "--version=branch=${branch}" ];
# };
updateScript = unstableGitUpdater {
# else the update script tries to walk 10000's of commits to find a tag
hardcodeZeroVersion = true;
# updateScript = unstableGitUpdater {
# # else the update script tries to walk 10000's of commits to find a tag
# hardcodeZeroVersion = true;
# inherit branch;
# };
} // optionalAttrs (nixpkgs-bootstrap-updater != null) {
updateScript = nixpkgs-bootstrap-updater.makeUpdateScript {
inherit branch;
};
};
@@ -146,11 +149,11 @@ let
allowUnfree = true; # NIXPKGS_ALLOW_UNFREE=1
allowBroken = true; # NIXPKGS_ALLOW_BROKEN=1
};
} // (if (system != localSystem) then {
} // optionalAttrs (system != localSystem) {
# XXX(2023/12/11): cache.nixos.org uses `system = ...` instead of `hostPlatform.system`, and that choice impacts the closure of every package.
# so avoid specifying hostPlatform.system on non-cross builds, so i can use upstream caches.
crossSystem = system;
} else {});
};
nixpkgs = import patchedSrc nixpkgsArgs;
in
patchedSrc

View File

@@ -0,0 +1,15 @@
{
lib,
static-nix-shell,
}:
let
self = static-nix-shell.mkBash {
pname = "nixpkgs-bootstrap-updater";
srcRoot = ./.;
pkgs = [ "common-updater-scripts" "curl" "jq" "nix-prefetch-github" ];
passthru.makeUpdateScript = { branch }: [
(lib.getExe self)
branch
];
};
in self

View File

@@ -0,0 +1,28 @@
#!/usr/bin/env nix-shell
#!nix-shell -i bash -p bash -p common-updater-scripts -p curl -p jq -p nix-prefetch-github
set -eu
branch=$1
if [ -z "$branch" ]; then
echo "USAGE: nixpkgsUpdater <branch>"
exit 1
fi
jsonGetField() {
local json=$1
local field=$2
echo "$json" | jq --exit-status --raw-output ".$field"
}
set -x
prefetchData=$(nix-prefetch-github --json --meta --rev "$branch" NixOS nixpkgs)
rev=$(jsonGetField "$prefetchData" src.rev)
nixHash=$(jsonGetField "$prefetchData" src.hash)
commitDate=$(jsonGetField "$prefetchData" meta.commitDate)
update-source-version "sane.nixpkgs-bootstrap.$branch" "unstable-$commitDate" "$nixHash" \
--rev="$rev" \
--print-changes

View File

@@ -7,6 +7,7 @@
lib.recurseIntoAttrs (lib.makeScope newScope (self: with self; {
mkNixpkgs = callPackage ./mkNixpkgs.nix { };
master = callPackage ./master.nix { };
nixpkgs-bootstrap-updater = callPackage ./nixpkgs-bootstrap-updater { };
staging = callPackage ./staging.nix { };
staging-next = callPackage ./staging-next.nix { };
}))