This guide shows you how to run lorri daemon
as a service.
If you are using NixOS or home-manager
on Linux with a Nixpkgs channel at
least as recent as nixos-19.09
, you have it easy: see Setup on NixOS or with
home-manager
on Linux. Otherwise, read on.
The exact steps depend on your operating system and general setup. Currently, we have instructions for these setups:
Here we'll set up a systemd socket and service file manually.
What's the purpose of the systemd socket? How does systemd know when to start the daemon "on demand"?
lorri clients, like the `direnv` integration, talk to the daemon via a Unix socket at a well-known location. [`lorri.socket`] tells systemd to start the systemd service defined in [`lorri.service`] the first time a client attempts to connect to this socket.
If your lorri
binary is not in ~/.nix-profile/bin/lorri
, please change the
ExecStart=
setting in lorri.service
to the correct location.
Install lorri.socket
and lorri.service
and make systemd listen on the
daemon socket:
$ mkdir -p ~/.config/systemd/user && \
cp contrib/lorri.{socket,service} ~/.config/systemd/user/ && \
systemctl --user daemon-reload && \
systemctl --user enable --now lorri.socket
The lorri daemon will now be started on demand by systemd. See Verify the setup to check that everything works as expected.
This approach uses macOS's launchd, which is used to manage launch daemons.
- write the following
plist
file to~/Library/LaunchAgents/nix.lorri.plist
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>Label</key>
<string>nix.lorri</string>
<key>ProgramArguments</key>
<array>
<string>lorri</string>
<string>daemon</string>
</array>
</dict>
</plist>
- run
launchctl load -w ~/Library/LaunchAgents/nix.lorri.plist
Alternatively, one can reference the above launchd
documentation or use a tool like https://launched.zerowidth.com to easily create a launchd
plist
file.
Run lorri daemon
on macOS with Nix (using nix-darwin)
The following user contributions should help you get started:
In this section, we'll see how to check that the lorri daemon
setup actually
works as intended.
On a systemd-based system, you should get the following:
$ systemctl --user is-enabled lorri.socket
enabled
$ systemctl --user is-active lorri.socket
active
On macOS, use this command to check the status of the lorri daemon:
$ launchctl list | grep lorri