mirror of
https://github.com/NixOS/nixpkgs.git
synced 2024-11-30 19:02:57 +00:00
1c5ca89f42
direnv is required to allow files to be run by lorri, so it should be installed, too.
56 lines
1.5 KiB
Nix
56 lines
1.5 KiB
Nix
{ 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 = lib.mdDoc ''
|
|
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.
|
|
'';
|
|
};
|
|
package = lib.mkOption {
|
|
default = pkgs.lorri;
|
|
type = lib.types.package;
|
|
description = lib.mdDoc ''
|
|
The lorri package to use.
|
|
'';
|
|
defaultText = lib.literalExpression "pkgs.lorri";
|
|
};
|
|
};
|
|
};
|
|
|
|
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 = {
|
|
ExecStart = "${cfg.package}/bin/lorri daemon";
|
|
PrivateTmp = true;
|
|
ProtectSystem = "strict";
|
|
ProtectHome = "read-only";
|
|
Restart = "on-failure";
|
|
};
|
|
};
|
|
|
|
environment.systemPackages = [ cfg.package pkgs.direnv ];
|
|
};
|
|
}
|