[Nix-dev] environment in systemd services

Arnold Krille arnold at arnoldarts.de
Sat Jan 30 14:20:47 CET 2016


Hi all,

yes, its the first time I am writing on this list.

I am trying to get duply/duplicity to run. When I execute `duply amazon
backup` in a root shell, all is well. But I want it to be run regularly
by systemd. So I created a service:

```
systemd.services.duplyamazon =
  {
    path = [ pkgs.duply ];
    environment = { LANG = "C"; HOME="/root"; TMPDIR="/tmp"; }; 
    script = "duply amazon status"; 
    startAt = "Sat 4:10:00";
  }; 
```

But when I run that (either by the timer or by `systemctl start
duplyamazon`, it fails with very strange python backtrace:

```
Jan 30 14:10:08 portal duplyamazon-start[47296]: Using temporary
directory /tmp/duplicity-b53bV9-tempdir Jan 30 14:10:08 portal
duplyamazon-start[47296]: Backend error detail: Traceback (most recent
call last): Jan 30 14:10:08 portal duplyamazon-start[47296]: File
"/nix/store/ap2bv0p5m8napigg7f6yciap4nm61ap8-duplicity-0.7.02/bin/.duplicity-wrapped",
line 1519, in <module> Jan 30 14:10:08 portal duplyamazon-start[47296]:
with_tempdir(main) Jan 30 14:10:08 portal duplyamazon-start[47296]:
File
"/nix/store/ap2bv0p5m8napigg7f6yciap4nm61ap8-duplicity-0.7.02/bin/.duplicity-wrapped",
line 1513, in with_tempdir Jan 30 14:10:08 portal
duplyamazon-start[47296]: fn() Jan 30 14:10:08 portal
duplyamazon-start[47296]: File
"/nix/store/ap2bv0p5m8napigg7f6yciap4nm61ap8-duplicity-0.7.02/bin/.duplicity-wrapped",
line 1354, in main Jan 30 14:10:08 portal duplyamazon-start[47296]:
action = commandline.ProcessCommandLine(sys.argv[1:]) Jan 30 14:10:08
portal duplyamazon-start[47296]: File
"/nix/store/ap2bv0p5m8napigg7f6yciap4nm61ap8-duplicity-0.7.02/lib/python2.7/site-packages/duplicity/commandline.py",
line 1062, in ProcessCommandLine Jan 30 14:10:08 portal
duplyamazon-start[47296]: globals.backend =
backend.get_backend(args[0]) Jan 30 14:10:08 portal
duplyamazon-start[47296]: File
"/nix/store/ap2bv0p5m8napigg7f6yciap4nm61ap8-duplicity-0.7.02/lib/python2.7/site-packages/duplicity/backend.py",
line 223, in get_backend Jan 30 14:10:08 portal
duplyamazon-start[47296]: obj = get_backend_object(url_string) Jan 30
14:10:08 portal duplyamazon-start[47296]: File
"/nix/store/ap2bv0p5m8napigg7f6yciap4nm61ap8-duplicity-0.7.02/lib/python2.7/site-packages/duplicity/backend.py",
line 209, in get_backend_object Jan 30 14:10:08 portal
duplyamazon-start[47296]: return factory(pu) Jan 30 14:10:08 portal
duplyamazon-start[47296]: File
"/nix/store/ap2bv0p5m8napigg7f6yciap4nm61ap8-duplicity-0.7.02/lib/python2.7/site-packages/duplicity/backends/_boto_single.py",
line 161, in __init__ Jan 30 14:10:08 portal duplyamazon-start[47296]:
self.resetConnection() Jan 30 14:10:08 portal duplyamazon-start[47296]:
File
"/nix/store/ap2bv0p5m8napigg7f6yciap4nm61ap8-duplicity-0.7.02/lib/python2.7/site-packages/duplicity/backends/_boto_single.py",
line 187, in resetConnection Jan 30 14:10:08 portal
duplyamazon-start[47296]: raise BackendException(err.message) Jan 30
14:10:08 portal duplyamazon-start[47296]: BackendException Jan 30
14:10:08 portal duplyamazon-start[47296]: BackendException: Jan 30
14:10:08 portal duplyamazon-start[47296]: 14:10:08.191 Task 'STATUS'
failed with exit code '23'.
```

I think its either because it can not access the tmpdir or because it
can not access the network. And I don't know whether that is because of
some missing environment variables or because of how systemd services
have to be configured.

Can anyone try to point me in the right direction?

Thanks in advance,

Arnold


Background: I am currently setting up a new homeserver with NixOS and
therefore I am moving all the currently running services of my ubuntu
based homeserver. Expect more questions from me in the next weeks… ;-)
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 230 bytes
Desc: not available
Url : http://lists.science.uu.nl/pipermail/nix-dev/attachments/20160130/0777bd68/attachment.bin 


More information about the nix-dev mailing list