forked from Drift/pvv-nixos-config
bekkalokk: package mediawiki extensions outside of module
This commit is contained in:
parent
d39047b8cb
commit
9495682f57
|
@ -80,6 +80,7 @@
|
|||
overlays = [
|
||||
(final: prev: {
|
||||
heimdal = unstablePkgs.heimdal;
|
||||
mediawiki-extensions = final.callPackage ./packages/mediawiki-extensions { };
|
||||
})
|
||||
];
|
||||
};
|
||||
|
@ -123,6 +124,8 @@
|
|||
(nixlib.getAttrs allMachines self.packages.x86_64-linux);
|
||||
|
||||
simplesamlphp = pkgs.callPackage ./packages/simplesamlphp { };
|
||||
|
||||
mediawiki-extensions = pkgs.callPackage ./packages/mediawiki-extensions { };
|
||||
} // nixlib.genAttrs allMachines
|
||||
(machine: self.nixosConfigurations.${machine}.config.system.build.toplevel);
|
||||
};
|
||||
|
|
|
@ -60,22 +60,7 @@ in {
|
|||
};
|
||||
|
||||
extensions = {
|
||||
DeleteBatch = pkgs.fetchzip {
|
||||
url = "https://extdist.wmflabs.org/dist/extensions/DeleteBatch-REL1_39-995ea6f.tar.gz";
|
||||
sha256 = "sha256-0F4GLCy2f5WcWIY2YgF1tVxgYbglR0VOsj/pMrW93b8=";
|
||||
};
|
||||
UserMerge = pkgs.fetchzip {
|
||||
url = "https://extdist.wmflabs.org/dist/extensions/UserMerge-REL1_39-b10d50e.tar.gz";
|
||||
sha256 = "sha256-bXhj1+OlOUJDbvEuc8iwqb1LLEu6cN6+C/7cAvnWPOQ=";
|
||||
};
|
||||
PluggableAuth = pkgs.fetchzip {
|
||||
url = "https://extdist.wmflabs.org/dist/extensions/PluggableAuth-REL1_39-1210fc3.tar.gz";
|
||||
sha256 = "sha256-F6bTMCzkK3kZwZGIsNE87WlZWqXXmTMhEjApO99YKR0=";
|
||||
};
|
||||
SimpleSAMLphp = pkgs.fetchzip {
|
||||
url = "https://extdist.wmflabs.org/dist/extensions/SimpleSAMLphp-REL1_39-dcf0acb.tar.gz";
|
||||
sha256 = "sha256-tCvFmb2+q2rxms+lRo5pgoI3h6GjCwXAR8XisPg03TQ=";
|
||||
};
|
||||
inherit (pkgs.mediawiki-extensions) DeleteBatch UserMerge PluggableAuth SimpleSAMLphp;
|
||||
};
|
||||
|
||||
extraConfig = let
|
||||
|
|
|
@ -0,0 +1,7 @@
|
|||
{ pkgs, lib }:
|
||||
lib.makeScope pkgs.newScope (self: {
|
||||
DeleteBatch = self.callPackage ./delete-batch { };
|
||||
PluggableAuth = self.callPackage ./pluggable-auth { };
|
||||
SimpleSAMLphp = self.callPackage ./simple-saml-php { };
|
||||
UserMerge = self.callPackage ./user-merge { };
|
||||
})
|
|
@ -0,0 +1,7 @@
|
|||
{ fetchzip }:
|
||||
|
||||
fetchzip {
|
||||
name = "mediawiki-delete-batch";
|
||||
url = "https://extdist.wmflabs.org/dist/extensions/DeleteBatch-REL1_41-5774fdd.tar.gz";
|
||||
hash = "sha256-ROkn93lf0mNXBvij9X2pMhd8LXZ0azOz7ZRaqZvhh8k=";
|
||||
}
|
|
@ -0,0 +1,7 @@
|
|||
{ fetchzip }:
|
||||
|
||||
fetchzip {
|
||||
name = "mediawiki-pluggable-auth-source";
|
||||
url = "https://extdist.wmflabs.org/dist/extensions/PluggableAuth-REL1_41-d5b3ad8.tar.gz";
|
||||
hash = "sha256-OLlkKeSlfNgWXWwDdINrYRZpYuSGRwzZHgU8EYW6rYU=";
|
||||
}
|
|
@ -0,0 +1,7 @@
|
|||
{ fetchzip }:
|
||||
|
||||
fetchzip {
|
||||
name = "mediawiki-simple-saml-php-source";
|
||||
url = "https://extdist.wmflabs.org/dist/extensions/SimpleSAMLphp-REL1_41-9ae0678.tar.gz";
|
||||
hash = "sha256-AmCaG5QXMJvi3N6zFyWylwYDt8GvyIk/0GFpM1Y0vkY=";
|
||||
}
|
|
@ -0,0 +1,66 @@
|
|||
#!/usr/bin/env nix-shell
|
||||
#!nix-shell -i python3 -p "python3.withPackages(ps: with ps; [ beautifulsoup4 requests ])"
|
||||
|
||||
import os
|
||||
from pathlib import Path
|
||||
import re
|
||||
import subprocess
|
||||
from collections import defaultdict
|
||||
from pprint import pprint
|
||||
|
||||
import bs4
|
||||
import requests
|
||||
|
||||
BASE_URL = "https://extdist.wmflabs.org/dist/extensions"
|
||||
|
||||
def fetch_plugin_list(skip_master=True) -> dict[str, list[str]]:
|
||||
content = requests.get(BASE_URL).text
|
||||
soup = bs4.BeautifulSoup(content, features="html.parser")
|
||||
result = defaultdict(list)
|
||||
for a in soup.find_all('a'):
|
||||
if skip_master and 'master' in a.text:
|
||||
continue
|
||||
split = a.text.split('-')
|
||||
result[split[0]].append(a.text)
|
||||
return result
|
||||
|
||||
def update(package_file: Path, plugin_list: dict[str, list[str]]) -> None:
|
||||
assert package_file.is_file()
|
||||
with open(package_file) as file:
|
||||
content = file.read()
|
||||
|
||||
tarball = re.search(f'url = "{BASE_URL}/(.+\.tar\.gz)";', content).group(1)
|
||||
split = tarball.split('-')
|
||||
updated_tarball = plugin_list[split[0]][-1]
|
||||
|
||||
_hash = re.search(f'hash = "(.+?)";', content).group(1)
|
||||
|
||||
out, err = subprocess.Popen(
|
||||
["nix-prefetch-url", "--unpack", "--type", "sha256", f"{BASE_URL}/{updated_tarball}"],
|
||||
stdout=subprocess.PIPE,
|
||||
stderr=subprocess.PIPE
|
||||
).communicate()
|
||||
out, err = subprocess.Popen(
|
||||
["nix", "hash", "to-sri", "--type", "sha256", out.decode().strip()],
|
||||
stdout=subprocess.PIPE,
|
||||
stderr=subprocess.PIPE
|
||||
).communicate()
|
||||
|
||||
updated_hash = out.decode().strip()
|
||||
|
||||
if tarball == updated_tarball and _hash == updated_hash:
|
||||
return
|
||||
|
||||
print(f"Updating: {tarball} ({_hash[7:14]}) -> {updated_tarball} ({updated_hash[7:14]})")
|
||||
|
||||
updated_text = re.sub(f'url = "{BASE_URL}/.+?\.tar\.gz";', f'url = "{BASE_URL}/{updated_tarball}";', content)
|
||||
updated_text = re.sub('hash = ".+";', f'hash = "{updated_hash}";', updated_text)
|
||||
with open(package_file, 'w') as file:
|
||||
file.write(updated_text)
|
||||
|
||||
if __name__ == "__main__":
|
||||
plugin_list = fetch_plugin_list()
|
||||
|
||||
for direntry in os.scandir(Path(__file__).parent):
|
||||
if direntry.is_dir():
|
||||
update(Path(direntry) / "default.nix", plugin_list)
|
|
@ -0,0 +1,7 @@
|
|||
{ fetchzip }:
|
||||
|
||||
fetchzip {
|
||||
name = "mediawiki-user-merge-source";
|
||||
url = "https://extdist.wmflabs.org/dist/extensions/UserMerge-REL1_41-a53af3b.tar.gz";
|
||||
hash = "sha256-TxUkEqMW79thYl1la2r+w9laRnd3uSYYg1xDB+1he1g=";
|
||||
}
|
Loading…
Reference in New Issue