8 cfg = config.services.onedrive;
10 onedriveLauncher = pkgs.writeShellScriptBin "onedrive-launcher" ''
11 # XDG_CONFIG_HOME is not recognized in the environment here.
12 if [ -f $HOME/.config/onedrive-launcher ]
14 # Hopefully using underscore boundary helps locate variables
15 for _onedrive_config_dirname_ in $(cat $HOME/.config/onedrive-launcher | grep -v '[ \t]*#' )
17 systemctl --user start onedrive@$_onedrive_config_dirname_
20 systemctl --user start onedrive@onedrive
27 # meta.doc = ./onedrive.xml;
31 options.services.onedrive = {
32 enable = lib.mkEnableOption "OneDrive service";
34 package = lib.mkOption {
35 type = lib.types.package;
36 default = pkgs.onedrive;
37 defaultText = lib.literalExpression "pkgs.onedrive";
39 OneDrive package to use.
45 config = lib.mkIf cfg.enable {
46 environment.systemPackages = [ cfg.package ];
48 systemd.user.services."onedrive@" = {
49 description = "Onedrive sync service";
54 ${cfg.package}/bin/onedrive --monitor --confdir=%h/.config/%i
56 Restart = "on-failure";
58 RestartPreventExitStatus = 3;
62 systemd.user.services.onedrive-launcher = {
63 wantedBy = [ "default.target" ];
66 ExecStart = "${onedriveLauncher}/bin/onedrive-launcher";