Files
nixpkgs/pkgs/by-name/fb/fbthrift/scrub-build-directory-from-output.patch
Dark Steveneq 646b892680
Some checks failed
Periodic Merges (6h) / master → staging-nixos (push) Failing after 12m50s
Periodic Merges (6h) / master → staging-next (push) Failing after 12m54s
Periodic Merges (24h) / merge-base(master,staging) → haskell-updates (push) Failing after 11m54s
Periodic Merges (6h) / staging-next → staging (push) Failing after 12m13s
Periodic Merges (24h) / staging-next-25.05 → staging-25.05 (push) Failing after 13m24s
Periodic Merges (24h) / release-25.05 → staging-next-25.05 (push) Failing after 14m28s
push sheeet
2025-10-09 14:15:47 +02:00

37 lines
1.6 KiB
Diff

diff --git a/thrift/compiler/generate/t_mstch_cpp2_generator.cc b/thrift/compiler/generate/t_mstch_cpp2_generator.cc
index d232df5158..96d15efbda 100644
--- a/thrift/compiler/generate/t_mstch_cpp2_generator.cc
+++ b/thrift/compiler/generate/t_mstch_cpp2_generator.cc
@@ -1116,6 +1116,13 @@
mstch::node autogen_path() {
std::string path = service_->program()->path();
std::replace(path.begin(), path.end(), '\\', '/');
+ // Ensure output reproducibility for Nix builds.
+ if (auto nix_build_top = std::getenv("NIX_BUILD_TOP")) {
+ auto prefix = std::string(nix_build_top) + "/";
+ if (path.starts_with(prefix)) {
+ path.replace(0, prefix.length(), "/build/");
+ }
+ }
return path;
}
mstch::node cpp_includes() {
diff --git a/thrift/compiler/generate/t_whisker_generator.cc b/thrift/compiler/generate/t_whisker_generator.cc
index 99a6ac14af..fa91a05247 100644
--- a/thrift/compiler/generate/t_whisker_generator.cc
+++ b/thrift/compiler/generate/t_whisker_generator.cc
@@ -572,6 +572,13 @@
// use posix path separators, even on windows, for autogen comment
// to avoid spurious fixture regen diffs
std::replace(path.begin(), path.end(), '\\', '/');
+ // Ensure output reproducibility for Nix builds.
+ if (auto nix_build_top = std::getenv("NIX_BUILD_TOP")) {
+ auto prefix = std::string(nix_build_top) + "/";
+ if (path.starts_with(prefix)) {
+ path.replace(0, prefix.length(), "/build/");
+ }
+ }
return path;
});
def.property("namespaces", [&](const t_program& self) -> map::ptr {