From 71e0e816166030feefaf99aa65e14488fac47434 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Sandro=20J=C3=A4ckel?= <sandro.jaeckel@gmail.com>
Date: Sun, 19 Dec 2021 07:19:27 +0100
Subject: [PATCH] atuin: 0.7.1 -> 0.8.0, install shell completion, add
 SuperSandro2000 as maintainer

---
 pkgs/tools/misc/atuin/default.nix | 24 +++++++++++++++++++-----
 1 file changed, 19 insertions(+), 5 deletions(-)

diff --git a/pkgs/tools/misc/atuin/default.nix b/pkgs/tools/misc/atuin/default.nix
index ae7a17e721cd..381711811875 100644
--- a/pkgs/tools/misc/atuin/default.nix
+++ b/pkgs/tools/misc/atuin/default.nix
@@ -1,6 +1,7 @@
 { lib
 , stdenv
 , fetchFromGitHub
+, installShellFiles
 , rustPlatform
 , libiconv
 , Security
@@ -9,24 +10,37 @@
 
 rustPlatform.buildRustPackage rec {
   pname = "atuin";
-  version = "0.7.1";
+  version = "0.8.0";
 
   src = fetchFromGitHub {
     owner = "ellie";
     repo = pname;
     rev = "v${version}";
-    sha256 = "sha256-jjGP8YeHnEr0f9RONwA6wZT872C0jXTvSRdt9zAu6KE=";
+    sha256 = "sha256-I/ZDaOAiHdWOkmf+jIWWxZ3C25UHsl6MB7mCRLADFNs=";
   };
 
-  cargoSha256 = "0vy6q3hjp374lyg00zxim8aplh83iq3f4rrmpz5vnpwbag1fdql3";
+  cargoSha256 = "sha256-KMss6Mpn4LHnkhtJyRea+D7mKItBK4lqq9syFEmCiFo=";
+
+  nativeBuildInputs = [ installShellFiles ];
 
   buildInputs = lib.optionals stdenv.isDarwin [ libiconv Security SystemConfiguration ];
 
+  postInstall = ''
+    HOME=$(mktemp -d)
+    for shell in bash fish zsh; do
+      $out/bin/atuin gen-completions -s $shell -o .
+    done
+
+    installShellCompletion --cmd atuin \
+      --bash atuin.bash \
+      --fish atuin.fish \
+      --zsh _atuin
+  '';
+
   meta = with lib; {
     description = "Replacement for a shell history which records additional commands context with optional encrypted synchronization between machines";
     homepage = "https://github.com/ellie/atuin";
     license = licenses.mit;
-    maintainers = [ maintainers.onsails ];
-    broken = stdenv.isDarwin && stdenv.isAarch64;
+    maintainers = with maintainers; [ onsails SuperSandro2000 ];
   };
 }