-
-
Notifications
You must be signed in to change notification settings - Fork 475
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #222 from tricktron/lorri
Adds Lorri module
- Loading branch information
Showing
4 changed files
with
83 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
{ 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."; | ||
}; | ||
|
||
logFile = mkOption { | ||
type = types.nullOr types.path; | ||
default = null; | ||
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>. | ||
''; | ||
}; | ||
}; | ||
}; | ||
|
||
config = mkIf cfg.enable { | ||
environment.systemPackages = [ pkgs.lorri ]; | ||
launchd.user.agents.lorri = { | ||
command = with pkgs; "${lorri}/bin/lorri daemon"; | ||
path = with pkgs; [ nix ]; | ||
serviceConfig = { | ||
KeepAlive = true; | ||
RunAtLoad = true; | ||
ProcessType = "Background"; | ||
StandardOutPath = cfg.logFile; | ||
StandardErrorPath = cfg.logFile; | ||
EnvironmentVariables = { NIX_PATH = "nixpkgs=" + toString pkgs.path; }; | ||
}; | ||
}; | ||
}; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
{ config, pkgs, ... }: | ||
|
||
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 = '' | ||
${pkgs.xcbuild}/bin/plutil -lint ${plistPath} | ||
[ ${testResult} ]; | ||
''; | ||
} | ||
|