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

Eelco Dolstra eelco.dolstra at logicblox.com
Thu Oct 8 14:48:36 CEST 2015


Hi,

On 08/10/15 09:23, Bjørn Forsman wrote:

> On 8 October 2015 at 09:18, Domen Kožar <domen at dev.si> wrote:
>> It's easier to generate a package that wraps the script binary and then use
>> it in a cronjob
> 
> Or just "nix-shell ... --run "NIX_REMOTE=daemon ./my-script.py"?

Surely that should be "NIX_REMOTE=daemon NIX_PATH=... nix-shell -p ...".
Otherwise you're setting the environment variable too late, and you need
NIX_PATH for the -p flag to work.

Even better is using a systemd timer instead of a cronjob, e.g.

  systemd.services.foo =
    { script = "nix-shell -p ...";
      environment = config.environment.sessionVariables;
      startAt = "12:34";
    };

-- 
Eelco Dolstra | LogicBlox, Inc. | http://nixos.org/~eelco/


More information about the nix-dev mailing list