nix-config/home/dav/davsync.nix

23 lines
700 B
Nix
Raw Normal View History

2022-01-18 09:32:55 +01:00
{ config, pkgs, contacts, addressbook, ... }:
let
shell = "${pkgs.dash}/bin/dash";
vdirsyncer = "${pkgs.vdirsyncer}/bin/vdirsyncer";
mkdir = "${pkgs.coreutils}/bin/mkdir";
cat = "${pkgs.coreutils}/bin/cat";
abook = "${pkgs.abook}/bin/abook";
dirname = "${pkgs.coreutils}/bin/dirname";
in
pkgs.writeScriptBin "davsync" ''
#!${shell}
${vdirsyncer} discover && \
${vdirsyncer} sync && \
${mkdir} -p "$(${dirname} ${addressbook})" && \
${cat} "${contacts}"/*/*/* | \
${abook} \
--convert \
--informat vcard \
--outformat abook > \
"${config.home.homeDirectory}/.abook/adressbook"
''