1{
2 lib,
3 stdenv,
4 fetchFromGitHub,
5
6 # nativeBuildInputs
7 cmake,
8 rustPlatform,
9 rustc,
10 cargo,
11 installShellFiles,
12
13 # buildInputs
14 libuuid,
15
16 # passthru.tests
17 nixosTests,
18
19 # nativeCheckInputs
20 python3,
21
22 # nativeInstallCheckInputs
23 versionCheckHook,
24}:
25stdenv.mkDerivation (finalAttrs: {
26 pname = "taskwarrior";
27 version = "3.4.1";
28 src = fetchFromGitHub {
29 owner = "GothenburgBitFactory";
30 repo = "taskwarrior";
31 tag = "v${finalAttrs.version}";
32 hash = "sha256-00HiGju4pIswx8Z+M+ATdBSupiMS2xIm2ZnE52k/RwA=";
33 fetchSubmodules = true;
34 };
35 cargoDeps = rustPlatform.fetchCargoVendor {
36 name = "${finalAttrs.pname}-${finalAttrs.version}-cargo-deps";
37 inherit (finalAttrs) src;
38 hash = "sha256-trc5DIWf68XRBSMjeG/ZchuwFA56wJnLbqm17gE+jYQ=";
39 };
40
41 # The CMakeLists files used by upstream issue a `cargo install` command to
42 # install a rust tool (cxxbridge-cmd) that is supposed to be included in the Cargo.toml's and
43 # `Cargo.lock` files of upstream. Setting CARGO_HOME like that helps `cargo
44 # install` find the dependencies we prefetched. See also:
45 # https://github.com/GothenburgBitFactory/taskwarrior/issues/3705
46 postUnpack = ''
47 export CARGO_HOME=$PWD/.cargo
48 '';
49 failingTests = [
50 # It would be very hard to make this test succeed, as the bash completion
51 # needs to be installed and the builder's `bash` should be aware of it.
52 # Doesn't worth the effort. See also:
53 # https://github.com/GothenburgBitFactory/taskwarrior/issues/3727
54 "bash_completion.test.py"
55 ];
56 # Contains Bash and Python scripts used while testing.
57 preConfigure = ''
58 patchShebangs test
59 ''
60 + lib.optionalString (builtins.length finalAttrs.failingTests > 0) ''
61 substituteInPlace test/CMakeLists.txt \
62 ${lib.concatMapStringsSep "\\\n " (t: "--replace-fail ${t} '' ") finalAttrs.failingTests}
63 '';
64
65 strictDeps = true;
66 nativeBuildInputs = [
67 cmake
68 rustPlatform.cargoSetupHook
69 # To install cxxbridge-cmd before configurePhase, see above linked upstream
70 # issue.
71 rustc
72 cargo
73 installShellFiles
74 ];
75
76 buildInputs = [
77 libuuid
78 ];
79
80 doCheck = true;
81 # See:
82 # https://github.com/GothenburgBitFactory/taskwarrior/blob/v3.2.0/doc/devel/contrib/development.md#run-the-test-suite
83 preCheck = ''
84 make test_runner
85 '';
86 nativeCheckInputs = [
87 python3
88 ];
89
90 doInstallCheck = true;
91
92 nativeInstallCheckInputs = [
93 versionCheckHook
94 ];
95
96 versionCheckProgram = "${placeholder "out"}/bin/${finalAttrs.meta.mainProgram}";
97
98 postInstall = ''
99 # ZSH is installed automatically from some reason, only bash and fish need
100 # manual installation
101 installShellCompletion --cmd task \
102 --bash $out/share/doc/task/scripts/bash/task.sh \
103 --fish $out/share/doc/task/scripts/fish/task.fish
104 rm -r $out/share/doc/task/scripts/bash
105 rm -r $out/share/doc/task/scripts/fish
106 # Install vim and neovim plugin
107 mkdir -p $out/share/vim-plugins
108 mv $out/share/doc/task/scripts/vim $out/share/vim-plugins/task
109 mkdir -p $out/share/nvim
110 ln -s $out/share/vim-plugins/task $out/share/nvim/site
111 '';
112
113 passthru.tests.nixos = nixosTests.taskchampion-sync-server;
114
115 meta = {
116 changelog = "https://github.com/GothenburgBitFactory/taskwarrior/releases/tag/${finalAttrs.src.tag}";
117 description = "Highly flexible command-line tool to manage TODO lists";
118 homepage = "https://taskwarrior.org";
119 license = lib.licenses.mit;
120 maintainers = with lib.maintainers; [
121 marcweber
122 oxalica
123 mlaradji
124 doronbehar
125 ];
126 mainProgram = "task";
127 platforms = lib.platforms.unix;
128 };
129})