2019-11-16 22:05:08 +01:00
|
|
|
{ config, lib, pkgs, ... }:
|
|
|
|
|
|
|
|
with lib;
|
|
|
|
|
|
|
|
let
|
|
|
|
|
|
|
|
cfg = config.services.lorri;
|
|
|
|
|
2020-02-02 00:39:17 +01:00
|
|
|
in {
|
2019-11-16 22:05:08 +01:00
|
|
|
meta.maintainers = [ maintainers.gerschtli ];
|
|
|
|
|
2020-04-16 01:06:47 +02:00
|
|
|
options.services.lorri = {
|
|
|
|
enable = mkEnableOption "lorri build daemon";
|
|
|
|
|
|
|
|
package = mkOption {
|
|
|
|
type = types.package;
|
|
|
|
default = pkgs.lorri;
|
2021-10-09 11:14:08 +02:00
|
|
|
defaultText = literalExpression "pkgs.lorri";
|
2020-04-16 01:06:47 +02:00
|
|
|
description = "Which lorri package to install.";
|
|
|
|
};
|
|
|
|
};
|
2019-11-16 22:05:08 +01:00
|
|
|
|
|
|
|
config = mkIf cfg.enable {
|
2021-07-07 23:24:27 +02:00
|
|
|
assertions = [
|
|
|
|
(lib.hm.assertions.assertPlatform "services.lorri" pkgs
|
|
|
|
lib.platforms.linux)
|
|
|
|
];
|
|
|
|
|
2020-04-16 01:06:47 +02:00
|
|
|
home.packages = [ cfg.package ];
|
2019-11-16 22:05:08 +01:00
|
|
|
|
|
|
|
systemd.user = {
|
|
|
|
services.lorri = {
|
|
|
|
Unit = {
|
|
|
|
Description = "lorri build daemon";
|
|
|
|
Requires = "lorri.socket";
|
|
|
|
After = "lorri.socket";
|
|
|
|
RefuseManualStart = true;
|
|
|
|
};
|
|
|
|
|
|
|
|
Service = {
|
2020-04-16 01:06:47 +02:00
|
|
|
ExecStart = "${cfg.package}/bin/lorri daemon";
|
2019-11-16 22:05:08 +01:00
|
|
|
PrivateTmp = true;
|
|
|
|
ProtectSystem = "strict";
|
|
|
|
ProtectHome = "read-only";
|
|
|
|
Restart = "on-failure";
|
2020-02-02 00:39:17 +01:00
|
|
|
Environment = let
|
|
|
|
path = with pkgs;
|
|
|
|
makeSearchPath "bin" [ nix gitMinimal gnutar gzip ];
|
2020-05-24 12:19:39 +02:00
|
|
|
in [ "PATH=${path}" ];
|
2019-11-16 22:05:08 +01:00
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
sockets.lorri = {
|
2020-02-02 00:39:17 +01:00
|
|
|
Unit = { Description = "Socket for lorri build daemon"; };
|
2019-11-16 22:05:08 +01:00
|
|
|
|
|
|
|
Socket = {
|
|
|
|
ListenStream = "%t/lorri/daemon.socket";
|
|
|
|
RuntimeDirectory = "lorri";
|
|
|
|
};
|
|
|
|
|
2020-02-02 00:39:17 +01:00
|
|
|
Install = { WantedBy = [ "sockets.target" ]; };
|
2019-11-16 22:05:08 +01:00
|
|
|
};
|
|
|
|
};
|
|
|
|
};
|
|
|
|
}
|