1
0
Fork 0
mirror of https://github.com/LnL7/nix-darwin.git synced 2024-12-14 11:57:34 +00:00

Makes it work.

This commit is contained in:
Thibault Gagnaux 2020-08-29 16:32:49 +02:00
parent 11413f94b2
commit 30593350fd
2 changed files with 32 additions and 41 deletions

View file

@ -4,56 +4,43 @@ with lib;
let
cfg = config.services.lorri;
home = "${builtins.getEnv "HOME"}";
in
{
options = {
services.lorri.enable = mkOption {
type = types.bool;
default = false;
description = "Whether to enable the lorri service.";
};
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.";
logFile = mkOption {
type = types.nullOr types.path;
default = "${home}/Library/Logs/lorri.log";
example = "${home}/Library/Logs/lorri.log";
description = ''
The logfile to use for the lorri service. Alternatively
<command>sudo launchctl debug system/com.target.lorri --stderr</command>
can be used to stream the logs to a shell after restarting the service with
<command>sudo launchctl kickstart -k system/com.target.lorri</command>.
'';
};
};
};
config = mkIf cfg.enable {
environment.systemPackages = [ cfg.package ];
environment.systemPackages = [ pkgs.lorri ];
launchd.user.agents.lorri = {
serviceConfig = {
Label = "com.target.lorri";
ProgramArguments = with pkgs; ["${zsh}/bin/zsh" "-c" "${lorri}/bin/lorri daemon"];
KeepAlive = true;
RunAtLoad = 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

@ -2,17 +2,21 @@
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";
plistPath = "${config.out}/user/Library/LaunchAgents/com.target.lorri.plist";
in
{
services.lorri.enable = true;
nix.package = nix;
nix.package = pkgs.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}
grep -o "<key>RunAtLoad</key>" ${plistPath}
grep -o "<key>ProcessType</key>" ${plistPath}
grep -o "<string>Background</string>" ${plistPath}
grep -o "<string>com.target.lorri</string>" ${plistPath}
grep -o "<string>${pkgs.zsh}/bin/zsh</string>" ${plistPath}
grep -o "<string>-c</string>" ${plistPath}
grep -o "<string>${pkgs.lorri}/bin/lorri daemon</string>" ${plistPath}
'';
}