-
Notifications
You must be signed in to change notification settings - Fork 110
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
ca84219
commit 9be5902
Showing
8 changed files
with
147 additions
and
26 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -19,3 +19,4 @@ trivy-results.sarif | |
Pulumi.dev.yaml | ||
lre.bazelrc | ||
rust-project.json | ||
darwin.bazelrc |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,12 @@ | ||
load("@rules_cc//cc:defs.bzl", "cc_binary") | ||
|
||
# This example matches the config of the lre platform | ||
cc_binary( | ||
name = "hello_lre", | ||
srcs = ["hello.cpp"], | ||
copts = ["--verbose"], | ||
target_compatible_with = [ | ||
"@platforms//os:linux", | ||
"@platforms//cpu:x86_64", | ||
], | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
{ | ||
lib, | ||
flake-parts-lib, | ||
... | ||
}: { | ||
options = { | ||
perSystem = flake-parts-lib.mkPerSystemOption ( | ||
{ | ||
config, | ||
options, | ||
pkgs, | ||
... | ||
}: let | ||
cfg = config.darwin; | ||
in { | ||
options = { | ||
darwin = { | ||
pkgs = lib.mkOption { | ||
type = lib.types.uniq (lib.types.lazyAttrsOf (lib.types.raw or lib.types.unspecified)); | ||
description = "Nixpkgs to use."; | ||
default = pkgs; | ||
defaultText = lib.literalMD "`pkgs` (module argument)"; | ||
}; | ||
settings = lib.mkOption { | ||
type = lib.types.submoduleWith { | ||
modules = [./modules/darwin.nix]; | ||
specialArgs = {inherit (cfg) pkgs;}; | ||
}; | ||
default = {}; | ||
description = "Configuration for Bazel on Darwin."; | ||
}; | ||
installationScript = lib.mkOption { | ||
type = lib.types.str; | ||
description = "Create darwin.bazelrc."; | ||
default = cfg.settings.installationScript; | ||
defaultText = lib.literalMD "bazelrc content"; | ||
readOnly = true; | ||
}; | ||
}; | ||
}; | ||
} | ||
); | ||
}; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
{ | ||
config, | ||
lib, | ||
pkgs, | ||
... | ||
}: let | ||
# Conditionally set the bazelrc only if the target system is Darwin (macOS) | ||
bazelrc = | ||
if pkgs.stdenv.isDarwin | ||
then | ||
pkgs.writeText "darwin.bazelrc" '' | ||
# These flags are dynamically generated by the Darwin flake module. | ||
# | ||
# Add `try-import %%workspace%%/darwin.bazelrc` to your .bazelrc to | ||
# include these flags when running Bazel in a nix environment. | ||
# These are the libs and frameworks used by darwin. | ||
build --@rules_rust//:extra_rustc_flags=-L${pkgs.libiconv}/lib,-Lframework=${pkgs.darwin.Security}/Library/Frameworks,-Lframework=${pkgs.darwin.CF}/Library/Frameworks | ||
build --@rules_rust//:extra_exec_rustc_flags=-L${pkgs.libiconv}/lib,-Lframework=${pkgs.darwin.Security}/Library/Frameworks,-Lframework=${pkgs.darwin.CF}/Library/Frameworks | ||
'' | ||
else ""; | ||
in { | ||
options = { | ||
installationScript = lib.mkOption { | ||
type = lib.types.str; | ||
description = "A bash snippet which creates a darwin.bazelrc file in the | ||
repository."; | ||
}; | ||
}; | ||
config = { | ||
installationScript = '' | ||
if ! type -t git >/dev/null; then | ||
# In pure shells | ||
echo 1>&2 "WARNING: Darwin: git command not found; skipping installation." | ||
elif ! ${pkgs.git}/bin/git rev-parse --git-dir &> /dev/null; then | ||
echo 1>&2 "WARNING: Darwin: .git not found; skipping installation." | ||
else | ||
GIT_WC=`${pkgs.git}/bin/git rev-parse --show-toplevel` | ||
# These update procedures compare before they write, to avoid | ||
# filesystem churn. This improves performance with watch tools like | ||
# lorri and prevents installation loops by lorri. | ||
if ! readlink "''${GIT_WC}/darwin.bazelrc" >/dev/null \ | ||
|| [[ $(readlink "''${GIT_WC}/darwin.bazelrc") != ${bazelrc} ]]; then | ||
echo 1>&2 "Darwin: updating $PWD repository" | ||
[ -L darwin.bazelrc ] && unlink darwin.bazelrc | ||
if [ -e "''${GIT_WC}/darwin.bazelrc" ]; then | ||
echo 1>&2 "Darwin: WARNING: Refusing to install because of pre-existing darwin.bazelrc" | ||
echo 1>&2 " Remove the darwin.bazelrc file and add darwin.bazelrc to .gitignore." | ||
else | ||
ln -fs ${bazelrc} "''${GIT_WC}/darwin.bazelrc" | ||
fi | ||
fi | ||
fi | ||
''; | ||
}; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters