1
0
Fork 0
mirror of https://github.com/LnL7/nix-darwin.git synced 2025-03-13 20:30:02 +00:00

Disable StandardOutPath by default and refactor test to using plutil

This commit is contained in:
Thibault Gagnaux 2020-08-31 13:07:06 +02:00
parent 798fc52d12
commit 1dbe3b71e3
2 changed files with 25 additions and 14 deletions

View file

@ -16,7 +16,7 @@ in
logFile = mkOption {
type = types.nullOr types.path;
default = "/var/tmp/lorri.log";
default = null;
example = "/var/tmp/lorri.log";
description = ''
The logfile to use for the lorri service. Alternatively

View file

@ -3,22 +3,33 @@
let
lorri = pkgs.runCommand "lorri-0.0.0" {} "mkdir $out";
plistPath = "${config.out}/user/Library/LaunchAgents/org.nixos.lorri.plist";
actual = pkgs.runCommand "convert-plist-to-json" { buildInputs = [ pkgs.xcbuild ]; }
"plutil -convert json -o $out ${plistPath}";
actualJson = builtins.fromJSON (builtins.readFile "${actual.out}");
expectedJson = builtins.fromJSON ''
{
"EnvironmentVariables": {
"NIX_PATH": "${"nixpkgs="+ toString pkgs.path}",
"PATH": "${builtins.unsafeDiscardStringContext pkgs.nix}/bin"
},
"KeepAlive": true,
"Label": "org.nixos.lorri",
"ProcessType": "Background",
"ProgramArguments": [
"/bin/sh",
"-c",
"exec ${builtins.unsafeDiscardStringContext pkgs.lorri}/bin/lorri daemon"
],
"RunAtLoad": true
}
'';
testResult = toString (actualJson == expectedJson);
in
{
services.lorri.enable = true;
test = ''
echo checking lorri service in /Library/LaunchAgents >&2
grep -o "<key>NIX_PATH</key>" ${plistPath}
grep -o "<key>EnvironmentVariables</key>" ${plistPath}
grep -o "<string>nixpkgs=" ${plistPath}
grep -o "<key>KeepAlive</key>" ${plistPath}
grep -o "<key>RunAtLoad</key>" ${plistPath}
grep -o "<key>ProcessType</key>" ${plistPath}
grep -o "<string>Background</string>" ${plistPath}
grep -o "<string>/bin/sh</string>" ${plistPath}
grep -o "<string>org.nixos.lorri</string>" ${plistPath}
grep -o "<string>-c</string>" ${plistPath}
grep -o "<string>exec ${pkgs.lorri}/bin/lorri daemon</string>" ${plistPath}
${pkgs.xcbuild}/bin/plutil -lint ${plistPath}
[ ${testResult} ];
'';
}