Format neovim plugin update script
This commit is contained in:
parent
4c44032cc9
commit
33345748b8
1 changed files with 14 additions and 14 deletions
|
@ -6,38 +6,38 @@ plugins="${script_dir}/plugins.txt"
|
||||||
nix_new_file="${script_dir}/plugins_new.nix"
|
nix_new_file="${script_dir}/plugins_new.nix"
|
||||||
nix_file="${script_dir}/plugins.nix"
|
nix_file="${script_dir}/plugins.nix"
|
||||||
|
|
||||||
echo '# This file has been auto-generated' > "$nix_new_file"
|
echo '# This file has been auto-generated' >"$nix_new_file"
|
||||||
echo '{ pkgs, ... }:' >> "$nix_new_file"
|
echo '{ pkgs, ... }:' >>"$nix_new_file"
|
||||||
|
|
||||||
echo "{" >> "$nix_new_file"
|
echo "{" >>"$nix_new_file"
|
||||||
while IFS='' read -r LINE || [ -n "${LINE}" ]; do
|
while IFS='' read -r LINE || [ -n "${LINE}" ]; do
|
||||||
owner="$(echo "$LINE" | cut -d'/' -f1)"
|
owner="$(echo "$LINE" | cut -d'/' -f1)"
|
||||||
repo="$(echo "$LINE" | cut -d'/' -f2)"
|
repo="$(echo "$LINE" | cut -d'/' -f2)"
|
||||||
build="$(echo "$LINE" | cut -d'/' -f3)"
|
build="$(echo "$LINE" | cut -d'/' -f3)"
|
||||||
name="$(echo "$repo" | tr [.] '-')"
|
name="$(echo "$repo" | tr [.] '-')"
|
||||||
src="$(nix-prefetch-github --nix --no-fetch-submodules "$owner" "$repo" 2> /dev/null | tail -n +4)"
|
src="$(nix-prefetch-github --nix --no-fetch-submodules "$owner" "$repo" 2>/dev/null | tail -n +4)"
|
||||||
rev="$(echo "$src" | grep rev | cut -d '"' -f 2)"
|
rev="$(echo "$src" | grep rev | cut -d '"' -f 2)"
|
||||||
|
|
||||||
echo "Updating ${owner}/${repo} ..."
|
echo "Updating ${owner}/${repo} ..."
|
||||||
|
|
||||||
echo "${name} = pkgs.vimUtils.buildVimPluginFrom2Nix {" >> "$nix_new_file"
|
echo "${name} = pkgs.vimUtils.buildVimPluginFrom2Nix {" >>"$nix_new_file"
|
||||||
echo "pname = \"${repo}\";" >> "$nix_new_file"
|
echo "pname = \"${repo}\";" >>"$nix_new_file"
|
||||||
echo "version = \"${rev:0:7}\";" >> "$nix_new_file"
|
echo "version = \"${rev:0:7}\";" >>"$nix_new_file"
|
||||||
echo "src = ${src};" >> "$nix_new_file"
|
echo "src = ${src};" >>"$nix_new_file"
|
||||||
|
|
||||||
if [ -n "$build" ]; then
|
if [ -n "$build" ]; then
|
||||||
echo "buildPhase = \"${build}\";" >> "$nix_new_file"
|
echo "buildPhase = \"${build}\";" >>"$nix_new_file"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
echo "meta.homepage = \"https://github.com/${owner}/${repo}\";" >> "$nix_new_file"
|
echo "meta.homepage = \"https://github.com/${owner}/${repo}\";" >>"$nix_new_file"
|
||||||
echo '};' >> "$nix_new_file"
|
echo '};' >>"$nix_new_file"
|
||||||
done < "$plugins"
|
done <"$plugins"
|
||||||
echo "}" >> "$nix_new_file"
|
echo "}" >>"$nix_new_file"
|
||||||
|
|
||||||
nixpkgs-fmt "$nix_new_file"
|
nixpkgs-fmt "$nix_new_file"
|
||||||
|
|
||||||
if test -f "$nix_file"; then
|
if test -f "$nix_file"; then
|
||||||
diff -U 4 "$nix_file" "$nix_new_file" | bat --paging=never -ldiff
|
diff -U 2 "$nix_file" "$nix_new_file" | bat --paging=never -ldiff
|
||||||
mv "$nix_new_file" "$nix_file"
|
mv "$nix_new_file" "$nix_file"
|
||||||
else
|
else
|
||||||
mv "$nix_new_file" "$nix_file"
|
mv "$nix_new_file" "$nix_file"
|
||||||
|
|
Loading…
Reference in a new issue