about summary refs log tree commit diff
path: root/nixos/modules/services/networking/jotta-cli.nix
blob: c7e6dad5453ca01e194a32e5164bffebfb9d14cc (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
{ config, lib, pkgs, ... }:

with lib;

let cfg = config.user.services.jotta-cli;
in {
  options = {
    user.services.jotta-cli = {

      enable = mkEnableOption "Jottacloud Command-line Tool";

      options = mkOption {
        default = [ "stdoutlog" "datadir" "%h/.jottad/" ];
        example = [ ];
        type = with types; listOf str;
        description = "Command-line options passed to jottad.";
      };

      package = lib.mkPackageOption pkgs "jotta-cli" { };
    };
  };
  config = mkIf cfg.enable {
    systemd.user.services.jottad = {

      description = "Jottacloud Command-line Tool daemon";

      serviceConfig = {
        Type = "notify";
        EnvironmentFile = "-%h/.config/jotta-cli/jotta-cli.env";
        ExecStart = "${lib.getExe' cfg.package "jottad"} ${concatStringsSep " " cfg.options}";
        Restart = "on-failure";
      };

      wantedBy = [ "default.target" ];
      wants = [ "network-online.target" ];
      after = [ "network-online.target" ];
    };
    environment.systemPackages = [ pkgs.jotta-cli ];
  };

  meta.maintainers = with lib.maintainers; [ evenbrenden ];
  meta.doc = ./jotta-cli.md;
}