Skip to content

Commit 0ff64b1

Browse files
authored
Standardize flake naming conventions (#1698)
1 parent 4b42fec commit 0ff64b1

File tree

5 files changed

+33
-40
lines changed

5 files changed

+33
-40
lines changed

flake.lock

Lines changed: 1 addition & 4 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

flake.nix

Lines changed: 23 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44
inputs = {
55
nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable";
66
flake-parts.url = "github:hercules-ci/flake-parts";
7-
flake-utils.url = "github:numtide/flake-utils";
87
git-hooks = {
98
url = "github:cachix/git-hooks.nix";
109
inputs.nixpkgs.follows = "nixpkgs";
@@ -20,7 +19,6 @@
2019
# TODO(SchahinRohani): Use a specific commit hash until nix2container is stable.
2120
url = "github:nlewo/nix2container/cc96df7c3747c61c584d757cfc083922b4f4b33e";
2221
inputs.nixpkgs.follows = "nixpkgs";
23-
inputs.flake-utils.follows = "flake-utils";
2422
};
2523
};
2624

@@ -46,6 +44,18 @@
4644
./tools/nixos/flake-module.nix
4745
./flake-module.nix
4846
];
47+
flake = {
48+
flakeModules = {
49+
default = ./flake-module.nix;
50+
darwin = ./tools/darwin/flake-module.nix;
51+
lre = ./local-remote-execution/flake-module.nix;
52+
nixos = ./tools/nixos/flake-module.nix;
53+
};
54+
overlays = {
55+
lre = import ./local-remote-execution/overlays/default.nix {inherit nix2container;};
56+
tools = import ./tools/public/default.nix {inherit nix2container;};
57+
};
58+
};
4959
perSystem = {
5060
config,
5161
pkgs,
@@ -363,7 +373,7 @@
363373
nightly-rust = pkgs.rust-bin.nightly.${pkgs.lre.nightly-rust.meta.version};
364374
};
365375
};
366-
local-remote-execution.settings = {
376+
lre.settings = {
367377
Env = with pkgs.lre;
368378
if pkgs.stdenv.isDarwin
369379
then lre-rs.meta.Env # C++ doesn't support Darwin yet.
@@ -373,18 +383,16 @@
373383
then "macos"
374384
else "linux";
375385
};
376-
nixos.settings = {
377-
path = with pkgs; [
378-
"/run/current-system/sw/bin"
379-
"${binutils.bintools}/bin"
380-
"${uutils-coreutils-noprefix}/bin"
381-
"${pkgs.lre.clang}/bin"
382-
"${git}/bin"
383-
"${python3}/bin"
384-
];
385-
};
386+
nixos.settings.path = with pkgs; [
387+
"/run/current-system/sw/bin"
388+
"${binutils.bintools}/bin"
389+
"${uutils-coreutils-noprefix}/bin"
390+
"${pkgs.lre.clang}/bin"
391+
"${git}/bin"
392+
"${python3}/bin"
393+
];
386394
devShells.default = pkgs.mkShell {
387-
nativeBuildInputs = let
395+
packages = let
388396
bazel = pkgs.writeShellScriptBin "bazel" ''
389397
unset TMPDIR TMP
390398
exec ${pkgs.bazelisk}/bin/bazelisk "$@"
@@ -456,7 +464,7 @@
456464
457465
# Generate lre.bazelrc which configures LRE toolchains when
458466
# running in the nix environment.
459-
${config.local-remote-execution.installationScript}
467+
${config.lre.installationScript}
460468
461469
# Generate nativelink.bazelrc which gives Bazel invocations access
462470
# to NativeLink's read-only cache.
@@ -492,17 +500,5 @@
492500
'';
493501
};
494502
};
495-
}
496-
// {
497-
flakeModule = {
498-
default = ./flake-module.nix;
499-
darwin = ./tools/darwin/flake-module.nix;
500-
local-remote-execution = ./local-remote-execution/flake-module.nix;
501-
nixos = ./tools/nixos/flake-module.nix;
502-
};
503-
overlays = {
504-
lre = import ./local-remote-execution/overlays/default.nix {inherit nix2container;};
505-
tools = import ./tools/public/default.nix {inherit nix2container;};
506-
};
507503
};
508504
}

