Skip to content

Commit 46c0e91

Browse files
committed
feat(atuin): enable remote sync
Enable hosted Atuin sync from the reusable Atuin module so every enabled Atuin home gets the same remote sync defaults. Host configs can disable khanelinix.programs.terminal.tools.atuin.sync.enable when needed.
1 parent 932497e commit 46c0e91

1 file changed

Lines changed: 46 additions & 19 deletions

File tree

modules/home/programs/terminal/tools/atuin/default.nix

Lines changed: 46 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ let
99
inherit (lib) mkIf;
1010

1111
cfg = config.khanelinix.programs.terminal.tools.atuin;
12+
hasSops = config.khanelinix.services.sops.enable or false;
1213

1314
userHome = config.home.homeDirectory;
1415
atuinSocketPath = "${userHome}/.local/share/atuin/daemon.sock";
@@ -30,12 +31,22 @@ in
3031
options.khanelinix.programs.terminal.tools.atuin = {
3132
enable = lib.mkEnableOption "atuin";
3233
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+
};
3341
};
3442

3543
config = mkIf cfg.enable {
3644
home.shellAliases = {
45+
atuin-key = "atuin key";
46+
atuin-login = "atuin login";
3747
atuin-prune-failed = "atuin search --exclude-exit 0 --delete \"\"";
3848
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";
3950
};
4051

4152
launchd.agents.atuin-daemon.config = lib.mkIf pkgs.stdenv.hostPlatform.isDarwin {
@@ -58,6 +69,12 @@ in
5869
StandardOutPath = atuinLogPaths.stdout;
5970
};
6071

72+
sops.secrets = mkIf (cfg.sync.enable && hasSops) {
73+
"atuin/key" = {
74+
sopsFile = lib.getFile "secrets/khaneliman/default.yaml";
75+
};
76+
};
77+
6178
programs.atuin = {
6279
enable = true;
6380

@@ -79,26 +96,36 @@ in
7996

8097
# Atuin configuration
8198
# 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;
95113

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+
];
102129
};
103130
};
104131
}

0 commit comments

Comments
 (0)