1
0
Fork 0
mirror of https://github.com/LnL7/nix-darwin.git synced 2025-03-16 13:28:16 +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 let
cfg = config.services.lorri; cfg = config.services.lorri;
home = "${builtins.getEnv "HOME"}";
in in
{ {
options = { options = {
services.lorri.enable = mkOption { services.lorri = {
type = types.bool; enable = mkOption {
default = false; type = types.bool;
description = "Whether to enable the lorri service."; default = false;
}; description = "Whether to enable the lorri service.";
};
services.lorri.package = mkOption { logFile = mkOption {
type = types.path; type = types.nullOr types.path;
default = pkgs.lorri; default = "${home}/Library/Logs/lorri.log";
defaultText = "pkgs.lorri"; example = "${home}/Library/Logs/lorri.log";
description = "This option specifies the lorri package to use."; description = ''
}; The logfile to use for the lorri service. Alternatively
<command>sudo launchctl debug system/com.target.lorri --stderr</command>
services.lorri.logFile = mkOption { can be used to stream the logs to a shell after restarting the service with
type = types.nullOr types.path; <command>sudo launchctl kickstart -k system/com.target.lorri</command>.
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 { config = mkIf cfg.enable {
environment.systemPackages = [ cfg.package ]; environment.systemPackages = [ pkgs.lorri ];
launchd.user.agents.lorri = { launchd.user.agents.lorri = {
serviceConfig = { serviceConfig = {
Label = "com.target.lorri";
ProgramArguments = with pkgs; ["${zsh}/bin/zsh" "-c" "${lorri}/bin/lorri daemon"];
KeepAlive = true; KeepAlive = true;
RunAtLoad = true;
ProcessType = "Background"; ProcessType = "Background";
LowPriorityIO = false;
StandardOutPath = cfg.logFile; StandardOutPath = cfg.logFile;
StandardErrorPath = 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 let
nix = pkgs.runCommand "nix-0.0.0" { version = "1.11.6"; } "mkdir -p $out"; 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 in
{ {
services.lorri.enable = true; services.lorri.enable = true;
nix.package = nix; nix.package = pkgs.nix;
test = '' test = ''
echo checking lorri service in /Library/LaunchAgents >&2 echo checking lorri service in /Library/LaunchAgents >&2
cat ${plistPath}
grep -o "<key>KeepAlive</key>" ${plistPath} grep -o "<key>KeepAlive</key>" ${plistPath}
grep -o "<string>org.nixos.lorri</string>" ${plistPath} grep -o "<key>RunAtLoad</key>" ${plistPath}
grep -o "<string>exec ${pkgs.lorri}/bin/lorri daemon</string>" ${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}
''; '';
} }