summaryrefslogtreecommitdiff
path: root/modules/services/lorri.nix
blob: 0c12300434aab664bc9bfff304c31ec0b9c835b3 (plain)
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
44
45
46
{ config, lib, pkgs, ... }:

with lib;

let
  cfg = config.services.lorri;
in
{
  options =  {
    services.lorri = {
      enable = mkOption {
        type = types.bool;
        default = false;
        description = "Whether to enable the lorri service.";
      };
      
      logFile = mkOption {
        type = types.nullOr types.path;
        default = null;
        example =  "/var/tmp/lorri.log";
        description = ''
          The logfile to use for the lorri service. Alternatively
          {command}`sudo launchctl debug system/org.nixos.lorri --stderr`
          can be used to stream the logs to a shell after restarting the service with
          {command}`sudo launchctl kickstart -k system/org.nixos.lorri`.
        '';
      };
    };
  };

  config = mkIf cfg.enable {
    environment.systemPackages = [ pkgs.lorri ];
    launchd.user.agents.lorri = {
      command = with pkgs; "${lorri}/bin/lorri daemon";
      path = with pkgs; [ config.nix.package git gnutar gzip ];
      serviceConfig = {
        KeepAlive = true;
        RunAtLoad = true;
        ProcessType = "Background";
        StandardOutPath = cfg.logFile;
        StandardErrorPath = cfg.logFile;
        EnvironmentVariables = { NIX_PATH = "nixpkgs=" + toString pkgs.path; };
      };
    };
  };
}