[M7] lockfile: pin top-level nixpkgs_rev + flake_utils_rev
This commit is contained in:
@@ -99,20 +99,26 @@ auto pinned_inputs_dedup(const std::vector<DepBinding>& bindings)
|
||||
return out;
|
||||
}
|
||||
|
||||
auto emit_inputs_block(const std::vector<const DepBinding*>& pinned)
|
||||
-> std::string {
|
||||
// Always emit the shared toolchain `nixpkgs` and `flake-utils`
|
||||
// inputs. Per-pinned-dep inputs land between them so the output
|
||||
// diff stays stable across reruns.
|
||||
auto emit_inputs_block(const std::vector<const DepBinding*>& pinned,
|
||||
const lockfile::Lockfile& lock) -> std::string {
|
||||
auto nixpkgs_url =
|
||||
lock.nixpkgs_rev_pin && !lock.nixpkgs_rev_pin->empty()
|
||||
? std::format("github:NixOS/nixpkgs/{}", *lock.nixpkgs_rev_pin)
|
||||
: std::string{"github:NixOS/nixpkgs/nixos-unstable"};
|
||||
auto flake_utils_url =
|
||||
lock.flake_utils_rev_pin && !lock.flake_utils_rev_pin->empty()
|
||||
? std::format("github:numtide/flake-utils/{}",
|
||||
*lock.flake_utils_rev_pin)
|
||||
: std::string{"github:numtide/flake-utils"};
|
||||
std::string out =
|
||||
" inputs = {\n"
|
||||
" nixpkgs.url = \"github:NixOS/nixpkgs/nixos-unstable\";\n";
|
||||
+ std::format(" nixpkgs.url = \"{}\";\n", nixpkgs_url);
|
||||
for (const auto* b : pinned) {
|
||||
out += std::format(" {}.url = \"github:NixOS/nixpkgs/{}\";\n",
|
||||
b->sanitized, *b->rev);
|
||||
}
|
||||
out += " flake-utils.url = \"github:numtide/flake-utils\";\n"
|
||||
" };\n";
|
||||
out += std::format(" flake-utils.url = \"{}\";\n", flake_utils_url);
|
||||
out += " };\n";
|
||||
return out;
|
||||
}
|
||||
|
||||
@@ -165,7 +171,7 @@ auto flake_nix(const GenerateInputs& in) -> std::string {
|
||||
out += "{\n";
|
||||
out += std::format(" description = \"{}\";\n\n", in.manifest.package.name);
|
||||
|
||||
out += emit_inputs_block(pinned);
|
||||
out += emit_inputs_block(pinned, in.lock);
|
||||
|
||||
const bool any_pkg_config =
|
||||
std::ranges::any_of(in.recipes,
|
||||
|
||||
Reference in New Issue
Block a user