Files
nixpkgs/pkgs/by-name/ba/bazel_8/build-support/bazelDerivation.nix
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

75 lines
1.8 KiB
Nix

{
stdenv,
lndir,
lib,
}:
args@{
bazel,
registry ? null,
bazelRepoCache ? null,
bazelVendorDeps ? null,
startupArgs ? [ ],
commandArgs ? [ ],
bazelPreBuild ? "",
bazelPostBuild ? "",
serverJavabase ? null,
targets,
command,
...
}:
stdenv.mkDerivation (
{
preBuildPhases = [ "preBuildPhase" ];
preBuildPhase =
(lib.optionalString (bazelRepoCache != null) ''
# repo_cache needs to be writeable even in air-gapped builds
mkdir repo_cache
${lndir}/bin/lndir -silent ${bazelRepoCache}/repo_cache repo_cache
'')
+ (lib.optionalString (bazelVendorDeps != null) ''
mkdir vendor_dir
${lndir}/bin/lndir -silent ${bazelVendorDeps}/vendor_dir vendor_dir
# pin all deps to avoid re-fetch attempts by Bazel
rm vendor_dir/VENDOR.bazel
find vendor_dir -mindepth 1 -maxdepth 1 -type d -printf "pin(\"@@%P\")\n" > vendor_dir/VENDOR.bazel
'')
# keep preBuildPhase always defined as it is listed in preBuildPhases
+ ''
true
'';
buildPhase = ''
runHook preBuild
export HOME=$(mktemp -d)
${bazelPreBuild}
${bazel}/bin/bazel ${
lib.escapeShellArgs (
lib.optional (serverJavabase != null) "--server_javabase=${serverJavabase}"
++ [ "--batch" ]
++ startupArgs
)
} ${command} ${
lib.escapeShellArgs (
lib.optional (registry != null) "--registry=file://${registry}"
++ lib.optional (bazelRepoCache != null) "--repository_cache=repo_cache"
++ lib.optional (bazelVendorDeps != null) "--vendor_dir=vendor_dir"
++ commandArgs
++ targets
)
}
${bazelPostBuild}
runHook postBuild
'';
}
// args
)