nixos/tracker: Define env var so it can find miners’ subcommands

tracker looks in its directory tree for executable files
to make available as subcommands. Users expect to find subcommands
from tracker-miners package but that fails as they are in different
tree. We also cannot change the lookup path since tracker-miners
also depends on a library from tracker package.

Until we can break the dependency cycle on package level:

   tracker -> tracker-miners -> tracker-sparql (tracker)

we need to work around it. I chose to set an environment
variable that overrides the subcommands lookup to a tree
symlinking files from both packages in GNOME NixOS module.

https://gitlab.gnome.org/GNOME/tracker/-/issues/341
Fixes: https://github.com/NixOS/nixpkgs/issues/153378
This commit is contained in:
Jan Tojnar 2022-01-03 21:51:26 +01:00
parent 18c84ea816
commit 3c1b474e44
2 changed files with 26 additions and 1 deletions

View file

@ -47,6 +47,8 @@ with lib;
systemd.packages = [ pkgs.tracker-miners ];
services.gnome.tracker.subcommandPackages = [ pkgs.tracker-miners ];
};
}

View file

@ -4,6 +4,9 @@
with lib;
let
cfg = config.services.gnome.tracker;
in
{
meta = {
@ -33,6 +36,15 @@ with lib;
'';
};
subcommandPackages = mkOption {
type = types.listOf types.package;
default = [ ];
internal = true;
description = ''
List of packages containing tracker3 subcommands.
'';
};
};
};
@ -40,7 +52,7 @@ with lib;
###### implementation
config = mkIf config.services.gnome.tracker.enable {
config = mkIf cfg.enable {
environment.systemPackages = [ pkgs.tracker ];
@ -48,6 +60,17 @@ with lib;
systemd.packages = [ pkgs.tracker ];
environment.variables = {
TRACKER_CLI_SUBCOMMANDS_DIR =
let
subcommandPackagesTree = pkgs.symlinkJoin {
name = "tracker-with-subcommands-${pkgs.tracker.version}";
paths = [ pkgs.tracker ] ++ cfg.subcommandPackages;
};
in
"${subcommandPackagesTree}/libexec/tracker3";
};
};
}