[Nix-dev] Running nix-shell commands as cron jobs

Joachim Schiele js at lastlog.de
Thu Oct 8 12:40:40 CEST 2015


write a wrapper-script like this below:

#!/run/current-system/sw/bin/bash
source /etc/profile

nix-shell --pure -p python3 -p python3Packages.requests2 --run
./my-script.py

====
two options from here:
* but as domen already said, maybe you generate your own 'program' as a
store entry
* or you make the nix-shell persistent, see what is written here
https://nixos.org/wiki/Development_Environments#Making_a_Persistent_nix-shell_Environment

warning: if you use nix-shell as you are doing right now, everytime you
do a "nix-channel --upgrade" you might run into a situation where
nix-shell breaks for some weird reason as packages got renamed and such.
so either create your own package or make the nix-shell persistent

On 07.10.2015 22:06, Anders Lundstedt wrote:
> A python script I have depends on the requests2 package. I can run the
> script using
> 
> nix-shell --pure -p python3 -p python3Packages.requests2 --run ./my-script.py
> 
> 
> However when putting this line as a cron job I get the cron output:
> 
> error: Nix database directory ‘/nix/var/nix/db’ is not writable:
> Permission denied
> 
> 
> What solutions are there to run a simple script with dependencies as a
> cron job, other than to add the script as a package?
> _______________________________________________
> nix-dev mailing list
> nix-dev at lists.science.uu.nl
> http://lists.science.uu.nl/mailman/listinfo/nix-dev
> 




More information about the nix-dev mailing list