2020-04-24 23:36:52 +00:00
|
|
|
{ config, lib, pkgs, ... }:
|
|
|
|
|
|
|
|
let
|
|
|
|
cfg = config.services.lorri;
|
|
|
|
socketPath = "lorri/daemon.socket";
|
|
|
|
in {
|
|
|
|
options = {
|
|
|
|
services.lorri = {
|
|
|
|
enable = lib.mkOption {
|
|
|
|
default = false;
|
|
|
|
type = lib.types.bool;
|
|
|
|
description = ''
|
|
|
|
Enables the daemon for `lorri`, a nix-shell replacement for project
|
|
|
|
development. The socket-activated daemon starts on the first request
|
|
|
|
issued by the `lorri` command.
|
|
|
|
'';
|
|
|
|
};
|
2020-09-25 04:45:31 +00:00
|
|
|
package = lib.mkOption {
|
|
|
|
default = pkgs.lorri;
|
|
|
|
type = lib.types.package;
|
2022-08-12 12:06:08 +00:00
|
|
|
description = lib.mdDoc ''
|
2020-09-25 04:45:31 +00:00
|
|
|
The lorri package to use.
|
|
|
|
'';
|
2021-10-06 13:57:05 +00:00
|
|
|
defaultText = lib.literalExpression "pkgs.lorri";
|
2020-09-25 04:45:31 +00:00
|
|
|
};
|
2020-04-24 23:36:52 +00:00
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
config = lib.mkIf cfg.enable {
|
|
|
|
systemd.user.sockets.lorri = {
|
|
|
|
description = "Socket for Lorri Daemon";
|
|
|
|
wantedBy = [ "sockets.target" ];
|
|
|
|
socketConfig = {
|
|
|
|
ListenStream = "%t/${socketPath}";
|
|
|
|
RuntimeDirectory = "lorri";
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
systemd.user.services.lorri = {
|
|
|
|
description = "Lorri Daemon";
|
|
|
|
requires = [ "lorri.socket" ];
|
|
|
|
after = [ "lorri.socket" ];
|
|
|
|
path = with pkgs; [ config.nix.package git gnutar gzip ];
|
|
|
|
serviceConfig = {
|
2020-09-25 04:45:31 +00:00
|
|
|
ExecStart = "${cfg.package}/bin/lorri daemon";
|
2020-04-24 23:36:52 +00:00
|
|
|
PrivateTmp = true;
|
|
|
|
ProtectSystem = "strict";
|
|
|
|
ProtectHome = "read-only";
|
|
|
|
Restart = "on-failure";
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
2020-09-25 04:45:31 +00:00
|
|
|
environment.systemPackages = [ cfg.package ];
|
2020-04-24 23:36:52 +00:00
|
|
|
};
|
|
|
|
}
|