fix: more config options for git fuzzy

This commit is contained in:
oddlama 2023-09-18 16:11:44 +02:00
parent 80a4544bee
commit 761adc3133
No known key found for this signature in database
GPG key ID: 14EFE510775FE39A
2 changed files with 30 additions and 6 deletions

View file

@ -4,10 +4,11 @@
lib,
makeWrapper,
gitAndTools,
bc,
bat,
extraPackages ? [],
}: let
binPath = lib.makeBinPath ([gitAndTools.hub gitAndTools.delta bat] ++ extraPackages);
binPath = lib.makeBinPath ([gitAndTools.hub gitAndTools.delta bc bat] ++ extraPackages);
in
stdenvNoCC.mkDerivation rec {
pname = "git-fuzzy";
@ -24,12 +25,24 @@ in
];
postPatch = ''
for GF_key in $(grep -o -- 'GF_[A-Z0-9_]*' lib/load-configs.sh | sort -u); do
for GF_key in $(grep -ohr -- 'GF_[A-Z0-9_]*' lib | sort -u); do
key=''${GF_key#"GF_"}
key=''${key//_/-}
key=''${key,,}
cat >> lib/load-configs-from-git.sh <<EOF
if val=\$(git config --get fuzzy.''${key@Q}); then
$GF_key=\$val
export $GF_key=\$val
fi
EOF
done
for GIT_FUZZY_key in $(grep -ohr -- 'GIT_FUZZY_[A-Z0-9_]*' lib | sort -u); do
key=''${GIT_FUZZY_key#"GIT_FUZZY_"}
key=''${key//_/-}
key=''${key,,}
cat >> lib/load-configs-from-git.sh <<EOF
if val=\$(git config --get fuzzy.''${key@Q}); then
export $GIT_FUZZY_key=\$val
fi
EOF
done
@ -38,12 +51,11 @@ in
nativeBuildInputs = [makeWrapper];
installPhase = ''
install -m755 -D ./bin/git-fuzzy $out/bin/git-fuzzy
install -d "$out/lib"
cp -r lib "$out/lib/git-fuzzy"
cp -r lib "$out/lib"
'';
postFixup = ''
sed -i 's%lib_dir="$script_dir/../lib"%lib_dir='"$out"'/lib/git-fuzzy%' $out/bin/git-fuzzy
sed -i 's%git_fuzzy_dir="$script_dir/.."%git_fuzzy_dir='"$out"'%' $out/bin/git-fuzzy
wrapProgram "$out/bin/git-fuzzy" --prefix PATH : ${binPath}
'';