{ sysLib, pkgs, lib, ... }: let enforce_policies = sysLib.writeShellScriptWithLibrary { name = "enforce_policies.taskwarrior-hook"; src = ./scripts/on-add_enforce-policies.sh; dependencies = with pkgs; [dash jq taskwarrior gnused gnugrep]; replacementStrings = let mkProject = project: subproject: if builtins.isString subproject then { name = "${project.name}.${subproject}"; prefix = null; } else let name = builtins.elemAt (builtins.attrNames subproject) 0; in { name = "${project.name}.${name}"; subprojects = builtins.elemAt (builtins.attrValues subproject) 0; prefix = null; }; mkProjectName = project: if builtins.hasAttr "subprojects" project then lib.lists.flatten ([project.name] ++ (builtins.map mkProjectName (builtins.map (mkProject project) project.subprojects))) else [project.name]; projects = lib.lists.flatten (builtins.map mkProjectName (import ../projects {})); projects_newline = builtins.concatStringsSep "\n" projects; projects_comma = builtins.concatStringsSep ", " projects; in { PROJECTS_NEWLINE = projects_newline; PROJECTS_COMMA = projects_comma; }; }; track_timewarrior = pkgs.stdenv.mkDerivation { name = "track_timewarrior.taskwarrior-hook"; propagatedBuildInputs = [ pkgs.timewarrior pkgs.taskwarrior (pkgs.python3.withPackages (pythonPackages: with pythonPackages; [ taskw ])) ]; dontUnpack = true; installPhase = "install -Dm755 ${./scripts/on-modify_track-timewarrior.py} $out/bin/bin"; }; track_total_active_time = pkgs.stdenv.mkDerivation { name = "track_total_active_time.taskwarrior-hook"; propagatedBuildInputs = [ pkgs.taskwarrior (pkgs.python3.withPackages (pythonPackages: with pythonPackages; [ taskw ])) ]; dontUnpack = true; installPhase = "install -Dm755 ${./scripts/on-modify_track-total-active-time.py} $out/bin/bin"; }; in { xdg = { dataFile = { "task/hooks/on-add_enforce-policies".source = "${enforce_policies}/bin/enforce_policies.taskwarrior-hook"; "task/hooks/on-modify_track-timewarrior".source = "${track_timewarrior}/bin/bin"; "task/hooks/on-modify_track-total-active-time".source = "${track_total_active_time}/bin/bin"; }; }; }