Skip to content

Commit

Permalink
Drop the _hermetic suffix on new cc toolchain
Browse files Browse the repository at this point in the history
Addressing review comment
tweag#128 (comment)
  • Loading branch information
aherrmann committed Nov 23, 2020
1 parent b3cce10 commit ca71928
Show file tree
Hide file tree
Showing 5 changed files with 21 additions and 19 deletions.
15 changes: 8 additions & 7 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,13 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/).

[Unreleased]: https://github.com/tweag/rules_nixpkgs/compare/v0.7.0...HEAD

### Added

- Define `nixpkgs_cc_configure_hermetic` in `//nixpkgs:repositories.bzl`.
See [#128][#128].

### Changed

- The implementation of `nixpkgs_cc_configure` has been replaced by a more
hermetic version that no longer uses Bazel's builtin autodection toolchain
under the hood. The previous behavior is now available under the name
`nixpkgs_cc_configure_deprecated`, if required.
See [#128][#128].
- The values in the `nixopts` attribute to `nixpkgs_package` are now subject to
location expansion. Any instance of `$(location LABEL)` in the `nixopts`
attribute will be expanded to the file path of the file referenced by
Expand All @@ -23,8 +23,9 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/).

### Deprecated

- `nixpkgs_cc_configure` has been deprecated in favor of
`nixpkgs_cc_configure_hermetic` and will be replaced by it in future.
- The old implementation of `nixpkgs_cc_configure`, now available under the
name `nixpkgs_cc_configure_deprecated`, has been marked as deprecated in
favor of `nixpkgs_cc_configure` and will be replaced by it in future.
See [#128][#128].

[#128]: https://github.com/tweag/rules_nixpkgs/pull/128
Expand Down
11 changes: 6 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ Links:
* [nixpkgs_git_repository](#nixpkgs_git_repository)
* [nixpkgs_package](#nixpkgs_package)
* [nixpkgs_cc_configure](#nixpkgs_cc_configure)
* [nixpkgs_cc_configure_deprecated](#nixpkgs_cc_configure_deprecated)
* [nixpkgs_go_configure](#nixpkgs_go_configure)

## Setup
Expand Down Expand Up @@ -326,7 +327,7 @@ filegroup(
</tbody>
</table>

### nixpkgs_cc_configure_hermetic
### nixpkgs_cc_configure

Use a CC toolchain from Nixpkgs. No-op if not a nix-based platform.

Expand All @@ -350,7 +351,7 @@ toolchain.
Example:

```bzl
nixpkgs_cc_configure_hermetic(repository = "@nixpkgs//:default.nix")
nixpkgs_cc_configure(repository = "@nixpkgs//:default.nix")
```

<table class="table table-condensed table-bordered table-params">
Expand Down Expand Up @@ -421,7 +422,7 @@ nixpkgs_cc_configure_hermetic(repository = "@nixpkgs//:default.nix")
</tbody>
</table>

### nixpkgs_cc_configure
### nixpkgs_cc_configure_deprecated

Tells Bazel to use compilers and linkers from Nixpkgs for the CC
toolchain. By default, Bazel autodetects a toolchain on the current
Expand All @@ -430,7 +431,7 @@ is considered a best practice.

Deprecated:

Use `nixpkgs_cc_configure_hermetic` instead.
Use `nixpkgs_cc_configure` instead.

While this improves upon Bazel's autoconfigure toolchain by picking tools from
a Nix derivation rather than the environment, it is still not fully hermetic as
Expand All @@ -441,7 +442,7 @@ depending on the cc toolchain leading to cache misses.
Example:

```bzl
nixpkgs_cc_configure(repository = "@nixpkgs//:default.nix")
nixpkgs_cc_configure_deprecated(repository = "@nixpkgs//:default.nix")
```

<table class="table table-condensed table-bordered table-params">
Expand Down
4 changes: 2 additions & 2 deletions WORKSPACE
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ rules_nixpkgs_dependencies()

load(
"//nixpkgs:nixpkgs.bzl",
"nixpkgs_cc_configure_hermetic",
"nixpkgs_cc_configure",
"nixpkgs_git_repository",
"nixpkgs_local_repository",
"nixpkgs_package",
Expand Down Expand Up @@ -161,7 +161,7 @@ nixpkgs_package(
repository = "@nixpkgs",
)

nixpkgs_cc_configure_hermetic(repository = "@remote_nixpkgs")
nixpkgs_cc_configure(repository = "@remote_nixpkgs")

nixpkgs_python_configure(
python2_attribute_path = "python2",
Expand Down
6 changes: 3 additions & 3 deletions nixpkgs/nixpkgs.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -522,7 +522,7 @@ _nixpkgs_cc_toolchain = repository_rule(
},
)

def nixpkgs_cc_configure_hermetic(
def nixpkgs_cc_configure(
name = "nixpkgs_config_cc",
attribute_path = "",
nix_file = None,
Expand Down Expand Up @@ -682,7 +682,7 @@ nixpkgs_cc_autoconf = repository_rule(
],
)

def nixpkgs_cc_configure(
def nixpkgs_cc_configure_deprecated(
repository = None,
repositories = {},
nix_file = None,
Expand All @@ -692,7 +692,7 @@ def nixpkgs_cc_configure(
"""Use a CC toolchain from Nixpkgs. No-op if not a nix-based platform.
Deprecated:
Use `nixpkgs_cc_configure_hermetic` instead.
Use `nixpkgs_cc_configure` instead.
While this improves upon Bazel's autoconfigure toolchain by picking tools
from a Nix derivation rather than the environment, it is still not fully
Expand Down
4 changes: 2 additions & 2 deletions tests/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -76,13 +76,13 @@ sh_test(
toolchains = ["@rules_sh//sh/posix:make_variables"],
)

# Test nixpkgs_cc_configure_hermetic() by building some CC code.
# Test nixpkgs_cc_configure() by building some CC code.
cc_binary(
name = "cc-test",
srcs = ["cc-test.cc"],
)

# Test that nixpkgs_cc_configure_hermetic is selected.
# Test that nixpkgs_cc_configure is selected.
cc_toolchain_test(
name = "cc-toolchain",
)
Expand Down

0 comments on commit ca71928

Please sign in to comment.