Clone of https://github.com/NixOS/nixpkgs.git (to stress-test knotserver)
1{ lib 2, commitizen 3, fetchFromGitHub 4, buildPythonPackage 5, git 6, pythonOlder 7, stdenv 8, installShellFiles 9, poetry-core 10, nix-update-script 11, testers 12, argcomplete 13, charset-normalizer 14, colorama 15, decli 16, importlib-metadata 17, jinja2 18, packaging 19, pyyaml 20, questionary 21, termcolor 22, tomlkit 23, py 24, pytest-freezer 25, pytest-mock 26, pytest-regressions 27, pytest7CheckHook 28, deprecated 29}: 30 31buildPythonPackage rec { 32 pname = "commitizen"; 33 version = "3.28.0"; 34 format = "pyproject"; 35 36 disabled = pythonOlder "3.8"; 37 38 src = fetchFromGitHub { 39 owner = "commitizen-tools"; 40 repo = pname; 41 rev = "refs/tags/v${version}"; 42 hash = "sha256-Z/L8TvMoee3qB+P6HUJEQxqw3nDEbBQabQOUyx0iugw="; 43 }; 44 45 pythonRelaxDeps = [ 46 "argcomplete" 47 "decli" 48 ]; 49 50 nativeBuildInputs = [ 51 poetry-core 52 installShellFiles 53 ]; 54 55 propagatedBuildInputs = [ 56 argcomplete 57 charset-normalizer 58 colorama 59 decli 60 importlib-metadata 61 jinja2 62 packaging 63 pyyaml 64 questionary 65 termcolor 66 tomlkit 67 ]; 68 69 nativeCheckInputs = [ 70 argcomplete 71 deprecated 72 git 73 py 74 pytest-freezer 75 pytest-mock 76 pytest-regressions 77 pytest7CheckHook 78 ]; 79 80 doCheck = true; 81 82 pythonImportsCheck = [ "commitizen" ]; 83 84 # The tests require a functional git installation 85 # which requires a valid HOME directory. 86 preCheck = '' 87 export HOME="$(mktemp -d)" 88 89 git config --global user.name "Nix Builder" 90 git config --global user.email "nix-builder@nixos.org" 91 git init . 92 ''; 93 94 # NB: These tests require complex GnuPG setup 95 disabledTests = [ 96 "test_bump_minor_increment_signed" 97 "test_bump_minor_increment_signed_config_file" 98 "test_bump_on_git_with_hooks_no_verify_enabled" 99 "test_bump_on_git_with_hooks_no_verify_disabled" 100 "test_bump_pre_commit_changelog" 101 "test_bump_pre_commit_changelog_fails_always" 102 "test_get_commits_with_signature" 103 # fatal: not a git repository (or any of the parent directories): .git 104 "test_commitizen_debug_excepthook" 105 ]; 106 107 postInstall = 108 let 109 register-python-argcomplete = lib.getExe' argcomplete "register-python-argcomplete"; 110 in 111 lib.optionalString (stdenv.buildPlatform.canExecute stdenv.hostPlatform) 112 '' 113 installShellCompletion --cmd cz \ 114 --bash <(${register-python-argcomplete} --shell bash $out/bin/cz) \ 115 --zsh <(${register-python-argcomplete} --shell zsh $out/bin/cz) \ 116 --fish <(${register-python-argcomplete} --shell fish $out/bin/cz) 117 ''; 118 119 passthru = { 120 updateScript = nix-update-script { }; 121 tests.version = testers.testVersion { 122 package = commitizen; 123 command = "cz version"; 124 }; 125 }; 126 127 meta = with lib; { 128 description = "Tool to create committing rules for projects, auto bump versions, and generate changelogs"; 129 homepage = "https://github.com/commitizen-tools/commitizen"; 130 changelog = "https://github.com/commitizen-tools/commitizen/blob/v${version}/CHANGELOG.md"; 131 license = licenses.mit; 132 mainProgram = "cz"; 133 maintainers = with maintainers; [ lovesegfault anthonyroussel ]; 134 }; 135}