Understanding binutils-darwin-wrapper/nix-support bad substitution

I’m getting the following error in a GitHub action on macOS

/nix/store/3z9jfr419kz91rzx0sq5880k14s70sjk-cctools-binutils-darwin-wrapper-927.0.2/nix-support/setup-hook: line 134: ${cmd^^}${role_post}=${cmd}: bad substitution

As I don’t have a Mac available locally, It’s especially difficult to understand what’s going on.

Can you offer any hints on how to understand what is going on?

looks to me an illegal bash command. A guess out of the blue, the darwin system is using the system’s bash (which behaves bit differently on macos vs linux). I git grepped ${cmd^^}${role_post} and it’s coming from nigpkgs/pkgs/build-support/bintools-wrapper/setup-hook.sh I wonder if you can avoid running this by using clang or more darwin specific compilation tools. Sorry if Im not of much help.

Spot on!

It turns out that nix-shell --run <whatever> gave the warning:

warning: file 'nixpkgs' was not found in the Nix search path (add it using $NIX_PATH or -I), at (string):1:9; will use bash from your environment

This is in a GitHub action where I install Nix with cachix/install-nix-action@v12, so this particular problem is easily fixed by setting nixpkgs thus:

- name: Install Nix
  uses: cachix/install-nix-action@v12
    nix_path: nixpkgs=channel:nixos-unstable

I don’t like that nixos-unstable, but that is best discussed elsewhere.

1 Like

Hmm, interesting. Looking at the source code, maybe setting NIX_BUILD_SHELL environment variable to bash in the GH workflow and adding bashInteractive to shell.nix would be able to bypass this? Or are inputs added to the environment too late?