diff --git a/home-manager/bash.nix b/home-manager/bash.nix index 3a7cec876..ce3d68f97 100644 --- a/home-manager/bash.nix +++ b/home-manager/bash.nix @@ -12,6 +12,7 @@ programs.fzf.enableBashIntegration = false; # GH-1192: Don't enable fzf integrations, it makes shell startup slower. Load only key-bindings if required. programs.television.enableBashIntegration = false; # Conflict with fzf by default programs.zellij.enableBashIntegration = false; # Intentionally disabled for keeping stable bash + programs.atuin.enableBashIntegration = false; # Because of atuin depends on ble.sh. See also https://github.com/atuinsh/atuin/issues/1798 # Used only in bash - https://unix.stackexchange.com/a/689403 # https://github.com/nix-community/home-manager/blob/release-24.11/modules/programs/readline.nix diff --git a/home-manager/common.nix b/home-manager/common.nix index 4759cc199..b70976d84 100644 --- a/home-manager/common.nix +++ b/home-manager/common.nix @@ -220,6 +220,33 @@ ]; }; + # https://github.com/nix-community/home-manager/blob/release-25.05/modules/programs/atuin.nix + programs.atuin = { + enable = true; + + flags = [ + # https://github.com/atuinsh/atuin/issues/51 + "--disable-up-arrow" + + # NOTE: Add another keybind if I found suitable one + "--disable-ctrl-r" # Prefer fzf key-bindings. Use `atuin search --interactive` instead. + ]; + + settings = { + # auto_sync = true; # TODO: Consider enabling after test + + # Set a temporary value here to prevent using an external service like the default https://api.atuin.sh/. + # Current issues: + # - Atuin TLS support is disabled. + # - The NixOS module does not seem to accept config files or support TLS. + # Requirements before actual setup: Set ATUIN_SYNC_ADDRESS="https://algae.${TAILNET_DOMAIN}" on each device. + # Typically written to: "$XDG_CONFIG_HOME/zsh/.zshenv.local" + sync_address = "http://algae.local:8888"; + + enter_accept = false; # Ensure disabling even through it is the default. + }; + }; + # https://github.com/nix-community/home-manager/blob/release-25.05/modules/programs/yazi.nix programs.yazi = { enable = true; diff --git a/home-manager/packages.nix b/home-manager/packages.nix index ee992af5a..10125df91 100644 --- a/home-manager/packages.nix +++ b/home-manager/packages.nix @@ -11,6 +11,7 @@ direnv unstable.nixfmt nushell + atuin fzf # History: CTRL+R, Walker: CTRL+T # fzf-git-sh for CTRL-G CTRL-{} keybinds should be manually integrated in each shell diff --git a/home-manager/zsh.nix b/home-manager/zsh.nix index c73380d57..ec91f48ca 100644 --- a/home-manager/zsh.nix +++ b/home-manager/zsh.nix @@ -21,6 +21,7 @@ in programs.fzf.enableZshIntegration = false; # GH-1192: Don't enable fzf integrations, it makes shell startup slower. Load only key-bindings if required. programs.television.enableZshIntegration = false; # Conflict with fzf by default programs.zellij.enableZshIntegration = false; # Avoid nested zellij in host and remote login as container + programs.atuin.enableZshIntegration = true; home.activation.refreshZcompdumpCache = config.lib.dag.entryAnywhere '' if [[ -v oldGenPath && -f '${ZCOMPDUMP_CACHE_PATH}' ]]; then diff --git a/nixos/configuration.nix b/nixos/configuration.nix index 18f813ad5..13ee3f92f 100644 --- a/nixos/configuration.nix +++ b/nixos/configuration.nix @@ -249,4 +249,12 @@ # https://github.com/NixOS/nixpkgs/blob/nixos-25.05/nixos/modules/security/sudo-rs.nix security.sudo-rs.enable = true; + + networking.hosts = { + "127.0.0.1" = [ + # The motivation is: https://github.com/kachick/dotfiles/pull/266#discussion_r2462670847 + # Ensure to avoid the default URL in atuin connections + "api.atuin.sh" + ]; + }; } diff --git a/nixos/hosts/algae/default.nix b/nixos/hosts/algae/default.nix index 962c1a0c6..286de267b 100644 --- a/nixos/hosts/algae/default.nix +++ b/nixos/hosts/algae/default.nix @@ -2,6 +2,7 @@ lib, pkgs, inputs, + config, ... }: @@ -68,6 +69,41 @@ AllowSuspendThenHibernate=no ''; + # https://github.com/NixOS/nixpkgs/blob/nixos-25.05/nixos/modules/services/misc/atuin.nix + # atuin module appears not supporting customizing server.toml: https://github.com/NixOS/nixpkgs/blob/e9b7f2ff62b35f711568b1f0866243c7c302028d/nixos/modules/services/misc/atuin.nix#L148 + services.atuin = { + enable = true; + openRegistration = true; # Always allow to help the testing. It is okay, this server only useable on private networks + }; + + systemd.services.tailscale-serve-atuin = { + description = "Support atuin server via tailscale. See GH-173 and GH-266"; + wantedBy = [ + "multi-user.target" + ]; + + after = [ + "tailscaled.service" + "atuin.service" + ]; + + requires = [ + "tailscaled.service" + "atuin.service" + ]; + + serviceConfig = { + User = "nobody"; + Type = "simple"; + + # If run without systemd, `--bg` flag might helps + ExecStart = "${pkgs.unstable.tailscale}/bin/tailscale serve ${toString config.services.atuin.port}"; + + Restart = "on-failure"; + RestartSec = 15; + }; + }; + environment.systemPackages = with pkgs; [ # Available since https://github.com/NixOS/nixpkgs/pull/406363 (patched.yaneuraou.override {