2019-11-08 17:18:03 +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-06 16:04:31 +00:00
|
|
|
package = lib.mkOption {
|
|
|
|
default = pkgs.lorri;
|
|
|
|
type = lib.types.package;
|
|
|
|
description = ''
|
|
|
|
The lorri package to use.
|
|
|
|
'';
|
2021-10-03 16:06:03 +00:00
|
|
|
defaultText = lib.literalExpression "pkgs.lorri";
|
2020-09-06 16:04:31 +00:00
|
|
|
};
|
2019-11-08 17:18:03 +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" ];
|
2019-12-16 09:09:59 +00:00
|
|
|
path = with pkgs; [ config.nix.package git gnutar gzip ];
|
2019-11-08 17:18:03 +00:00
|
|
|
serviceConfig = {
|
2020-09-06 16:04:31 +00:00
|
|
|
ExecStart = "${cfg.package}/bin/lorri daemon";
|
2019-11-08 17:18:03 +00:00
|
|
|
PrivateTmp = true;
|
2023-12-13 02:34:58 +00:00
|
|
|
ProtectSystem = "full";
|
2019-11-08 17:18:03 +00:00
|
|
|
Restart = "on-failure";
|
|
|
|
};
|
|
|
|
};
|
2019-11-15 15:41:00 +00:00
|
|
|
|
2023-04-14 13:18:56 +00:00
|
|
|
environment.systemPackages = [ cfg.package pkgs.direnv ];
|
2019-11-08 17:18:03 +00:00
|
|
|
};
|
|
|
|
}
|