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