1{ lib, fetchFromGitHub, installShellFiles, python3Packages }:
2
3python3Packages.buildPythonApplication rec {
4 pname = "trash-cli";
5 version = "0.23.9.23";
6
7 src = fetchFromGitHub {
8 owner = "andreafrancia";
9 repo = "trash-cli";
10 rev = version;
11 hash = "sha256-EbW7P9fl7CDA6etOba7qcOtcxB2GkCd+zoi+NW0ZP9c=";
12 };
13
14 propagatedBuildInputs = with python3Packages; [ psutil six ];
15
16 nativeBuildInputs = with python3Packages; [
17 installShellFiles
18 shtab
19 ];
20
21 nativeCheckInputs = with python3Packages; [
22 mock
23 pytestCheckHook
24 ];
25
26 postPatch = ''
27 sed -i '/typing/d' setup.cfg
28 '';
29
30 doInstallCheck = true;
31 installCheckPhase = ''
32 runHook preInstallCheck
33
34 # Create a home directory with a test file.
35 HOME="$(mktemp -d)"
36 touch "$HOME/deleteme"
37
38 # Verify that trash list is initially empty.
39 [[ $($out/bin/trash-list) == "" ]]
40
41 # Trash a test file and verify that it shows up in the list.
42 $out/bin/trash "$HOME/deleteme"
43 [[ $($out/bin/trash-list) == *" $HOME/deleteme" ]]
44
45 # Empty the trash and verify that it is empty.
46 $out/bin/trash-empty
47 [[ $($out/bin/trash-list) == "" ]]
48
49 runHook postInstallCheck
50 '';
51 postInstall = ''
52 for bin in trash-empty trash-list trash-restore trash-put trash; do
53 installShellCompletion --cmd "$bin" \
54 --bash <("$out/bin/$bin" --print-completion bash) \
55 --zsh <("$out/bin/$bin" --print-completion zsh)
56 done
57 '';
58
59 meta = with lib; {
60 homepage = "https://github.com/andreafrancia/trash-cli";
61 description = "Command line interface to the freedesktop.org trashcan";
62 maintainers = [ maintainers.rycee ];
63 platforms = platforms.unix;
64 license = licenses.gpl2Plus;
65 mainProgram = "trash";
66 };
67}