Running multiple commands through `nix develop -c`

I am trying to use a nix flake for some dependencies but I can’t seem to run multiple commands on a single develop command.

Running something like nix develop -c ./gradlew --no-daemon clean buildPlugin works ok, but adding a && or ; will take me out of the environment for the next command.

Trying to quote it also fails, with

nix develop --command ‘./gradlew --no-daemon clean buildPlugin && ./gradlew --no-daemon clean runIde’

trying to find a directory from the text between the quotes.

/tmp/nix-shell.2c93e3: line 2165: /home/[user]/projects/plugin2/gradlew --no-daemon clean buildPlugin && ./gradlew --no-daemon clean runIde: No such file or directory

The simple solution is to just launch the shell, but I’m sure there’s a way to not do this as I’d like a good workflow.

The -c option isn’t interpreted by a shell layer. The argument array is made into a command line directly. So if you want shell syntax available, call an actual shell:

nix develop -c bash -c './gradlew --no-daemon clean buildPlugin && ./gradlew --no-daemon clean runIde'
1 Like