nix-community / home-manager

Manage a user environment using Nix [maintainer=@rycee]
https://nix-community.github.io/home-manager/
MIT License
7.14k stars 1.85k forks source link

Atuin daemon option #5797

Open SolidRhino opened 2 months ago

SolidRhino commented 2 months ago

Description

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

daemon

opeik commented 2 months ago

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";
  };
};
dbaynard commented 1 month ago

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.

water-sucks commented 1 month ago

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

dbaynard commented 1 month ago

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

I haven't tested a launchd variant, yet.