nixpkgs/pkgs/by-name/tr/trash-cli/package.nix
aleksana 571c71e6f7 treewide: migrate packages to pkgs/by-name, take 1
We are migrating packages that meet below requirements:

1. using `callPackage`
2. called path is a directory
3. overriding set is empty (`{ }`)
4. not containing path expressions other than relative path (to
makenixpkgs-vet happy)
5. not referenced by nix files outside of the directory, other
than`pkgs/top-level/all-packages.nix`
6. not referencing nix files outside of the directory
7. not referencing `default.nix` (since it's changed to `package.nix`)
8. `outPath` doesn't change after migration

The tool is here: https://github.com/Aleksanaa/by-name-migrate.
2024-11-09 20:04:51 +08:00

70 lines
1.8 KiB
Nix

{ lib, fetchFromGitHub, installShellFiles, nix-update-script, python3Packages }:
python3Packages.buildPythonApplication rec {
pname = "trash-cli";
version = "0.24.5.26";
src = fetchFromGitHub {
owner = "andreafrancia";
repo = "trash-cli";
rev = version;
hash = "sha256-ltuMnxtG4jTTSZd6ZHWl8wI0oQMMFqW0HAPetZMfGtc=";
};
propagatedBuildInputs = with python3Packages; [ psutil six ];
nativeBuildInputs = with python3Packages; [
installShellFiles
shtab
];
nativeCheckInputs = with python3Packages; [
mock
pytestCheckHook
];
postPatch = ''
sed -i '/typing/d' setup.cfg
'';
doInstallCheck = true;
installCheckPhase = ''
runHook preInstallCheck
# Create a home directory with a test file.
HOME="$(mktemp -d)"
touch "$HOME/deleteme"
# Verify that trash list is initially empty.
[[ $($out/bin/trash-list) == "" ]]
# Trash a test file and verify that it shows up in the list.
$out/bin/trash "$HOME/deleteme"
[[ $($out/bin/trash-list) == *" $HOME/deleteme" ]]
# Empty the trash and verify that it is empty.
$out/bin/trash-empty
[[ $($out/bin/trash-list) == "" ]]
runHook postInstallCheck
'';
postInstall = ''
for bin in trash-empty trash-list trash-restore trash-put trash; do
installShellCompletion --cmd "$bin" \
--bash <("$out/bin/$bin" --print-completion bash) \
--zsh <("$out/bin/$bin" --print-completion zsh)
done
'';
passthru.updateScript = nix-update-script { };
meta = with lib; {
homepage = "https://github.com/andreafrancia/trash-cli";
description = "Command line interface to the freedesktop.org trashcan";
maintainers = [ maintainers.rycee ];
platforms = platforms.unix;
license = licenses.gpl2Plus;
mainProgram = "trash";
};
}