diff --git a/configs/zsh.nix b/configs/zsh.nix index bb1eba8..91bf19b 100644 --- a/configs/zsh.nix +++ b/configs/zsh.nix @@ -7,6 +7,15 @@ # nothing to see here ''; + environment.systemPackages = [pkgs.atuin]; + environment.variables.ATUIN_CONFIG_DIR = toString (pkgs.writeTextDir "/config.toml" '' + auto_sync = true + update_check = false + sync_address = "http://zaatar.r:8888" + sync_frequency = 0 + style = "compact" + ''); + programs.zsh = let zsh-completions = pkgs.fetchFromGitHub { owner = "zsh-users"; @@ -14,12 +23,6 @@ rev = "cf565254e26bb7ce03f51889e9a29953b955b1fb"; sha256 = "1yf4rz99acdsiy0y1v3bm65xvs2m0sl92ysz0rnnrlbd5amn283l"; }; - zsh-history-substring-search = pkgs.fetchFromGitHub { - owner = "zsh-users"; - repo = "zsh-history-substring-search"; - rev = "aae3388491c2312c4efb2e86bcb999927bb2900e"; - sha256 = "0lgmq1xcccnz5cf7vl0r0qj351hwclx9p80cl0qczxry4r2g5qaz"; - }; in { enable = true; enableCompletion = true; @@ -54,12 +57,6 @@ autoload -U zmv run-help fpath=(${zsh-completions}/src $fpath) - source ${zsh-history-substring-search}/zsh-history-substring-search.zsh - - bindkey '^[[A' history-substring-search-up - bindkey '^[[B' history-substring-search-down - bindkey -M vicmd 'k' history-substring-search-up - bindkey -M vicmd 'j' history-substring-search-down ''; promptInit = with config.niveum; '' autoload -Uz vcs_info @@ -71,6 +68,13 @@ zstyle ':vcs_info:*' formats "%c%u%F{cyan}%b%f" zstyle ':vcs_info:*' actionformats "(%a) %c%u%F{cyan}%b%f" + # atuin distributed shell history + export ATUIN_NOBIND="true" # disable all keybdinings of atuin + eval "$(atuin init zsh)" + bindkey '^r' _atuin_search_widget # bind ctrl+r to atuin + # use zsh only session history + fc -p + precmd () { vcs_info RPROMPT="$vcs_info_msg_0_" diff --git a/flake.nix b/flake.nix index 2a401e6..595dc1f 100644 --- a/flake.nix +++ b/flake.nix @@ -172,7 +172,7 @@ sources = ["nix-writers" "nixpkgs" "retiolum" "stockholm"] ++ { - zaatar = ["traadfri"]; + zaatar = ["traadfri" "nixos-unstable"]; ful = []; tahina = []; tabula = []; diff --git a/systems/zaatar/atuin.nix b/systems/zaatar/atuin.nix new file mode 100644 index 0000000..acae725 --- /dev/null +++ b/systems/zaatar/atuin.nix @@ -0,0 +1,49 @@ +{config, ...}: let + inherit (import ) tmpfilesConfig; + unstable = import {inherit (config.nixpkgs) config;}; +in { + services.postgresql = { + enable = true; + dataDir = "/var/state/postgresql/${config.services.postgresql.package.psqlSchema}"; + ensureDatabases = ["atuin"]; + ensureUsers = [ + { + name = "atuin"; + ensurePermissions."DATABASE atuin" = "ALL PRIVILEGES"; + } + ]; + }; + + systemd.tmpfiles.rules = [ + (tmpfilesConfig { + type = "d"; + path = "/var/state/postgresql"; + mode = "0700"; + user = "postgres"; + group = "postgres"; + }) + ]; + + users.groups.atuin = {}; + users.users.atuin = { + isSystemUser = true; + group = "atuin"; + home = "/run/atuin"; + createHome = true; + }; + + systemd.services.atuin = { + wantedBy = ["multi-user.target"]; + environment = { + ATUIN_HOST = "0.0.0.0"; + ATUIN_PORT = "8888"; + ATUIN_OPEN_REGISTRATION = "true"; + ATUIN_DB_URI = "postgres:///atuin"; + }; + serviceConfig = { + User = "atuin"; + ExecStart = "${unstable.atuin}/bin/atuin server start"; + }; + }; + networking.firewall.allowedTCPPorts = [8888]; +} diff --git a/systems/zaatar/configuration.nix b/systems/zaatar/configuration.nix index 39b1f94..05b58ed 100644 --- a/systems/zaatar/configuration.nix +++ b/systems/zaatar/configuration.nix @@ -7,6 +7,7 @@ inherit (import ) retiolumAddresses restic; in { imports = [ + ./atuin.nix ./backup.nix ./gaslight.nix ./hardware-configuration.nix