diff options
author | github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> | 2023-04-06 16:11:06 +0000 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-04-06 16:11:06 +0000 |
commit | 638ad26bf6c7e1163eecc988ad32e7f0e407aca7 (patch) | |
tree | cb59e85b7504ce98c2e59c27ced041a3cfb43671 /pkgs/build-support | |
parent | fd1afd335926c668c761115a4c882eb5f4b24ede (diff) | |
parent | d3f37613e93528fa24b70fe62187da08f8f20869 (diff) |
Merge master into staging-next
Diffstat (limited to 'pkgs/build-support')
-rw-r--r-- | pkgs/build-support/build-bazel-package/default.nix | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/pkgs/build-support/build-bazel-package/default.nix b/pkgs/build-support/build-bazel-package/default.nix index 1901aa2235e73..a49d3c781ed83 100644 --- a/pkgs/build-support/build-bazel-package/default.nix +++ b/pkgs/build-support/build-bazel-package/default.nix @@ -1,6 +1,7 @@ { stdenv , cacert , lib +, writeCBin }: args@{ @@ -75,6 +76,28 @@ let ${lib.strings.concatStringsSep " " additionalFlags} \ ${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 stdenv.mkDerivation (fBuildAttrs // { @@ -149,6 +172,10 @@ stdenv.mkDerivation (fBuildAttrs // { new_target="$(readlink "$symlink" | sed "s,$NIX_BUILD_TOP,NIX_BUILD_TOP,")" rm "$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 echo '${bazel.name}' > $bazelOut/external/.nix-bazel-version |