File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 3636
3737 mkWrapper =
3838 name : p :
39- pkgs . writeShellScriptBin "rustic-${ name } " ''
40- set -a
41- ${ optionalString ( p . environmentFile != null ) ". ${ p . environmentFile } " }
42- set +a
43- export RUSTIC_CACHE_DIR=/var/cache/rustic
44- exec ${ cfg . package } /bin/rustic -P ${ name } "$@"
39+ let
40+ bin = pkgs . writeShellScriptBin "rustic-${ name } " ''
41+ set -a
42+ ${ optionalString ( p . environmentFile != null ) ". ${ p . environmentFile } " }
43+ set +a
44+ export RUSTIC_CACHE_DIR=/var/cache/rustic
45+ exec ${ cfg . package } /bin/rustic -P ${ name } "$@"
46+ '' ;
47+ # Remap wrapper → rustic so clap's `_rustic` dispatch works.
48+ # Load rustic's own completion lazily (bash-completion only sources this file on first TAB).
49+ completion = pkgs . writeText "rustic-${ name } .bash" ''
50+ _rustic_${ name } () {
51+ if ! declare -F _rustic >/dev/null && [[ -f ${ cfg . package } /share/bash-completion/completions/rustic.bash ]]; then
52+ . ${ cfg . package } /share/bash-completion/completions/rustic.bash
53+ fi
54+ COMP_WORDS[0]=rustic
55+ _rustic rustic "$2" "$3"
56+ }
57+ complete -F _rustic_${ name } -o nosort -o bashdefault -o default rustic-${ name }
58+ '' ;
59+ in
60+ pkgs . runCommand "rustic-${ name } " { } ''
61+ mkdir -p $out/bin $out/share/bash-completion/completions
62+ ln -s ${ bin } /bin/rustic-${ name } $out/bin/rustic-${ name }
63+ ln -s ${ completion } $out/share/bash-completion/completions/rustic-${ name } .bash
4564 '' ;
4665 in
4766 {
You can’t perform that action at this time.
0 commit comments