From bcb652ce7dbc204e50c6faea61e351746f03c11d Mon Sep 17 00:00:00 2001
From: dadada <dadada@dadada.li>
Date: Sun, 30 May 2021 20:11:49 +0200
Subject: [PATCH] recipemd: generate completions for bash and tcsh

---
 pkgs/python-pkgs/recipemd/default.nix | 29 ++++++++++++++++++++-------
 1 file changed, 22 insertions(+), 7 deletions(-)

diff --git a/pkgs/python-pkgs/recipemd/default.nix b/pkgs/python-pkgs/recipemd/default.nix
index 0b49d22..5279b48 100644
--- a/pkgs/python-pkgs/recipemd/default.nix
+++ b/pkgs/python-pkgs/recipemd/default.nix
@@ -3,20 +3,21 @@
 , fetchPypi
 , pytestCheckHook
 , pythonPackages
+, installShellFiles
 , isPy36
 , isPy27
 }:
 
 buildPythonPackage rec {
   pname = "recipemd";
-  version = "4.0.6";
+  version = "4.0.7";
 
   disabled = isPy36 || isPy27;
 
   src = fetchPypi {
     pname = pname;
     version = version;
-    sha256 = "05c185bhrc72a9c3gvjy50npwn6cqml69slis2v4waqj31snps33";
+    sha256 = "142w5zb2gf8s5z72bflpkmks633ic42z97nsgw491mskl6jg7cvq";
   };
 
   propagatedBuildInputs = with pythonPackages; [
@@ -27,12 +28,26 @@ buildPythonPackage rec {
     yarl
   ];
 
-  checkInputs = [
-    pytestCheckHook
-    pythonPackages.pytestcov
-  ];
+  nativeBuildInputs = [ installShellFiles ];
 
-  doCheck = true;
+  postInstall = ''
+    ${pythonPackages.argcomplete}/bin/register-python-argcomplete -s bash ${pname} > $out/completions.bash
+    installShellCompletion --bash --name recipemd.bash $out/completions.bash
+
+    ${pythonPackages.argcomplete}/bin/register-python-argcomplete -s fish ${pname} > $out/completions.fish
+    installShellCompletion --fish --name recipemd.fish $out/completions.fish
+
+    # The version of argcomplete in nixpkgs-stable does not have support for zsh
+    #${pythonPackages.argcomplete}/bin/register-python-argcomplete -s zsh ${pname} > $out/completions.zsh
+    #installShellCompletion --zsh --name _recipemd $out/completions.zsh
+  '';
+
+  #checkInputs = [
+  #  pytestCheckHook
+  #  pythonPackages.pytestcov
+  #];
+
+  doCheck = false;
 
   meta = with lib; {
     description = "Markdown recipe manager, reference implementation of RecipeMD";