buildInput with whitespace in the path

Hi folks,

I have a default.nix file which I am using to setup an environment for some mobile apps. In order to do this on mac osx I need to include some build inputs with whitespace in their path.

Example:

/Applications/foo/White Space.app/lib/Content

When I run nix-shell nix is throwing and saying:

build input /Applications/foo/White does not exist

I have tried escaping the space bash style like this:

/Applications/foo/White\ Space.app/lib/Content

but the error persists.

How do I include a whitespace in a path in a default.nix file and also where in the manual is this covered.

In the nix language, you can concatenate a string to a path, resulting in a path, like so:

nix-repl> ./. + "/foo" == ./foo
true

You should be able to put the space inside the string part and have it parsed correctly.

1 Like

thanks for the answer, sadly in a built input using + with a path and string fails

so

buildInputs = [
/Applications/foo/White + " Space.app/lib/Content"
]

fails with

error: syntax error, unexpected ‘+’

You would think Nix would recognize a space in a built input or use bash escaping, but neither solution works for me.

You’ll need parens around it to keep it from being interpreted as multiple list elements.

Like so:

buildInputs = [
  (/Applications/foo + "/White Space.app/lib/Content")
];

you should also be able to do this

/Applications/foo/${"White Space.app"}/lib/Content
1 Like