diff --git a/docs/start/install/nix.md b/docs/start/install/nix.md index ec4a2ac0a..eb96ee9cf 100644 --- a/docs/start/install/nix.md +++ b/docs/start/install/nix.md @@ -44,9 +44,10 @@ in { Re-apply your home-manager configuration the usual way (e.g. `home-manager switch`). -You will then have an `emanote` command in your profile, and a systemd -user service running a live-preview of your notes. +You will then have an `emanote` command in your profile, and a background +service running a live-preview of your notes (systemd on Linux, launchd on macOS). +On Linux: ```sh $ home-manager switch ... @@ -62,5 +63,14 @@ $ systemctl --user status emanote.service └─1705303 /nix/store/9hj2cwk1jakfws0d1hpwa221kcni3j45-emanote-0.3.12.1/bin/emanote --layers /nix/store/hr7wp1xvqn48b8gy16sdq6k2csrvr8c1-emanote-config;/home/user/notes ``` +On macOS: +```sh +$ home-manager switch +... +$ launchctl list | grep emanote +- 0 org.nix-community.home.emanote +$ tail ~/Library/Logs/emanote.log +``` + [home-manager]: https://nixos.asia/en/home-manager [module]: https://github.com/srid/emanote/blob/master/nix/modules/home/emanote.nix diff --git a/emanote/CHANGELOG.md b/emanote/CHANGELOG.md index e20e960b7..7c67ea24e 100644 --- a/emanote/CHANGELOG.md +++ b/emanote/CHANGELOG.md @@ -7,6 +7,7 @@ - UI revamp (#622) - Dark mode (#605, #617) - Mermaid: add `elk` layout (#618) +- Home Manager module: macOS support via launchd (#623) ## 1.4.0.0 (2025-08-18) diff --git a/nix/modules/home/emanote.nix b/nix/modules/home/emanote.nix index db6e53d08..1d4c1251c 100644 --- a/nix/modules/home/emanote.nix +++ b/nix/modules/home/emanote.nix @@ -100,7 +100,7 @@ in config = lib.mkIf cfg.enable { home.packages = [ cfg.package ]; - systemd.user.services.emanote = { + systemd.user.services.emanote = lib.mkIf pkgs.stdenv.isLinux { Unit = { Description = "Emanote web server"; PartOf = [ cfg.systemdTarget ]; @@ -115,5 +115,23 @@ in ''; }; }; + + launchd.agents.emanote = lib.mkIf pkgs.stdenv.isDarwin { + enable = true; + config = { + ProgramArguments = [ + "${pkgs.lib.getExe cfg.package}" + "--layers" + "${lib.concatStringsSep ";" layers}" + "run" + "--host=${cfg.host}" + "--port=${builtins.toString cfg.port}" + ]; + KeepAlive = true; + RunAtLoad = true; + StandardOutPath = "${config.home.homeDirectory}/Library/Logs/emanote.log"; + StandardErrorPath = "${config.home.homeDirectory}/Library/Logs/emanote.log"; + }; + }; }; }