Using experimental features on a nixos-rebuild

I encountered an issue whilst attempting to apply a nix configuration to a new system. My config uses the pipe-operators experimental feature and I’m trying to install it from a default system image, specifically the arm64 raspberry pi image.

sudo nixos-rebuild switch --flake=/path/to#flake

Running this gives the error message that suggests using the --extra-experimental-features flag to enable pipe operators but this flag not available for the nixos-rebuild command like it is for the nix commands. The experimental features are listed in the config itself: nix.settings.experimental-features = [ "nix-command" "flakes" "pipe-operators" ];. This however does not seem to work, I suppose that this may be an issue particular to features like pipe operators that alter the language syntax?

Changing the ~/.config/nix/nix.conf to enable the experimental features does not work in this scenario as sudo is needed to apply the system changes, so the user level config is ignored and the system level nix.conf is read only.

I’m not sure how to enable the experimental features in a one-off fashion for nixos commands as you can for nix ones. Does anyone have any suggestions as to how to do this, ideally without applying an intermediate configuration that enables the features?

Related posts which don’t quite address this issue:

You can try --use-remote-sudo (yes, even locally) instead of sudo, so that it runs as your user, and you’d have to use --impure to read your config off the filesystem.