Skip to content

Replace touch with bash builtin to fix NixOS compatibility#101

Open
DhashS wants to merge 1 commit intobuildbuddy-io:mainfrom
DhashS:fix-nixos-touch
Open

Replace touch with bash builtin to fix NixOS compatibility#101
DhashS wants to merge 1 commit intobuildbuddy-io:mainfrom
DhashS:fix-nixos-touch

Conversation

@DhashS
Copy link
Copy Markdown

@DhashS DhashS commented Apr 17, 2026

Summary

  • Replace touch "$1" with : > "$1" in _bazel_env_rule_impl
  • Replace touch $@ with : > $@ in the toolchain genrule

Problem

Fixes #100.

bazel_env fails on NixOS when using bazelisk (unpatched Bazel binaries). Bazel runs run_shell actions with a stripped environment (exec env -), so touch — an external command — is not found. On NixOS, tools live in the Nix store and are only reachable via PATH.

Fix

: > is a bash builtin (: is equivalent to true) combined with output redirection, which creates/truncates a file identically to touch without requiring any external command on PATH. This is a no-op change on other platforms.

Tested locally: 26/27 → 27/27 targets building with bazelisk on NixOS.

This PR was entirely vibe coded with Claude Code.

Use `: >` (bash builtin) instead of `touch` (external command) to create
output files. On NixOS with bazelisk, shell actions run with a stripped
environment where external commands are not on PATH.

Fixes buildbuddy-io#100

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

bazel_env fails on NixOS with bazelisk: touch: command not found

1 participant