home-manager icon indicating copy to clipboard operation
home-manager copied to clipboard

Atuin daemon option

Open SolidRhino opened this issue 1 year ago • 4 comments

Description

Add an option to manage the Atuin daemon with a user service.

daemon

SolidRhino avatar Sep 03 '24 07:09 SolidRhino

Here's the nix-darwin config I used to start the daemon:

launchd.user.agents.atuin = {
  command = "${pkgs.atuin}/bin/atuin daemon";
  serviceConfig = {
    RunAtLoad = true;
    StandardOutPath = "/tmp/atuin.log";
  };
};

opeik avatar Sep 19 '24 06:09 opeik

The following (via atuinsh/atuin#2039) uses the daemon feature. This ought to be supported in the linux version.

https://github.com/Nemo157/dotfiles/blob/a470d7f442b2ba584d5462f6d5581264ccbaec49/home/cli/atuin.nix#L51-L83

  systemd.user.services.atuin-daemon = {
    Unit = {
      Description = "atuin shell history daemon";
      Requires = [ "atuin-daemon.socket" ];
    };
    Service = {
      ExecStart = "${lib.getExe pkgs.atuin} daemon";
      Environment = [ "ATUIN_LOG=info" ];
      Restart = "on-failure";
      RestartSteps = 5;
      RestartMaxDelaySec = 10;
    };
    Install = {
      Also = [ "atuin-daemon.socket" ];
      WantedBy = [ "default.target" ];
    };
  };


  systemd.user.sockets.atuin-daemon = {
    Unit = {
      Description = "Unix socket activation for atuin shell history daemon";
    };


    Socket = {
      ListenStream = "%t/atuin.socket";
      SocketMode = "0600";
      RemoveOnStop = true;
    };


    Install = {
      WantedBy = [ "sockets.target" ];
    };
  };

The settings.daemon configuration needs this, too.

  socket_path = "/run/user/1000/atuin.socket";
  systemd_socket = true;

I'm about to test: if it's fine, I can contribute.

dbaynard avatar Oct 03 '24 01:10 dbaynard

Oh man I didn't see this, I just made a PR! #5946, it's pretty similar to your implementation though @dbaynard.

water-sucks avatar Oct 08 '24 20:10 water-sucks

Ah, not my implementation but I figured I'd make the link. Glad it's similar!

I haven't tested a launchd variant, yet.

dbaynard avatar Oct 08 '24 23:10 dbaynard