Cannot run basic shell using writeShellScriptBin

I did not find the answer here, sorry if I missed it.

(This is done using Home-Manager)

I don’t understand why this works:

(pkgs.writeShellScriptBin "myscript" ''
   #!/usr/bin/env bash
   echo "hello"

but the same content in a file loaded by:

(pkgs.writeShellScriptBin "myscript1" ./bash/

produces a
/nix/store/ Permission denied

I suspect it happens because the file is created as

74099114 -r--r--r-- 1 0 0 36  1 janv.  1970 /nix/store/

So, how to make it executable automatically?


1 Like

./bash/ is a path, which gets turned into a string /nix/store/, it is permission denied probably because the file is not executable. I think you might be looking for (pkgs.writeShellScriptBin "myscript1" (builtins.readFile ./bash/

1 Like

Exactly - Thank you !

1 Like