1
1
mirror of https://github.com/LnL7/nix-darwin.git synced 2024-09-11 12:49:18 +03:00

Adds lorri service.

This commit is contained in:
Thibault Gagnaux 2020-05-12 19:20:29 +02:00
parent 943a6b25d7
commit 11413f94b2
4 changed files with 79 additions and 0 deletions

View File

@ -43,6 +43,7 @@
./services/emacs.nix
./services/khd
./services/kwm
./services/lorri.nix
./services/mail/offlineimap.nix
./services/mopidy.nix
./services/nix-daemon.nix

View File

@ -0,0 +1,59 @@
{ config, lib, pkgs, ... }:
with lib;
let
cfg = config.services.lorri;
in
{
options = {
services.lorri.enable = mkOption {
type = types.bool;
default = false;
description = "Whether to enable the lorri service.";
};
services.lorri.package = mkOption {
type = types.path;
default = pkgs.lorri;
defaultText = "pkgs.lorri";
description = "This option specifies the lorri package to use.";
};
services.lorri.logFile = mkOption {
type = types.nullOr types.path;
default = "/var/tmp/lorri.log";
example = "/var/tmp/lorri.log";
description = ''
The logfile to use for the lorri service. Alternatively
<command>sudo launchctl debug system/org.nixos.lorri --stderr</command>
can be used to stream the logs to a shell after restarting the service with
<command>sudo launchctl kickstart -k system/org.nixos.lorri</command>.
'';
};
services.lorri.tempDir = mkOption {
type = types.nullOr types.path;
default = null;
description = "The TMPDIR to use for lorri.";
};
};
config = mkIf cfg.enable {
environment.systemPackages = [ cfg.package ];
launchd.user.agents.lorri = {
serviceConfig = {
KeepAlive = true;
ProcessType = "Background";
LowPriorityIO = false;
StandardOutPath = cfg.logFile;
StandardErrorPath = cfg.logFile;
EnvironmentVariables = mkMerge [
config.nix.envVars
{ TMPDIR = mkIf (cfg.tempDir != null) cfg.tempDir; }
];
};
command = "${cfg.package}/bin/lorri daemon";
};
};
}

View File

@ -113,6 +113,7 @@ let
tests.services-activate-system = makeTest ./tests/services-activate-system.nix;
tests.services-activate-system-changed-label-prefix = makeTest ./tests/services-activate-system-changed-label-prefix.nix;
tests.services-buildkite-agent = makeTest ./tests/services-buildkite-agent.nix;
tests.services-lorri = makeTest ./tests/services-lorri.nix;
tests.services-nix-daemon = makeTest ./tests/services-nix-daemon.nix;
tests.sockets-nix-daemon = makeTest ./tests/sockets-nix-daemon.nix;
tests.services-dnsmasq = makeTest ./tests/services-dnsmasq.nix;

18
tests/services-lorri.nix Normal file
View File

@ -0,0 +1,18 @@
{ config, pkgs, ... }:
let
nix = pkgs.runCommand "nix-0.0.0" { version = "1.11.6"; } "mkdir -p $out";
plistPath = "${config.out}/user/Library/LaunchAgents/org.nixos.lorri.plist";
in
{
services.lorri.enable = true;
nix.package = nix;
test = ''
echo checking lorri service in /Library/LaunchAgents >&2
cat ${plistPath}
grep -o "<key>KeepAlive</key>" ${plistPath}
grep -o "<string>org.nixos.lorri</string>" ${plistPath}
grep -o "<string>exec ${pkgs.lorri}/bin/lorri daemon</string>" ${plistPath}
'';
}