I recently tried to set up incron in order to monitor a directory and if changes occur, execute a script.
This script uses nix-shell shebangs to declare dependencies:
#!/usr/bin/env nix-shell
#! nix-shell -i bash
...
Incron correctly identifies changes in the directory, but can’t execute the script for some reason. When checking the status, I see the following errors:
Feb 20 23:20:46 nixos incrond[2397]: /usr/bin/env: ‘nix-shell’: No such file or directory
Feb 20 23:20:46 nixos incrond[2396]: cannot exec process: Resource temporarily unavailable
Note that the scripts work perfectly when ran by “hand”.
I apologize if this is an obvious question, I’m new to nixos.
The error suggests that nix-shell isn’t on PATH when it’s running this. I haven’t played with incron, but if you’re using the nixos option to enable it you might need to add pkgs.nix to services.incron.extraPackages
Thanks, but this seems to cause some other issues. I now get the following error:
Feb 21 14:10:10 nixos incrond[1715]: … <borked>
Feb 21 14:10:10 nixos incrond[1715]: at «none»:0: (source not available)
Feb 21 14:10:10 nixos incrond[1715]: … while calling the 'import' builtin
Feb 21 14:10:10 nixos incrond[1715]: at «string»:1:18:
Feb 21 14:10:10 nixos incrond[1715]: 1| {...}@args: with import <nixpkgs> args; (pkgs.runCommandCC or pkgs.runCommand) "shell" { buildInputs = [ (lesspass-cli) (openssl) ( (gawk) ]; } ""
Feb 21 14:10:10 nixos incrond[1715]: | ^
Feb 21 14:10:10 nixos incrond[1715]: (stack trace truncated; use '--show-trace' to show the full trace)
Feb 21 14:10:10 nixos incrond[1715]: error: file 'nixpkgs' was not found in the Nix search path (add it using $NIX_PATH or -I)
Feb 21 14:10:10 nixos incrond[1715]: at «none»:0: (source not available)
Feb 21 14:10:10 nixos incrond[1714]: cannot exec process: Resource temporarily unavailable
Note that my script specifies a valid search path for nixpkgs with the -I option.