buildBazelPackage: fix difference between linux and darwin deps

This commit is contained in:
Uri Baghin 2023-04-06 10:23:32 +10:00
parent 948a5e1728
commit f8ee061247
4 changed files with 30 additions and 3 deletions

View File

@ -1,6 +1,7 @@
{ stdenv { stdenv
, cacert , cacert
, lib , lib
, writeCBin
}: }:
args@{ args@{
@ -75,6 +76,28 @@ let
${lib.strings.concatStringsSep " " additionalFlags} \ ${lib.strings.concatStringsSep " " additionalFlags} \
${lib.strings.concatStringsSep " " targets} ${lib.strings.concatStringsSep " " targets}
''; '';
# we need this to chmod dangling symlinks on darwin, gnu coreutils refuses to do so:
# chmod: cannot operate on dangling symlink '$symlink'
chmodder = writeCBin "chmodder" ''
#include <stdio.h>
#include <stdlib.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <errno.h>
#include <string.h>
int main(int argc, char** argv) {
mode_t mode = S_IRWXU | S_IRWXG | S_IRWXO;
if (argc != 2) {
fprintf(stderr, "usage: chmodder file");
exit(EXIT_FAILURE);
}
if (lchmod(argv[1], mode) != 0) {
fprintf(stderr, "failed to lchmod '%s': %s", argv[0], strerror(errno));
exit(EXIT_FAILURE);
}
}
'';
in in
stdenv.mkDerivation (fBuildAttrs // { stdenv.mkDerivation (fBuildAttrs // {
@ -149,6 +172,10 @@ stdenv.mkDerivation (fBuildAttrs // {
new_target="$(readlink "$symlink" | sed "s,$NIX_BUILD_TOP,NIX_BUILD_TOP,")" new_target="$(readlink "$symlink" | sed "s,$NIX_BUILD_TOP,NIX_BUILD_TOP,")"
rm "$symlink" rm "$symlink"
ln -sf "$new_target" "$symlink" ln -sf "$new_target" "$symlink"
'' + lib.optionalString stdenv.isDarwin ''
# on linux symlink permissions cannot be modified, so we modify those on darwin to match the linux ones
${chmodder}/bin/chmodder "$symlink"
'' + ''
done done
echo '${bazel.name}' > $bazelOut/external/.nix-bazel-version echo '${bazel.name}' > $bazelOut/external/.nix-bazel-version

View File

@ -239,7 +239,7 @@ let
x86_64-linux = "sha256-A0A18kxgGNGHNQ67ZPUzh3Yq2LEcRV7CqR9EfP80NQk="; x86_64-linux = "sha256-A0A18kxgGNGHNQ67ZPUzh3Yq2LEcRV7CqR9EfP80NQk=";
aarch64-linux = "sha256-mU2jzuDu89jVmaG/M5bA3jSd7n7lDi+h8sdhs1z8p1A="; aarch64-linux = "sha256-mU2jzuDu89jVmaG/M5bA3jSd7n7lDi+h8sdhs1z8p1A=";
x86_64-darwin = "sha256-9nNTpetvjyipD/l8vKlregl1j/OnZKAcOCoZQeRBvts="; x86_64-darwin = "sha256-9nNTpetvjyipD/l8vKlregl1j/OnZKAcOCoZQeRBvts=";
aarch64-darwin = "sha256-dOGUsdFImeOLcZ3VtgrNnd8A/HgIs/LYuH9GQV7A+78="; aarch64-darwin = "sha256-FqYwI1YC5eqSv+DYj09DC5IaBfFDUCO97y+TFhGiWAA=";
}.${stdenv.system} or (throw "unsupported system ${stdenv.system}"); }.${stdenv.system} or (throw "unsupported system ${stdenv.system}");
}; };

View File

@ -398,7 +398,7 @@ let
else "sha256-QgOaUaq0V5HG9BOv9nEw8OTSlzINNFvbnyP8Vx+r9Xw="; else "sha256-QgOaUaq0V5HG9BOv9nEw8OTSlzINNFvbnyP8Vx+r9Xw=";
aarch64-linux = "sha256-zjnRtTG1j9cZTbP0Xnk2o/zWTNsP8T0n4Ai8IiAT3PE="; aarch64-linux = "sha256-zjnRtTG1j9cZTbP0Xnk2o/zWTNsP8T0n4Ai8IiAT3PE=";
x86_64-darwin = "sha256-RBLox9rzBKcZMm4NwnT7vQ/EjapWQJkqxuQ0LIdaM1E="; x86_64-darwin = "sha256-RBLox9rzBKcZMm4NwnT7vQ/EjapWQJkqxuQ0LIdaM1E=";
aarch64-darwin = "sha256-BRzh79lYvMHsUMk8BEYDLHTpnmeZ9+0lrDtj4XI1YY4="; aarch64-darwin = "sha256-tTk2KPFK4+0wA22xzb2C6qODgAbSxVbue0xk9JOjU04=";
}.${stdenv.hostPlatform.system} or (throw "unsupported system ${stdenv.hostPlatform.system}"); }.${stdenv.hostPlatform.system} or (throw "unsupported system ${stdenv.hostPlatform.system}");
}; };

View File

@ -81,7 +81,7 @@ buildBazelPackage rec {
fetchAttrs = { fetchAttrs = {
sha256 = { sha256 = {
x86_64-linux = "sha256-H2s8sTbmKF+yRfSzLsZAT2ckFuunFwh/FMSKj+GYyPM="; x86_64-linux = "sha256-H2s8sTbmKF+yRfSzLsZAT2ckFuunFwh/FMSKj+GYyPM=";
aarch64-linux = "sha256-R9jzy/dpdCcGgT9yq59Wo/IN/bVo6fxnVPGhLMZ9fbM="; aarch64-linux = "sha256-1/z7sZYMiuB4Re2itDZydsFVEel2NOYmi6vRmBGVO/4=";
}.${stdenv.system} or (throw "unsupported system ${stdenv.system}"); }.${stdenv.system} or (throw "unsupported system ${stdenv.system}");
dontUseCmakeConfigure = true; dontUseCmakeConfigure = true;
dontUseGnConfigure = true; dontUseGnConfigure = true;