aboutsummaryrefslogtreecommitdiff
path: root/home-manager/modules/services/lorri.nix
blob: 6183699088b3d6e48965feb4d98c121e4424073f (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
47
48
49
50
51
52
53
54
55
56
57
58
59
60
{ config, lib, pkgs, ... }:

with lib;

let

  cfg = config.services.lorri;

in {
  meta.maintainers = [ maintainers.gerschtli ];

  options.services.lorri = {
    enable = mkEnableOption "lorri build daemon";

    package = mkOption {
      type = types.package;
      default = pkgs.lorri;
      defaultText = literalExample "pkgs.lorri";
      description = "Which lorri package to install.";
    };
  };

  config = mkIf cfg.enable {
    home.packages = [ cfg.package ];

    systemd.user = {
      services.lorri = {
        Unit = {
          Description = "lorri build daemon";
          Requires = "lorri.socket";
          After = "lorri.socket";
          RefuseManualStart = true;
        };

        Service = {
          ExecStart = "${cfg.package}/bin/lorri daemon";
          PrivateTmp = true;
          ProtectSystem = "strict";
          ProtectHome = "read-only";
          Restart = "on-failure";
          Environment = let
            path = with pkgs;
              makeSearchPath "bin" [ nix gitMinimal gnutar gzip ];
          in [ "PATH=${path}" ];
        };
      };

      sockets.lorri = {
        Unit = { Description = "Socket for lorri build daemon"; };

        Socket = {
          ListenStream = "%t/lorri/daemon.socket";
          RuntimeDirectory = "lorri";
        };

        Install = { WantedBy = [ "sockets.target" ]; };
      };
    };
  };
}