Skip to content

Commit

Permalink
Disable StandardOutPath by default and refactor test to using plutil
Browse files Browse the repository at this point in the history
  • Loading branch information
Thibault Gagnaux committed Aug 31, 2020
1 parent 798fc52 commit 1dbe3b7
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 14 deletions.
2 changes: 1 addition & 1 deletion modules/services/lorri.nix
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
37 changes: 24 additions & 13 deletions tests/services-lorri.nix
Original file line number Diff line number Diff line change
Expand Up @@ -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} ];
'';
}

0 comments on commit 1dbe3b7

Please sign in to comment.