mirror of
https://github.com/Mic92/nixos-wiki-infra.git
synced 2024-11-22 00:04:01 +01:00
nixfmt extensions
This commit is contained in:
parent
ada004ff16
commit
6085d5513a
@ -1,5 +1,5 @@
|
|||||||
#!/usr/bin/env nix-shell
|
#!/usr/bin/env nix-shell
|
||||||
#!nix-shell -i python3 -p python3 python3Packages.requests python3Packages.beautifulsoup4 gh
|
#!nix-shell -i python3 -p nixfmt-rfc-style python3 python3Packages.requests python3Packages.beautifulsoup4 gh
|
||||||
import json
|
import json
|
||||||
import os
|
import os
|
||||||
import shlex
|
import shlex
|
||||||
@ -10,7 +10,6 @@ import urllib.parse
|
|||||||
from dataclasses import dataclass
|
from dataclasses import dataclass
|
||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
from tempfile import TemporaryDirectory
|
from tempfile import TemporaryDirectory
|
||||||
from typing import IO
|
|
||||||
|
|
||||||
import requests
|
import requests
|
||||||
from bs4 import BeautifulSoup
|
from bs4 import BeautifulSoup
|
||||||
@ -85,13 +84,12 @@ def mirror_extension(extension_name: str, mediawiki_version: str) -> Extension:
|
|||||||
raise Exception("Failed to fetch extension, see above")
|
raise Exception("Failed to fetch extension, see above")
|
||||||
|
|
||||||
|
|
||||||
def write_nix_file(file: IO[str], mirrored_extensions: list[Extension]) -> None:
|
def extension_nix_expression(mirrored_extensions: list[Extension]) -> str:
|
||||||
file.write("{ fetchzip }: {\n")
|
expression = "{ fetchzip }: {\n"
|
||||||
for extension in mirrored_extensions:
|
for extension in mirrored_extensions:
|
||||||
file.write(
|
expression += f' "{extension.name}" = fetchzip {{ url = "{extension.url}"; hash = "{extension.hash}"; }};\n'
|
||||||
f' "{extension.name}" = fetchzip {{ url = "{extension.url}"; hash = "{extension.hash}"; }};\n'
|
expression += "}\n"
|
||||||
)
|
return expression
|
||||||
file.write("}\n")
|
|
||||||
|
|
||||||
|
|
||||||
def get_mediawiki_version(mediawiki_version: str | None = None) -> str:
|
def get_mediawiki_version(mediawiki_version: str | None = None) -> str:
|
||||||
@ -130,8 +128,9 @@ def main():
|
|||||||
extension = mirror_extension(name, mediawiki_version)
|
extension = mirror_extension(name, mediawiki_version)
|
||||||
mirrored_extensions.append(extension)
|
mirrored_extensions.append(extension)
|
||||||
|
|
||||||
with open("extensions.nix", "w") as file:
|
nix_extensions = Path("extensions.nix")
|
||||||
write_nix_file(file, mirrored_extensions)
|
nix_extensions.write_text(extension_nix_expression(mirrored_extensions))
|
||||||
|
run(["nixfmt", str(nix_extensions)])
|
||||||
|
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
|
Loading…
Reference in New Issue
Block a user