mirror of
https://github.com/nix-community/nixvim.git
synced 2025-06-21 08:35:43 +02:00
modules/spellfiles: init
This commit is contained in:
parent
a3245848da
commit
420470dfde
7 changed files with 1015 additions and 0 deletions
44
update-scripts/fetch-spellfiles.nix
Normal file
44
update-scripts/fetch-spellfiles.nix
Normal file
|
@ -0,0 +1,44 @@
|
|||
{
|
||||
writeShellApplication,
|
||||
curl,
|
||||
nix,
|
||||
...
|
||||
}:
|
||||
writeShellApplication {
|
||||
name = "fetch-spellfiles";
|
||||
|
||||
runtimeInputs = [
|
||||
curl
|
||||
nix
|
||||
];
|
||||
|
||||
text = ''
|
||||
echo "{"
|
||||
|
||||
BASE_URL="https://ftp.nluug.nl/pub/vim/runtime/spell/"
|
||||
|
||||
html=$(curl -s "$BASE_URL")
|
||||
|
||||
# Extract only .spl and .sug file links
|
||||
readarray -t filenames < <(echo "$html" | grep -oP '(?<=href=")[^"]+\.(spl|sug)' | sort -u)
|
||||
|
||||
for filename in "''${filenames[@]}"; do
|
||||
|
||||
url="$BASE_URL$filename"
|
||||
|
||||
# Special characters (like '%40', standing for `@`) are invalid for nix store paths
|
||||
# -> We replace all non-alphanumeric characters with '_' and used this sanitized filename for
|
||||
# the derivation name
|
||||
sanitized_filename="''${filename//[^a-zA-Z0-9]/_}"
|
||||
sha256=$(nix-prefetch-url "$url" --name "$sanitized_filename")
|
||||
|
||||
hash=$(nix hash convert --to sri --hash-algo sha256 "$sha256")
|
||||
|
||||
# Ugly hardcoding of the `%40` -> `@` substitution
|
||||
filename="''${filename//%40/@}"
|
||||
echo -e " \"$filename\": { url: \"$url\", hash: \"$hash\" },"
|
||||
done
|
||||
|
||||
echo "}"
|
||||
'';
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue