1 { config, lib, pkgs, ... }:
3 cfg = config.services.onedrive;
5 onedriveLauncher = pkgs.writeShellScriptBin
8 # XDG_CONFIG_HOME is not recognized in the environment here.
9 if [ -f $HOME/.config/onedrive-launcher ]
11 # Hopefully using underscore boundary helps locate variables
12 for _onedrive_config_dirname_ in $(cat $HOME/.config/onedrive-launcher | grep -v '[ \t]*#' )
14 systemctl --user start onedrive@$_onedrive_config_dirname_
17 systemctl --user start onedrive@onedrive
24 # meta.doc = ./onedrive.xml;
28 options.services.onedrive = {
29 enable = lib.mkEnableOption (lib.mdDoc "OneDrive service");
31 package = lib.mkOption {
32 type = lib.types.package;
33 default = pkgs.onedrive;
34 defaultText = lib.literalExpression "pkgs.onedrive";
35 description = lib.mdDoc ''
36 OneDrive package to use.
42 config = lib.mkIf cfg.enable {
43 environment.systemPackages = [ cfg.package ];
45 systemd.user.services."onedrive@" = {
46 description = "Onedrive sync service";
51 ${cfg.package}/bin/onedrive --monitor --confdir=%h/.config/%i
55 RestartPreventExitStatus=3;
59 systemd.user.services.onedrive-launcher = {
60 wantedBy = [ "default.target" ];
63 ExecStart = "${onedriveLauncher}/bin/onedrive-launcher";