diff --git a/modules/module-list.nix b/modules/module-list.nix
index 52b987d65..6375ea38b 100644
--- a/modules/module-list.nix
+++ b/modules/module-list.nix
@@ -43,6 +43,7 @@
./services/emacs.nix
./services/khd
./services/kwm
+ ./services/lorri.nix
./services/mail/offlineimap.nix
./services/mopidy.nix
./services/nix-daemon.nix
diff --git a/modules/services/lorri.nix b/modules/services/lorri.nix
new file mode 100644
index 000000000..354bcf44a
--- /dev/null
+++ b/modules/services/lorri.nix
@@ -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
+ sudo launchctl debug system/org.nixos.lorri --stderr
+ can be used to stream the logs to a shell after restarting the service with
+ sudo launchctl kickstart -k system/org.nixos.lorri.
+ '';
+ };
+ };
+ };
+
+ 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; };
+ };
+ };
+ };
+}
\ No newline at end of file
diff --git a/release.nix b/release.nix
index 77eff1961..750510dcf 100644
--- a/release.nix
+++ b/release.nix
@@ -113,6 +113,7 @@ let
tests.services-activate-system = makeTest ./tests/services-activate-system.nix;
tests.services-activate-system-changed-label-prefix = makeTest ./tests/services-activate-system-changed-label-prefix.nix;
tests.services-buildkite-agent = makeTest ./tests/services-buildkite-agent.nix;
+ tests.services-lorri = makeTest ./tests/services-lorri.nix;
tests.services-nix-daemon = makeTest ./tests/services-nix-daemon.nix;
tests.sockets-nix-daemon = makeTest ./tests/sockets-nix-daemon.nix;
tests.services-dnsmasq = makeTest ./tests/services-dnsmasq.nix;
diff --git a/tests/services-lorri.nix b/tests/services-lorri.nix
new file mode 100644
index 000000000..f66c16f02
--- /dev/null
+++ b/tests/services-lorri.nix
@@ -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} ];
+ '';
+}
+