Closed donovanglover closed 5 months ago
Seems like TaskWarrior did a rewrite of their database-backend-thing in Rust. Commentary follows:
git submodule update --force
dance to get one of the submodules to load. The derivation does this.I've modified pkgs/applications/misc/taskwarrior/default.nix
pursuant to this diff:
diff --git a/pkgs/applications/misc/taskwarrior/default.nix b/pkgs/applications/misc/taskwarrior/default.nix
index 105d470d1..65af1fd93 100644
--- a/pkgs/applications/misc/taskwarrior/default.nix
+++ b/pkgs/applications/misc/taskwarrior/default.nix
@@ -1,14 +1,14 @@
-{ lib, stdenv, fetchFromGitHub, cmake, libuuid, gnutls, python3, xdg-utils, installShellFiles }:
+{ lib, stdenv, fetchFromGitHub, cmake, libuuid, gnutls, python3, xdg-utils, installShellFiles, corrosion, cargo, rustc }:
stdenv.mkDerivation rec {
pname = "taskwarrior";
version = "3.0.0";
src = fetchFromGitHub { owner = "GothenburgBitFactory"; repo = "taskwarrior"; rev = "v${version}";
@@ -17,7 +17,7 @@ stdenv.mkDerivation rec { --replace "xdg-open" "${lib.getBin xdg-utils}/bin/xdg-open" '';
nativeBuildInputs = [ cmake libuuid gnutls python3 installShellFiles ];
nativeBuildInputs = [ cmake libuuid gnutls python3 installShellFiles corrosion cargo rustc ];
doCheck = true; preCheck = ''
I added corrosion
(a sort of FFI-type thing for C++ and Rust), cargo
, and rustc
as inputs to the package.
Seems that one of their CMakeLists
wants to pull in Corrosion manually. (taskwarrior/src/tc/CMakeLists.txt
(View on Github)
cmake_minimum_required (VERSION 3.22)
FetchContent_Declare ( Corrosion GIT_REPOSITORY https://github.com/corrosion-rs/corrosion.git GIT_TAG v0.4.7 ) FetchContent_MakeAvailable(Corrosion)
(snipped)
According to the [Corrosion documentation](https://corrosion-rs.github.io/corrosion/setup_corrosion.html#subdirectory), you can clone Corrosion as a submodule. If you
$ cd src/tc $ git submodule add https://github.com/corrosion-rs/corrosion.git
and modify CMakeLists.txt to read
```cmake
cmake_minimum_required (VERSION 3.22)
#FetchContent_Declare (
# Corrosion
# GIT_REPOSITORY https://github.com/corrosion-rs/corrosion.git
# GIT_TAG v0.4.7
#)
#FetchContent_MakeAvailable(Corrosion)
add_subdirectory(./corrosion)
(snipped)
that problem is solved.
taskwarrior
, two errors occur in the build log:
[ 41%] Building CXX object src/CMakeFiles/task.dir/nag.cpp.o
Updating crates.io index
warning: spurious network error (2 tries remaining): failed to resolve address for github.com: Temporary failure in name resolution; class=Net (12)
warning: spurious network error (1 tries remaining): failed to resolve address for github.com: Temporary failure in name resolution; class=Net (12)
error: Unable to update registry `crates-io`
Caused by:
failed to fetch https://github.com/rust-lang/crates.io-index
Caused by:
network failure seems to have happened
if a proxy or similar is necessary net.git-fetch-with-cli
may help here
https://doc.rust-lang.org/cargo/reference/config.html#netgit-fetch-with-cli
Caused by: failed to resolve address for github.com: Temporary failure in name resolution; class=Net (12) make[2]: [src/tc/CMakeFiles/_cargo-build_taskchampion-lib.dir/build.make:70: src/tc/CMakeFiles/_cargo-build_taskchampion-lib] Error 101 make[1]: [CMakeFiles/Makefile2:550: src/tc/CMakeFiles/_cargo-build_taskchampion-lib.dir/all] Error 2 make[1]: *** Waiting for unfinished jobs.... [ 42%] Building CXX object src/CMakeFiles/task.dir/recur.cpp.o
and
[ 89%] Building CXX object src/columns/CMakeFiles/columns.dir/ColWait.cpp.o [ 91%] Linking CXX static library libcolumns.a [ 91%] Built target columns [ 92%] Linking CXX static library libcommands.a [ 92%] Built target commands make: *** [Makefile:156: all] Error 2 error: boost::bad_format_string: format-string is ill-formed
The first one is obviously the result of Nix's hermetic nature. Perhaps [https://github.com/cargo2nix/cargo2nix](cargo2nix) is of help here? The second error, though, is interesting. I don't know what it's for.
I've put my reproducible example in [stupidcomputer/nixpkgs](https://github.com/stupidcomputer/nixpkgs/tree/taskwarrior-rabbit-hunt/pkgs/applications/misc/taskwarrior) in the `taskwarrior-rabbit-hunt` branch. It contains an entire clone of the taskwarrior repo plus all the submodules and stuff.
### Next steps
* Breaking apart the `taskwarrior` package into `taskwarrior`, `libshared` (an ancillary library maintained by the maintainers of Taskwarrior), and `taskchampion` (their Rust-based database thing).
* Building `taskchampion` as a Rust package and then including it as a dependency to `taskwarrior`.
Hi @stupidcomputer,
First of all, I suggest that, instead of upgrading 2.6 to 3.0, we should have two different packages, taskwarrior2 and taskwarrior3. This is because the database and the sync workflow were completely changed in taskwarrior3, and because of that taskwarrior3 is not backwards-compatible with taskwarrior2. (Note however, that migration from 2 to 3 is straightforward).
Anyway, I managed to build taskwarrior 3.0 on nix through the following configuration:
{
rustPlatform,
rustc,
cargo,
corrosion,
lib,
stdenv,
fetchFromGitHub,
cmake,
libuuid,
gnutls,
python3,
xdg-utils,
installShellFiles,
}:
stdenv.mkDerivation rec {
pname = "taskwarrior";
version = "fd306712b85dda3ea89de4e617aebeb98b2ede80";
src = fetchFromGitHub {
owner = "GothenburgBitFactory";
repo = "taskwarrior";
rev = "fd306712b85dda3ea89de4e617aebeb98b2ede80";
fetchSubmodules = true;
sha256 = "sha256-vzfHq/LHfnTx6CVGFCuO6W5aSqj1jVqldMdmyciSDDk=";
};
postPatch = ''
substituteInPlace src/commands/CmdNews.cpp \
--replace "xdg-open" "${lib.getBin xdg-utils}/bin/xdg-open"
'';
nativeBuildInputs = [
cmake
libuuid
gnutls
python3
installShellFiles
corrosion
cargo
rustc
rustPlatform.cargoSetupHook
];
doCheck = true;
preCheck = ''
patchShebangs --build test
'';
checkTarget = "test";
cargoDeps = rustPlatform.fetchCargoTarball {
name = "${pname}-${version}-cargo-deps";
inherit src;
sourceRoot = src.name;
hash = "sha256-DIu5hF7TFki5Zi2NnEjVRAd1VyQariN/cqh/ibBo74A=";
};
cargoRoot = "./";
preConfigure = ''
export CMAKE_PREFIX_PATH="${corrosion}:$CMAKE_PREFIX_PATH"
'';
postInstall = ''
# ZSH is installed automatically from some reason, only bash and fish need
# manual installation
installShellCompletion --cmd task \
--bash $out/share/doc/task/scripts/bash/task.sh \
--fish $out/share/doc/task/scripts/fish/task.fish
rm -r $out/share/doc/task/scripts/bash
rm -r $out/share/doc/task/scripts/fish
# Install vim and neovim plugin
mkdir -p $out/share/vim-plugins
mv $out/share/doc/task/scripts/vim $out/share/vim-plugins/task
mkdir -p $out/share/nvim
ln -s $out/share/vim-plugins/task $out/share/nvim/site
'';
meta = with lib; {
description = "Highly flexible command-line tool to manage TODO lists";
homepage = "https://taskwarrior.org";
license = licenses.mit;
maintainers = with maintainers; [marcweber oxalica];
mainProgram = "task";
platforms = platforms.unix;
};
}
However, to build the sync server (taskchampion-sync-server), a different derivation needs to be used. (I have already a working derivation for taskchampion-sync-server. Let me know if you would like that as well).
@mlaradji, Thanks for your feedback, and sorry for the late response. a) I agree it's a good idea to split the two versions into separate packages. b) That derivation looks good; I haven't the time to test it, but I'll probably get to that today. I saw that TaskWarrior added corrosion as a submodule, so that diff goes away, which is good.
If you want to go ahead and post a PR for both taskwarrior3
and the sync server, I think that's fine. I'll review the derivation and make sure it works.
Thanks again.
Notify maintainers
@marcweber @oxalica
Note for maintainers: Please tag this issue in your PR.
Add a :+1: reaction to issues you find important.