at master 114 lines 2.9 kB view raw
1{ 2 lib, 3 fetchFromGitHub, 4 gitMinimal, 5 stdenv, 6 installShellFiles, 7 nix-update-script, 8 python3Packages, 9 versionCheckHook, 10 writableTmpDirAsHomeHook, 11}: 12 13python3Packages.buildPythonPackage rec { 14 pname = "commitizen"; 15 version = "4.9.1"; 16 pyproject = true; 17 18 src = fetchFromGitHub { 19 owner = "commitizen-tools"; 20 repo = "commitizen"; 21 tag = "v${version}"; 22 hash = "sha256-4hsKCBJHeRjc519h7KO/X8BJhGuw0N6XmC6u+QEiAnc="; 23 }; 24 25 pythonRelaxDeps = [ 26 "argcomplete" 27 "decli" 28 "termcolor" 29 ]; 30 31 build-system = with python3Packages; [ poetry-core ]; 32 33 nativeBuildInputs = [ installShellFiles ]; 34 35 dependencies = with python3Packages; [ 36 argcomplete 37 charset-normalizer 38 colorama 39 decli 40 deprecated 41 importlib-metadata 42 jinja2 43 packaging 44 pyyaml 45 questionary 46 termcolor 47 tomlkit 48 ]; 49 50 nativeCheckInputs = [ 51 gitMinimal 52 versionCheckHook 53 writableTmpDirAsHomeHook 54 ] 55 ++ (with python3Packages; [ 56 argcomplete 57 py 58 pytest-freezer 59 pytest-mock 60 pytest-regressions 61 pytest7CheckHook 62 ]); 63 64 versionCheckProgramArg = "version"; 65 66 pythonImportsCheck = [ "commitizen" ]; 67 68 # The tests require a functional git installation 69 preCheck = '' 70 git config --global user.name "Nix Builder" 71 git config --global user.email "nix-builder@nixos.org" 72 git init . 73 ''; 74 75 # NB: These tests require complex GnuPG setup 76 disabledTests = [ 77 "test_bump_minor_increment_signed" 78 "test_bump_minor_increment_signed_config_file" 79 "test_bump_on_git_with_hooks_no_verify_enabled" 80 "test_bump_on_git_with_hooks_no_verify_disabled" 81 "test_bump_pre_commit_changelog" 82 "test_bump_pre_commit_changelog_fails_always" 83 "test_get_commits_with_signature" 84 # fatal: not a git repository (or any of the parent directories): .git 85 "test_commitizen_debug_excepthook" 86 ]; 87 88 postInstall = 89 let 90 register-python-argcomplete = lib.getExe' python3Packages.argcomplete "register-python-argcomplete"; 91 in 92 lib.optionalString (stdenv.buildPlatform.canExecute stdenv.hostPlatform) '' 93 installShellCompletion --cmd cz \ 94 --bash <(${register-python-argcomplete} --shell bash $out/bin/cz) \ 95 --zsh <(${register-python-argcomplete} --shell zsh $out/bin/cz) \ 96 --fish <(${register-python-argcomplete} --shell fish $out/bin/cz) 97 ''; 98 99 passthru = { 100 updateScript = nix-update-script { }; 101 }; 102 103 meta = { 104 description = "Tool to create committing rules for projects, auto bump versions, and generate changelogs"; 105 homepage = "https://github.com/commitizen-tools/commitizen"; 106 changelog = "https://github.com/commitizen-tools/commitizen/blob/${src.tag}/CHANGELOG.md"; 107 license = lib.licenses.mit; 108 mainProgram = "cz"; 109 maintainers = with lib.maintainers; [ 110 lovesegfault 111 anthonyroussel 112 ]; 113 }; 114}