|
9 | 9 | inherit (lib) mkIf; |
10 | 10 |
|
11 | 11 | cfg = config.khanelinix.programs.terminal.tools.atuin; |
| 12 | + hasSops = config.khanelinix.services.sops.enable or false; |
12 | 13 |
|
13 | 14 | userHome = config.home.homeDirectory; |
14 | 15 | atuinSocketPath = "${userHome}/.local/share/atuin/daemon.sock"; |
|
30 | 31 | options.khanelinix.programs.terminal.tools.atuin = { |
31 | 32 | enable = lib.mkEnableOption "atuin"; |
32 | 33 | enableDebug = lib.mkEnableOption "atuin daemon debug logging"; |
| 34 | + sync = { |
| 35 | + enable = lib.mkOption { |
| 36 | + type = lib.types.bool; |
| 37 | + default = true; |
| 38 | + description = "Whether to enable Atuin remote history sync."; |
| 39 | + }; |
| 40 | + }; |
33 | 41 | }; |
34 | 42 |
|
35 | 43 | config = mkIf cfg.enable { |
36 | 44 | home.shellAliases = { |
| 45 | + atuin-key = "atuin key"; |
| 46 | + atuin-login = "atuin login"; |
37 | 47 | atuin-prune-failed = "atuin search --exclude-exit 0 --delete \"\""; |
38 | 48 | atuin-prune-failed-dry-run = "atuin search --exclude-exit 0 --format \"{exit}\t{time}\t{command}\" | rg '^[1-9][0-9]*\t'"; |
| 49 | + atuin-sync = "atuin sync"; |
39 | 50 | }; |
40 | 51 |
|
41 | 52 | launchd.agents.atuin-daemon.config = lib.mkIf pkgs.stdenv.hostPlatform.isDarwin { |
|
58 | 69 | StandardOutPath = atuinLogPaths.stdout; |
59 | 70 | }; |
60 | 71 |
|
| 72 | + sops.secrets = mkIf (cfg.sync.enable && hasSops) { |
| 73 | + "atuin/key" = { |
| 74 | + sopsFile = lib.getFile "secrets/khaneliman/default.yaml"; |
| 75 | + }; |
| 76 | + }; |
| 77 | + |
61 | 78 | programs.atuin = { |
62 | 79 | enable = true; |
63 | 80 |
|
|
79 | 96 |
|
80 | 97 | # Atuin configuration |
81 | 98 | # See: https://docs.atuin.sh/configuration/config/ |
82 | | - settings = { |
83 | | - enter_accept = true; |
84 | | - # Filter modes can still be toggled via `ctrl-r` |
85 | | - filter_mode = "workspace"; |
86 | | - keymap_mode = "auto"; |
87 | | - show_preview = true; |
88 | | - # NOTE: Whether to store commands that failed. |
89 | | - # Can be useful to auto prune, but lose commands that might have |
90 | | - # a simple typo to fix and would need to type again. |
91 | | - # store_failed = false; |
92 | | - style = "auto"; |
93 | | - update_check = false; |
94 | | - workspaces = true; |
| 99 | + settings = lib.mkMerge [ |
| 100 | + { |
| 101 | + enter_accept = true; |
| 102 | + # Filter modes can still be toggled via `ctrl-r` |
| 103 | + filter_mode = "workspace"; |
| 104 | + keymap_mode = "auto"; |
| 105 | + show_preview = true; |
| 106 | + # NOTE: Whether to store commands that failed. |
| 107 | + # Can be useful to auto prune, but lose commands that might have |
| 108 | + # a simple typo to fix and would need to type again. |
| 109 | + # store_failed = false; |
| 110 | + style = "auto"; |
| 111 | + update_check = false; |
| 112 | + workspaces = true; |
95 | 113 |
|
96 | | - # Filter some commands we don't want to accidentally call from history |
97 | | - history_filter = [ |
98 | | - "^(sudo reboot)$" |
99 | | - "^(reboot)$" |
100 | | - ]; |
101 | | - }; |
| 114 | + # Filter some commands we don't want to accidentally call from history |
| 115 | + history_filter = [ |
| 116 | + "^(sudo reboot)$" |
| 117 | + "^(reboot)$" |
| 118 | + ]; |
| 119 | + } |
| 120 | + (mkIf cfg.sync.enable { |
| 121 | + auto_sync = true; |
| 122 | + sync_address = "https://api.atuin.sh"; |
| 123 | + sync_frequency = "30m"; |
| 124 | + }) |
| 125 | + (mkIf (cfg.sync.enable && hasSops) { |
| 126 | + key_path = config.sops.secrets."atuin/key".path; |
| 127 | + }) |
| 128 | + ]; |
102 | 129 | }; |
103 | 130 | }; |
104 | 131 | } |
0 commit comments