( and ) causes syntax error

Hi everyone . İ tried to create mini script on @NobbZ 's script. But it includes ( ) these symbols for python. So i fail. How to solve it. İ tried to add it from configuration.nix and its writeShellScriptBin. İt gets error on os.system

You’re using writeShellScriptBin, which IIRC runs a syntax check on the script. If you’re going to put Python in it, you probably want to use writeScriptBin.


Not just that, it also puts a shebang in the file for you. Which means your script will look like this:

<some python code>

So even if there were no syntax checking, you’ll end up with a python script executed by bash.

If you want a python script, may I suggest writePython3Bin, which does what writeShellScriptBin does but for python? E.g.:

pkgs.writers.writePython3Bin "python-test" {} ''
  import os

  os.system("${libnotify}/bin/notify-send test")

The others already said how to fix the problem, though please in the future also:

  1. Do not paste screenshots of code, but use triple-backticks and paste in actual code, like this:
    (writeShellScriptBin "name" ''
  2. Also please always also paste the actual error message you get, it is much easier to tell you what the problem is.