-
Notifications
You must be signed in to change notification settings - Fork 442
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Nix example switched to using crate_universe_dependencies(bootstrap=True)
#2313
Nix example switched to using crate_universe_dependencies(bootstrap=True)
#2313
Conversation
1f78b0e
to
cb917cf
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As discussed offline, repinning currently fails for me with a vanilla nix
install with error: experimental Nix feature 'nix-command' is disabled; add '--extra-experimental-features nix-command' to enable it
- let's make this script run cleanly out of the box. Otherwise LGTM!
160c895
to
327631e
Compare
util/repin_all.sh
Outdated
echo "Visit https://nixos.org/download for installation instructions." | ||
exit 1 | ||
fi | ||
export NIX_CONFIG="$NIX_CONFIG\nexperimental-features = nix-command flakes" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This fails if $NIX_CONFIG
isn't set...
Just using ${NIX_CONFIG:-}
doesn't work because nix doesn't appear to like a plain leading \n
.
I changed it like this:
diff --git a/util/repin_all.sh b/util/repin_all.sh
index c7dba917..8fc9a0a2 100755
--- a/util/repin_all.sh
+++ b/util/repin_all.sh
@@ -10,7 +10,12 @@ if ! command -v nix &> /dev/null; then
echo "Visit https://nixos.org/download for installation instructions."
exit 1
fi
-export NIX_CONFIG="$NIX_CONFIG\nexperimental-features = nix-command flakes"
+new_nix_config="experimental-features = nix-command flakes"
+if [[ -z "${NIX_CONFIG:-}" ]]; then
+ export NIX_CONFIG="${new_nix_config}"
+else
+ export NIX_CONFIG="${NIX_CONFIG}\n${new_nix_config}"
+fi
# Re-generates all files which may need to be re-generated after changing crate_universe.
bazel run //crate_universe/3rdparty:crates_vendor
but it still doesn't seem to work with me on my ARM Mac:
% util/repin_all.sh
WARNING: Running Bazel server needs to be killed, because the startup options are different.
Starting local Bazel server and connecting to it...
INFO: Invocation ID: bd09af97-4b47-46c0-86d0-fba066034fcc
INFO: Analyzed target //crate_universe/3rdparty:crates_vendor (114 packages loaded, 351 targets configured).
INFO: Found 1 target...
Target //crate_universe/3rdparty:crates_vendor up-to-date:
bazel-bin/crate_universe/3rdparty/crates_vendor.sh
INFO: Elapsed time: 3.890s, Critical Path: 0.01s
INFO: 1 process: 1 internal.
INFO: Build completed successfully, 1 total action
INFO: Running command line: bazel-bin/crate_universe/3rdparty/crates_vendor.sh
Loading: 0 packages loaded
Loading: 0 packages loaded
checking cached actions
error: flake 'path:/Volumes/Source/github.com/bazelbuild/rules_rust/examples/nix_cross_compiling/nix' does not provide attribute 'packages.aarch64-darwin.bazel.rust', 'legacyPackages.aarch64-darwin.bazel.rust' or 'bazel.rust'
INFO: Repository nix_rust instantiated at:
/Volumes/Source/github.com/bazelbuild/rules_rust/examples/nix_cross_compiling/WORKSPACE.bazel:17:17: in <toplevel>
/Volumes/Source/github.com/bazelbuild/rules_rust/examples/nix_cross_compiling/bazel/nix_repositories.bzl:213:26: in nix_repositories
/private/var/tmp/_bazel_dwagnerhall/ce461197ed3d17b80eddc01283ea4d6f/external/rules_nixpkgs_core/nixpkgs.bzl:876:27: in nixpkgs_flake_package
Repository rule _nixpkgs_flake_package defined at:
/private/var/tmp/_bazel_dwagnerhall/ce461197ed3d17b80eddc01283ea4d6f/external/rules_nixpkgs_core/nixpkgs.bzl:795:41: in <toplevel>
ERROR: An error occurred during the fetch of repository 'nix_rust':
Traceback (most recent call last):
File "/private/var/tmp/_bazel_dwagnerhall/ce461197ed3d17b80eddc01283ea4d6f/external/rules_nixpkgs_core/nixpkgs.bzl", line 793, column 31, in _nixpkgs_flake_package_impl
_nixpkgs_build_and_symlink(repository_ctx, [nix_path, "build"], expr_args, build_file_content)
File "/private/var/tmp/_bazel_dwagnerhall/ce461197ed3d17b80eddc01283ea4d6f/external/rules_nixpkgs_core/nixpkgs.bzl", line 447, column 34, in _nixpkgs_build_and_symlink
exec_result = execute_or_fail(
File "/private/var/tmp/_bazel_dwagnerhall/ce461197ed3d17b80eddc01283ea4d6f/external/rules_nixpkgs_core/util.bzl", line 97, column 13, in execute_or_fail
fail("""
Error in fail:
Cannot build Nix derivation for package '@nix_rust'.
Command: "/nix/var/nix/profiles/default/bin/nix" "build" "path:/Volumes/Source/github.com/bazelbuild/rules_rust/examples/nix_cross_compiling/nix#bazel.rust" "--print-out-paths" "--out-link" "bazel-support/nix-out-link"
Return code: 1
Error output:
> error: flake 'path:/Volumes/Source/github.com/bazelbuild/rules_rust/examples/nix_cross_compiling/nix' does not provide attribute 'packages.aarch64-darwin.bazel.rust', 'legacyPackages.aarch64-darwin.bazel.rust' or 'bazel.rust'
ERROR: /Volumes/Source/github.com/bazelbuild/rules_rust/examples/nix_cross_compiling/WORKSPACE.bazel:17:17: fetching _nixpkgs_flake_package rule //external:nix_rust: Traceback (most recent call last):
File "/private/var/tmp/_bazel_dwagnerhall/ce461197ed3d17b80eddc01283ea4d6f/external/rules_nixpkgs_core/nixpkgs.bzl", line 793, column 31, in _nixpkgs_flake_package_impl
_nixpkgs_build_and_symlink(repository_ctx, [nix_path, "build"], expr_args, build_file_content)
File "/private/var/tmp/_bazel_dwagnerhall/ce461197ed3d17b80eddc01283ea4d6f/external/rules_nixpkgs_core/nixpkgs.bzl", line 447, column 34, in _nixpkgs_build_and_symlink
exec_result = execute_or_fail(
File "/private/var/tmp/_bazel_dwagnerhall/ce461197ed3d17b80eddc01283ea4d6f/external/rules_nixpkgs_core/util.bzl", line 97, column 13, in execute_or_fail
fail("""
Error in fail:
Cannot build Nix derivation for package '@nix_rust'.
Command: "/nix/var/nix/profiles/default/bin/nix" "build" "path:/Volumes/Source/github.com/bazelbuild/rules_rust/examples/nix_cross_compiling/nix#bazel.rust" "--print-out-paths" "--out-link" "bazel-support/nix-out-link"
Return code: 1
Error output:
> error: flake 'path:/Volumes/Source/github.com/bazelbuild/rules_rust/examples/nix_cross_compiling/nix' does not provide attribute 'packages.aarch64-darwin.bazel.rust', 'legacyPackages.aarch64-darwin.bazel.rust' or 'bazel.rust'
ERROR: Error computing the main repository mapping: Encountered error while reading extension file 'defs.bzl': no such package '@@crate_index//': no such package '@@cargo_bazel_bootstrap//': no such package '@@nix_rust//':
Cannot build Nix derivation for package '@nix_rust'.
Command: "/nix/var/nix/profiles/default/bin/nix" "build" "path:/Volumes/Source/github.com/bazelbuild/rules_rust/examples/nix_cross_compiling/nix#bazel.rust" "--print-out-paths" "--out-link" "bazel-support/nix-out-link"
Return code: 1
Error output:
> error: flake 'path:/Volumes/Source/github.com/bazelbuild/rules_rust/examples/nix_cross_compiling/nix' does not provide attribute 'packages.aarch64-darwin.bazel.rust', 'legacyPackages.aarch64-darwin.bazel.rust' or 'bazel.rust'
2f2e560
to
424411d
Compare
docs/MODULE.bazel.lock
Outdated
@@ -621,7 +621,7 @@ | |||
} | |||
}, | |||
"moduleExtensions": { | |||
"@apple_support~1.5.0//crosstool:setup.bzl%apple_cc_configure_extension": { | |||
"@@apple_support~1.5.0//crosstool:setup.bzl%apple_cc_configure_extension": { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Having no experience with bzlmod yet, I don't know if this is expected. Presumably something to do with Bazel 7.0.0 officially getting released 6 hours ago (🥳)?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah from: https://github.com/bazelbuild/bazel/releases/tag/7.0.0
[Incompatible] All labels in Bazel error messages, log output, Build Event Protocol, etc. are now prefixed with double-at (@@) instead of single-at (@) where applicable, to properly denote that they contain canonical repo names.
c91da3e
to
bf8893f
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, tahnks!
Head branch was pushed to by a user without write access
bf8893f
to
948b692
Compare
948b692
to
0773ade
Compare
Seeing as #2279 is merged, this fixes the current Nix built
cargo-bazel
getting stale because it's not able to watch the source files. This should make for much better iteration speed as well, as the Nix built form has to do a clean build every time.