From 58a476519e5878ae1467452e15c77dd913c21fe2 Mon Sep 17 00:00:00 2001 From: Matt McHenry Date: Wed, 30 Aug 2023 15:10:58 -0400 Subject: [PATCH] timetrap: add shell completions --- pkgs/applications/office/timetrap/default.nix | 50 ++++++++++++++++--- 1 file changed, 44 insertions(+), 6 deletions(-) diff --git a/pkgs/applications/office/timetrap/default.nix b/pkgs/applications/office/timetrap/default.nix index 579c9e115be8..7ece5e9b4b03 100644 --- a/pkgs/applications/office/timetrap/default.nix +++ b/pkgs/applications/office/timetrap/default.nix @@ -1,11 +1,49 @@ -{ lib, bundlerApp, bundlerUpdateScript }: +{ stdenv +, lib +, pkgs +, bundlerEnv +, bundlerApp +, bundlerUpdateScript +, installShellFiles +}: -bundlerApp { - pname = "timetrap"; - gemdir = ./.; - exes = [ "t" "timetrap" ]; +let + ttBundlerApp = bundlerApp { + pname = "timetrap"; + gemdir = ./.; + exes = [ "t" "timetrap" ]; - passthru.updateScript = bundlerUpdateScript "timetrap"; + passthru.updateScript = bundlerUpdateScript "timetrap"; + }; + + ttGem = bundlerEnv { + pname = "timetrap"; + gemdir = ./.; + }; + +in + +stdenv.mkDerivation { + name = "timetrap"; + + dontUnpack = true; + + nativeBuildInputs = [ installShellFiles ]; + + installPhase = '' + mkdir $out; + cd $out; + + mkdir bin; pushd bin; + ln -vs ${ttBundlerApp}/bin/t; + ln -vs ${ttBundlerApp}/bin/timetrap; + popd; + + for c in t timetrap; do + installShellCompletion --cmd $c --bash ${ttGem}/lib/ruby/gems/*/gems/timetrap*/completions/bash/*; + installShellCompletion --cmd $c --zsh ${ttGem}/lib/ruby/gems/*/gems/timetrap*/completions/zsh/*; + done; + ''; meta = with lib; { description = "A simple command line time tracker written in ruby";