about summary refs log tree commit diff stats
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--flake/nixosConfigurations/common.nix1
-rw-r--r--modules/by-name/at/atuin/module.nix92
-rw-r--r--modules/by-name/at/atuin/secrets/encryption_key.age42
-rw-r--r--pkgs/by-name/at/atuin/package.nix94
-rw-r--r--pkgs/by-name/at/atuin/set-dvorak-keybindings.patch37
-rw-r--r--secrets.nix2
6 files changed, 268 insertions, 0 deletions
diff --git a/flake/nixosConfigurations/common.nix b/flake/nixosConfigurations/common.nix
index cc191ea9..bdf65a35 100644
--- a/flake/nixosConfigurations/common.nix
+++ b/flake/nixosConfigurations/common.nix
@@ -31,6 +31,7 @@
     };
 
     programs = {
+      atuin.enable = true;
       imv.enable = true;
       lf.enable = true;
       zathura.enable = true;
diff --git a/modules/by-name/at/atuin/module.nix b/modules/by-name/at/atuin/module.nix
new file mode 100644
index 00000000..7adc34e1
--- /dev/null
+++ b/modules/by-name/at/atuin/module.nix
@@ -0,0 +1,92 @@
+{
+  config,
+  lib,
+  ...
+}: let
+  cfg = config.soispha.programs.atuin;
+in {
+  options.soispha.programs.atuin = {
+    enable = lib.mkEnableOption "atuin";
+  };
+
+  config = lib.mkIf cfg.enable {
+    age.secrets.atuin_encryption_key = {
+      file = ./secrets/encryption_key.age;
+      mode = "700";
+      owner = "soispha";
+      group = "users";
+    };
+
+    home-manager.users.soispha = {
+      programs.atuin = {
+        enable = true;
+        enableZshIntegration = config.soispha.programs.zsh.enable;
+        settings = {
+          key_path = "${config.age.secrets.atuin_encryption_key.path}";
+
+          # TODO: Setup a self-hosted sync server. <2024-10-18>
+          session_path = "";
+          auto_sync = false;
+          sync_address = "";
+
+          # Use the rather reasonable syntax of `skim` to search.
+          search_mode = "skim";
+
+          # Filter by files in a git directory, when in one.
+          # The filtermode can still be changed with `<Ctrl-r>` later.
+          workspaces = true;
+
+          # Save some space, by setting the mode to 'compact' and the height to 1 (meaning
+          # `atuin` may only use 1 line in the terminal).
+          style = "compact";
+          inline_height = 1;
+
+          # 'k' and 'j' to move up and down.
+          keymap_mode = "vim-normal";
+          keymap_cursor = {
+            emacs = "blink-underline";
+            vim_insert = "blink-block";
+            vim_normal = "blink-bar";
+          };
+
+          # Who wants software, that automatically calls home?!
+          update_check = false;
+
+          stats = {
+            # Commands with subcommands
+            # This list contains the defaults plus `nix`
+            common_subcommands = [
+              "apt"
+              "cargo"
+              "composer"
+              "dnf"
+              "docker"
+              "git"
+              "go"
+              "ip"
+              "kubectl"
+              "nix"
+              "nix"
+              "nmcli"
+              "npm"
+              "pecl"
+              "pnpm"
+              "podman"
+              "port"
+              "systemctl"
+              "tmux"
+              "yarn"
+            ];
+
+            # This overrides the default value.
+            ignored_commands = [];
+          };
+
+          # I currently don't want a sync deamon or a dotfiles manager running.
+          deamon.enable = false;
+          dotfiles.enable = false;
+        };
+      };
+    };
+  };
+}
diff --git a/modules/by-name/at/atuin/secrets/encryption_key.age b/modules/by-name/at/atuin/secrets/encryption_key.age
new file mode 100644
index 00000000..d801b0e0
--- /dev/null
+++ b/modules/by-name/at/atuin/secrets/encryption_key.age
@@ -0,0 +1,42 @@
+-----BEGIN AGE ENCRYPTED FILE-----
+YWdlLWVuY3J5cHRpb24ub3JnL3YxCi0+IFgyNTUxOSBBY3djUkVkbUhTZjFWS29F
+MFV5NkdCa3kxZTRjTFQ0N2cwekt4TVVhVTNZClN1ZE9ZSTdhaUtXWDZ2bjhEeVhZ
+V3RPRTAybU8zeWJZdW9VTFdWSVlWYUEKLT4gc3NoLWVkMjU1MTkgelpFb25nIHlH
+N2ZraXp0UGZFNFkzVVdiQTNnQ2RsSmsyWmJheFd3TC82R2RESmEzSFkKY2JEMzV2
+a05hYlJzU3lqbi9zbXR1SFp2VXhKTnhoSFFMTmR3Y0E4Q2VpawotPiBzc2gtZWQy
+NTUxOSA3SGZGVXcgdEtLd08ydks0SGdUWTA1ZlBqeWo5ZWt3dHZ0cXBoMHFzVW10
+ZHZ3cHdWawp2dnpERHV1RU9TUTBuSn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kT6jVWAlYCf5gWUVNUXG/7SR0u+Q==
+-----END AGE ENCRYPTED FILE-----
diff --git a/pkgs/by-name/at/atuin/package.nix b/pkgs/by-name/at/atuin/package.nix
new file mode 100644
index 00000000..7f58697a
--- /dev/null
+++ b/pkgs/by-name/at/atuin/package.nix
@@ -0,0 +1,94 @@
+# This has been taken from nixpkgs at:
+# https://github.com/NixOS/nixpkgs/blob/5785b6bb5eaae44e627d541023034e1601455827/pkgs/by-name/at/atuin/package.nix
+# I have just removed some features and added a patch for dvorak input.
+{
+  lib,
+  stdenv,
+  fetchFromGitHub,
+  installShellFiles,
+  rustPlatform,
+  libiconv,
+  buildPackages,
+  darwin,
+  nixosTests,
+}:
+rustPlatform.buildRustPackage rec {
+  pname = "atuin";
+  version = "18.3.0";
+
+  src = fetchFromGitHub {
+    owner = "atuinsh";
+    repo = "atuin";
+    rev = "v${version}";
+    hash = "sha256-Q3UI1IUD5Jz2O4xj3mFM7DqY3lTy3WhWYPa8QjJHTKE=";
+  };
+
+  # TODO: unify this to one hash because updater do not support this
+  cargoHash =
+    if stdenv.hostPlatform.isLinux
+    then "sha256-K4Vw/d0ZOROWujWr76I3QvfKefLhXLeFufUrgStAyjQ="
+    else "sha256-8NAfE7cGFT64ntNXK9RT0D/MbDJweN7vvsG/KlrY4K4=";
+
+  patches = [
+    ./set-dvorak-keybindings.patch
+  ];
+
+  # atuin's default features include 'check-updates', which do not make sense
+  # for distribution builds. List all other default features.
+  buildNoDefaultFeatures = true;
+  buildFeatures = [
+    "client"
+    # "sync"
+    # "server"
+    "clipboard"
+    # "daemon"
+  ];
+
+  nativeBuildInputs = [installShellFiles];
+
+  buildInputs = lib.optionals stdenv.hostPlatform.isDarwin [
+    libiconv
+    darwin.apple_sdk_11_0.frameworks.AppKit
+    darwin.apple_sdk_11_0.frameworks.Security
+    darwin.apple_sdk_11_0.frameworks.SystemConfiguration
+  ];
+
+  preBuild = ''
+    export PROTOC=${buildPackages.protobuf}/bin/protoc
+    export PROTOC_INCLUDE="${buildPackages.protobuf}/include";
+  '';
+
+  postInstall = lib.optionalString (stdenv.buildPlatform.canExecute stdenv.hostPlatform) ''
+    installShellCompletion --cmd atuin \
+      --bash <($out/bin/atuin gen-completions -s bash) \
+      --fish <($out/bin/atuin gen-completions -s fish) \
+      --zsh <($out/bin/atuin gen-completions -s zsh)
+  '';
+
+  passthru.tests = {
+    inherit (nixosTests) atuin;
+  };
+
+  # The checks don't compile without the `server` feature
+  doCheck = false;
+  checkFlags = [
+    # tries to make a network access
+    "--skip=registration"
+    # No such file or directory (os error 2)
+    "--skip=sync"
+    # PermissionDenied (Operation not permitted)
+    "--skip=change_password"
+    "--skip=multi_user_test"
+    "--skip=store::var::tests::build_vars"
+    # Tries to touch files
+    "--skip=build_aliases"
+  ];
+
+  meta = with lib; {
+    description = "Replacement for a shell history which records additional commands context with optional encrypted synchronization between machines";
+    homepage = "https://github.com/atuinsh/atuin";
+    license = licenses.mit;
+    maintainers = with maintainers; [SuperSandro2000 sciencentistguy _0x4A6F];
+    mainProgram = "atuin";
+  };
+}
diff --git a/pkgs/by-name/at/atuin/set-dvorak-keybindings.patch b/pkgs/by-name/at/atuin/set-dvorak-keybindings.patch
new file mode 100644
index 00000000..9ab3700a
--- /dev/null
+++ b/pkgs/by-name/at/atuin/set-dvorak-keybindings.patch
@@ -0,0 +1,37 @@
+From f763aef8094c12293570119d9ff0922356dd8c79 Mon Sep 17 00:00:00 2001
+From: Benedikt Peetz <benedikt.peetz@b-peetz.de>
+Date: Fri, 18 Oct 2024 23:03:01 +0200
+Subject: [PATCH] fix(client): Change the keymaps to support dvorka vim keys
+
+---
+ crates/atuin/src/command/client/search/interactive.rs | 6 +++---
+ 1 file changed, 3 insertions(+), 3 deletions(-)
+
+diff --git a/crates/atuin/src/command/client/search/interactive.rs b/crates/atuin/src/command/client/search/interactive.rs
+index c87fff1c..19e965fe 100644
+--- a/crates/atuin/src/command/client/search/interactive.rs
++++ b/crates/atuin/src/command/client/search/interactive.rs
+@@ -322,17 +322,17 @@ impl State {
+                     self.keymap_mode = KeymapMode::VimInsert;
+                     return InputAction::Continue;
+                 }
+-                KeyCode::Char('j') if !ctrl => {
++                KeyCode::Char('t') if !ctrl => {
+                     return self.handle_search_down(settings, true);
+                 }
+-                KeyCode::Char('k') if !ctrl => {
++                KeyCode::Char('n') if !ctrl => {
+                     return self.handle_search_up(settings, true);
+                 }
+                 KeyCode::Char('h') if !ctrl => {
+                     self.search.input.left();
+                     return InputAction::Continue;
+                 }
+-                KeyCode::Char('l') if !ctrl => {
++                KeyCode::Char('s') if !ctrl => {
+                     self.search.input.right();
+                     return InputAction::Continue;
+                 }
+-- 
+2.46.0
+
diff --git a/secrets.nix b/secrets.nix
index 3e16473d..02e07728 100644
--- a/secrets.nix
+++ b/secrets.nix
@@ -6,6 +6,8 @@ let
 in {
   "modules/by-name/lf/lf/secrets/cd_paths.age".publicKeys = [soispha tiamat apzu];
 
+  "modules/by-name/at/atuin/secrets/encryption_key.age".publicKeys = [soispha tiamat apzu];
+
   "modules/by-name/se/serverphone/private_keys/ca.key".publicKeys = [soispha tiamat apzu];
   "modules/by-name/se/serverphone/private_keys/server.key".publicKeys = [soispha tiamat apzu];