diff --git a/modules/services/lorri.nix b/modules/services/lorri.nix index 142f5748..9e2dfd6c 100644 --- a/modules/services/lorri.nix +++ b/modules/services/lorri.nix @@ -4,56 +4,43 @@ with lib; let cfg = config.services.lorri; + home = "${builtins.getEnv "HOME"}"; in { - options = { - services.lorri.enable = mkOption { - type = types.bool; - default = false; - description = "Whether to enable the lorri service."; - }; + options = { + services.lorri = { + enable = mkOption { + type = types.bool; + default = false; + description = "Whether to enable the lorri service."; + }; - services.lorri.package = mkOption { - type = types.path; - default = pkgs.lorri; - defaultText = "pkgs.lorri"; - description = "This option specifies the lorri package to use."; - }; - - services.lorri.logFile = mkOption { - type = types.nullOr types.path; - default = "/var/tmp/lorri.log"; - 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. - ''; - }; - - services.lorri.tempDir = mkOption { - type = types.nullOr types.path; - default = null; - description = "The TMPDIR to use for lorri."; + logFile = mkOption { + type = types.nullOr types.path; + default = "${home}/Library/Logs/lorri.log"; + example = "${home}/Library/Logs/lorri.log"; + description = '' + The logfile to use for the lorri service. Alternatively + sudo launchctl debug system/com.target.lorri --stderr + can be used to stream the logs to a shell after restarting the service with + sudo launchctl kickstart -k system/com.target.lorri. + ''; + }; }; }; config = mkIf cfg.enable { - environment.systemPackages = [ cfg.package ]; + environment.systemPackages = [ pkgs.lorri ]; launchd.user.agents.lorri = { serviceConfig = { + Label = "com.target.lorri"; + ProgramArguments = with pkgs; ["${zsh}/bin/zsh" "-c" "${lorri}/bin/lorri daemon"]; KeepAlive = true; + RunAtLoad = true; ProcessType = "Background"; - LowPriorityIO = false; StandardOutPath = cfg.logFile; StandardErrorPath = cfg.logFile; - EnvironmentVariables = mkMerge [ - config.nix.envVars - { TMPDIR = mkIf (cfg.tempDir != null) cfg.tempDir; } - ]; }; - command = "${cfg.package}/bin/lorri daemon"; }; }; } \ No newline at end of file diff --git a/tests/services-lorri.nix b/tests/services-lorri.nix index e70eef5d..d6a9935c 100644 --- a/tests/services-lorri.nix +++ b/tests/services-lorri.nix @@ -2,17 +2,21 @@ let 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 { services.lorri.enable = true; - nix.package = nix; + nix.package = pkgs.nix; test = '' echo checking lorri service in /Library/LaunchAgents >&2 - cat ${plistPath} grep -o "KeepAlive" ${plistPath} - grep -o "org.nixos.lorri" ${plistPath} - grep -o "exec ${pkgs.lorri}/bin/lorri daemon" ${plistPath} + grep -o "RunAtLoad" ${plistPath} + grep -o "ProcessType" ${plistPath} + grep -o "Background" ${plistPath} + grep -o "com.target.lorri" ${plistPath} + grep -o "${pkgs.zsh}/bin/zsh" ${plistPath} + grep -o "-c" ${plistPath} + grep -o "${pkgs.lorri}/bin/lorri daemon" ${plistPath} ''; }