Getting the daemon working on NixOS

For future reference:
Atuin 18.4.0 introduced a change to the default location of a socket for the daemon.
It uses the socket /run/user/1000/atuin.sock, if XDG_RUNTIME_DIR is set. Relevant PR:

Without home-manager

Use the above-shown manual service and socket configuration. Ideally, set the socket directory to what Atuin should default to:

-      atuinSockDir = "${config.home.homeDirectory}/.local/share/atuin";
+      atuinSockDir = "%t";

See section Context for additional explanation. If you have problems with the daemon timing out, set timeout times in the Atuin config, e.g. as in section With home-manager,

With home-manager

The daemon on NixOS with Atuin 18.4.0 from the nixpkgs with the home-manager module for Atuin and its daemon works correctly now.

The configuration of the home-manager module for Atuin for the daemon is as follows. (Only, I have a strange issue with connectivity where it takes around 8–15 seconds to connect to the server, which by default times out on a timeout of 5 seconds, so I had to modify the Atuin config accordingly (either as a Nix expression, or an imported TOML value) in the module attribute settings.

# Might not be necessary for you.
network_connect_timeout = 60
network_timeout = 60

[daemon]
enabled = true
systemd_socket = true

Notice that we do not define systemd_path, allowing the home-manager to use the new default of ${XDG_RUNTIME_DIR}/atuin.sock if it is set.

With the h-m configuration:

  programs.atuin = {
    enable = true;
    enableBashIntegration = true;
    enableFishIntegration = true;
    enableZshIntegration = true;
    daemon = {
      enable = true;
    };
    settings = lib.importTOML atuin_config_file.toml;
  };

Context

The previous default location (~/.local/share/atuin/atuin.sock) will not work with h-m as it hardcodes the path for Atuin version 18.4.0+ to %t/atuin.sock which is defined as follows:

The %t specifier in systemd service files represents the runtime directory. It is either /run for the root user or the value of the XDG_RUNTIME_DIR variable for unprivileged users.

1 Like