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

Bjørn Forsman bjorn.forsman at gmail.com
Thu Oct 8 15:07:24 CEST 2015


On 8 October 2015 at 14:48, Eelco Dolstra <eelco.dolstra at logicblox.com> wrote:
> 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";
>     };

Right :-)

But don't forget that NIX_REMOTE isn't part of
config.environment.sessionVariables. (Should it have been?)

- Bjørn


More information about the nix-dev mailing list