Skip to content

Commit f3d2c7a

Browse files
authored
🎠 Sync flake module conventions to LRE (#258)
1 parent 67bf75e commit f3d2c7a

File tree

7 files changed

+39
-35
lines changed

7 files changed

+39
-35
lines changed

.bazelrc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ build --noexperimental_profile_include_primary_output
4444
build --remote_instance_name=main
4545

4646
# Nix-generated action env for rules_ll.
47-
try-import %workspace%/.bazelrc.ll
47+
try-import %workspace%/ll.bazelrc
4848

4949
# Nix-generated flags for LRE.
5050
try-import %workspace%/lre.bazelrc

.gitignore

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,10 +26,10 @@ MODULE.bazel.lock
2626
examples/MODULE.bazel.lock
2727

2828
# Generated by the rules_ll bazelrc hook.
29-
.bazelrc.ll
29+
ll.bazelrc
3030

3131
# Generated by the LRE bazelrc hook.
32-
.bazelrc.lre
32+
lre.bazelrc
3333

3434
# Ignore NativeLink's local Pulumi stack.
3535
Pulumi.dev.yaml

examples/.bazelrc

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,9 +44,9 @@ build --noexperimental_profile_include_primary_output
4444
build --remote_instance_name=main
4545

4646
# Nix-generated action env for rules_ll. Usually this would be
47-
# `%workspace%/.bazelrc.ll`, but since this example flake is in the rules_ll
47+
# `%workspace%/ll.bazelrc`, but since this example flake is in the rules_ll
4848
# repository we need to reference the file from the parent directory.
49-
try-import %workspace%/../.bazelrc.ll
49+
try-import %workspace%/../ll.bazelrc
5050

5151
# Nix-generated flags for LRE.
5252
try-import %workspace%/../lre.bazelrc

examples/flake.nix

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -92,10 +92,12 @@
9292
local-remote-execution.settings = {
9393
inherit (pkgs.lre.lre-cc.meta) Env;
9494
};
95-
rules_ll.settings.llEnv = rules_ll.lib.defaultLlEnv {
96-
inherit pkgs;
97-
LL_CFLAGS = "-I${openssl.dev}/include";
98-
LL_LDFLAGS = "-L${openssl.out}/lib";
95+
rules_ll.settings = {
96+
Env = rules_ll.lib.defaultLlEnv {
97+
inherit pkgs;
98+
LL_CFLAGS = "-I${openssl.dev}/include";
99+
LL_LDFLAGS = "-L${openssl.out}/lib";
100+
};
99101
};
100102
devShells.default = pkgs.mkShell {
101103
nativeBuildInputs =

flake-module.nix

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ in
3333
};
3434
installationScript = mkOption {
3535
type = types.str;
36-
description = lib.mdDoc "A .bazelrc.ll generator for rules_ll.";
36+
description = lib.mdDoc "A ll.bazelrc generator for rules_ll.";
3737
default = cfg.settings.installationScript;
3838
defaultText = lib.literalMD "bazelrc contents";
3939
readOnly = true;

flake.nix

Lines changed: 13 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -93,15 +93,17 @@
9393
pre-commit.settings = {
9494
hooks = import ./pre-commit-hooks.nix { inherit pkgs; };
9595
};
96-
rules_ll.settings.llEnv =
97-
let
98-
openssl = (pkgs.openssl.override { static = true; });
99-
in
100-
self.lib.defaultLlEnv {
101-
inherit pkgs;
102-
LL_CFLAGS = "-I${openssl.dev}/include";
103-
LL_LDFLAGS = "-L${openssl.out}/lib";
104-
};
96+
rules_ll.settings = {
97+
Env =
98+
let
99+
openssl = (pkgs.openssl.override { static = true; });
100+
in
101+
self.lib.defaultLlEnv {
102+
inherit pkgs;
103+
LL_CFLAGS = "-I${openssl.dev}/include";
104+
LL_LDFLAGS = "-L${openssl.out}/lib";
105+
};
106+
};
105107
packages = {
106108
ll = import ./devtools/ll.nix {
107109
inherit pkgs;
@@ -145,11 +147,11 @@
145147
# development shell.
146148
${config.pre-commit.installationScript}
147149
148-
# Generate .bazelrc.ll which contains Bazel configuration
150+
# Generate ll.bazelrc which contains Bazel configuration
149151
# when rules_ll is run from a nix environment.
150152
${config.rules_ll.installationScript}
151153
152-
# Generate .bazelrc.lre which configures the LRE toolchains.
154+
# Generate lre.bazelrc which configures the LRE toolchains.
153155
${config.local-remote-execution.installationScript}
154156
155157
# Ensure that the ll command points to our ll binary.

modules/rules_ll.nix

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,12 @@ let
44

55
inherit (pkgs) runCommand writeText git;
66

7-
processedActionEnvs = map (x: "build --@rules_ll//ll:" + x) config.llEnv;
7+
processedActionEnvs = map (x: "build --@rules_ll//ll:" + x) config.Env;
88

9-
configFile = runCommand ".bazelrc.ll" { } ''
9+
configFile = runCommand "ll.bazelrc" { } ''
1010
printf '# These flags are dynamically generated by rules_ll.
1111
#
12-
# Add try-import %%workspace%%/.bazelrc.ll to your .bazelrc to
12+
# Add try-import %%workspace%%/ll.bazelrc to your .bazelrc to
1313
# include these flags when running Bazel in a nix environment.
1414
1515
${lib.concatLines processedActionEnvs}' >$out
@@ -20,23 +20,23 @@ in
2020
installationScript = mkOption {
2121
type = types.str;
2222
description = lib.mkDoc ''
23-
A bash snippet which creates a .bazelrc.ll file in the repository.
23+
A bash snippet which creates an ll.bazelrc file in the repository.
2424
'';
2525
};
26-
llEnv = mkOption {
26+
Env = mkOption {
2727
type = types.listOf types.str;
2828
description = lib.mdDoc ''
2929
Environment variables for `--@rules_ll//ll:*` settings.
3030
3131
For instance:
3232
3333
```nix
34-
llEnv = [
34+
Env = [
3535
"LL_CFLAGS=-I''${openssl.dev}/include"
3636
]
3737
```
3838
39-
results in the following line in `.bazelrc.ll`:
39+
results in the following line in `ll.bazelrc`:
4040
4141
```bash
4242
build --@rules_ll//ll:LL_CFLAGS=-I''${openssl.dev}/include
@@ -72,16 +72,16 @@ in
7272
# filesystem churn. This improves performance with watch tools like
7373
# lorri and prevents installation loops by lorri.
7474
75-
if ! readlink "''${GIT_WC}/.bazelrc.ll" >/dev/null \
76-
|| [[ $(readlink "''${GIT_WC}/.bazelrc.ll") != ${configFile} ]]; then
75+
if ! readlink "''${GIT_WC}/ll.bazelrc" >/dev/null \
76+
|| [[ $(readlink "''${GIT_WC}/ll.bazelrc") != ${configFile} ]]; then
7777
echo 1>&2 "rules_ll: updating $PWD repository"
78-
[ -L .bazelrc.ll ] && unlink .bazelrc.ll
78+
[ -L ll.bazelrc ] && unlink ll.bazelrc
7979
80-
if [ -e "''${GIT_WC}/.bazelrc.ll" ]; then
81-
echo 1>&2 "rules_ll: WARNING: Refusing to install because of pre-existing .bazelrc.ll"
82-
echo 1>&2 " Remove the .bazelrc.ll file and add .bazelrc.ll to .gitignore."
80+
if [ -e "''${GIT_WC}/ll.bazelrc" ]; then
81+
echo 1>&2 "rules_ll: WARNING: Refusing to install because of pre-existing ll.bazelrc"
82+
echo 1>&2 " Remove the ll.bazelrc file and add ll.bazelrc to .gitignore."
8383
else
84-
ln -fs ${configFile} "''${GIT_WC}/.bazelrc.ll"
84+
ln -fs ${configFile} "''${GIT_WC}/ll.bazelrc"
8585
fi
8686
fi
8787
fi

0 commit comments

Comments
 (0)