local-remote-execution/README.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ devShells.default = pkgs.mkShell {
6969
shellHook = ''
7070
# Generate lre.bazelrc which configures LRE toolchains when running
7171
# in the nix environment.
72-
${config.local-remote-execution.installationScript}
72+
${config.lre.installationScript}
7373
'';
7474
}
7575
```
@@ -101,12 +101,12 @@ build --extra_toolchains=@local-remote-execution//generated-cc/config:cc-toolcha
101101

102102
In the snippet above you can see a warning that no local toolchain is
103103
configured. LRE needs to know the remote toolchain configuration to make it
104-
available locally. The `local-remote-execution` settings take an `Env` input and
104+
available locally. The `lre` settings take an `Env` input and
105105
an optional `prefix` input to configure the generated `lre.bazelrc`:
106106

107107
```nix
108108
# This is a top-level field, next to `packages` and `apps`, and `devShells`
109-
local-remote-execution.settings = {
109+
lre.settings = {
110110
# In this example we import the lre-cc environment from nativelink and make it
111111
# available locally.
112112
inherit (lre-cc.meta) Env;
@@ -270,7 +270,7 @@ invoke a build against the cluster:
270270
CACHE=$(kubectl get gtw cache -o=jsonpath='{.status.addresses[0].value}')
271271
SCHEDULER=$(kubectl get gtw scheduler -o=jsonpath='{.status.addresses[0].value}')
272272
273-
# Note: If you omit setting a `prefix` the `local-remote-execution.settings` you
273+
# Note: If you omit setting a `prefix` the `lre.settings` you
274274
# can omit `--config=lre` here as LRE will be enabled by default.
275275
bazel build \
276276
--config=lre \
@@ -300,7 +300,7 @@ bazel clean
300300
301301
CACHE=$(kubectl get gtw cache -o=jsonpath='{.status.addresses[0].value}')
302302
303-
# Note: If you omit setting a `prefix` the `local-remote-execution.settings` you
303+
# Note: If you omit setting a `prefix` the `lre.settings` you
304304
# can omit `--config=lre` here as LRE will be enabled by default.
305305
bazel build \
306306
--config=lre \

local-remote-execution/flake-module.nix

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,10 @@
1111
pkgs,
1212
...
1313
}: let
14-
cfg = config.local-remote-execution;
14+
cfg = config.lre;
1515
in {
1616
options = {
17-
local-remote-execution = {
17+
lre = {
1818
pkgs = lib.mkOption {
1919
type = lib.types.uniq (lib.types.lazyAttrsOf (lib.types.raw or lib.types.unspecified));
2020
description = lib.mdDoc ''

local-remote-execution/modules/lre.nix

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@
4141
# devShells.default = pkgs.mkShell {
4242
# shellHook = ''
4343
# # Generate the `lre.bazelrc` config file.
44-
# ${config.local-remote-execution.installationScript}
44+
# ${config.lre.installationScript}
4545
# '';
4646
# };
4747
# ```
@@ -103,7 +103,7 @@
103103
then ["#" "# WARNING: No environment set. LRE will not work locally."]
104104
else ["#"] ++ (map (x: "# " + x) (lib.lists.unique config.Env));
105105

106-
# If the `local-remote-execution.settings.prefix` is set to a nonempty string,
106+
# If the `lre.settings.prefix` is set to a nonempty string,
107107
# prefix the Bazel build commands with that string. This will disable LRE
108108
# by default and require adding `--config=<prefix>` to Bazel invocations.
109109
maybePrefixedConfig =

0 commit comments

Comments
 (0)