Update zims

This commit is contained in:
Greg Hellings
2025-06-24 22:44:32 -05:00
parent 86a371b0aa
commit 853562128e
3 changed files with 40 additions and 27 deletions
+17 -5
View File
@@ -2,7 +2,7 @@
callPackage, callPackage,
fetchtorrent, fetchtorrent,
lib, lib,
stdenv, stdenvNoCC,
... ...
}: }:
let let
@@ -10,9 +10,21 @@ let
# Converts the inputs from the file into a fetchtorrent command # Converts the inputs from the file into a fetchtorrent command
zim = zim =
type: val: type: val:
(fetchtorrent { stdenvNoCC.mkDerivation (finalAttrs: {
inherit (val) hash name; inherit (val) name;
url = "https://download.kiwix.org/zim/${type}/${val.name}.torrent"; src = (
fetchtorrent {
inherit (val) hash;
url = "https://download.kiwix.org/zim/${type}/${val.name}.torrent";
backend = "rqbit";
postUnpack = "ls -lR";
}
);
phases = [ "installPhase" ];
installPhase = ''
ls -lR ${finalAttrs.src}
cp ${finalAttrs.src} $out
'';
}); });
rawZims = builtins.fromJSON (builtins.readFile ./zim/blobs.json); rawZims = builtins.fromJSON (builtins.readFile ./zim/blobs.json);
# Uses the function above to convert the JSON into a structure of fetchtorrent derivations # Uses the function above to convert the JSON into a structure of fetchtorrent derivations
@@ -26,7 +38,7 @@ let
) )
); );
in in
stdenv.mkDerivation { stdenvNoCC.mkDerivation {
name = "zims"; name = "zims";
version = "2024-10"; version = "2024-10";
+10 -10
View File
@@ -5,7 +5,7 @@
"hash": "sha256-pQpattmS9VmO3ZIQUFn66az8GSmB4IvYhTTCFn6SUmo=" "hash": "sha256-pQpattmS9VmO3ZIQUFn66az8GSmB4IvYhTTCFn6SUmo="
}, },
"phet": { "phet": {
"name": "phet_en_all_2023-04.zim", "name": "phet_en_all_2025-03.zim",
"hash": "sha256-pQpattmS9VmO3ZIQUFn66az8GSmB4IvYhTTCFn6SUmo=" "hash": "sha256-pQpattmS9VmO3ZIQUFn66az8GSmB4IvYhTTCFn6SUmo="
}, },
"wikibooks": { "wikibooks": {
@@ -21,8 +21,8 @@
"hash": "sha256-pQpattmS9VmO3ZIQUFn66az8GSmB4IvYhTTCFn6SUmo=" "hash": "sha256-pQpattmS9VmO3ZIQUFn66az8GSmB4IvYhTTCFn6SUmo="
}, },
"wikiversity": { "wikiversity": {
"name": "wikiversity_en_all_maxi_2021-03.zim", "name": "wikiversity_en_all_maxi_2025-05.zim",
"hash": "sha256-w/3J2neHPWbz1kK2qR0OB64mkwuDI7RJMuoAWz9yyZs=" "hash": "sha256-pQpattmS9VmO3ZIQUFn66az8GSmB4IvYhTTCFn6SUmo="
}, },
"wiktionary": { "wiktionary": {
"name": "wiktionary_en_all_nopic_2024-05.zim", "name": "wiktionary_en_all_nopic_2024-05.zim",
@@ -35,19 +35,19 @@
"hash": "sha256-pQpattmS9VmO3ZIQUFn66az8GSmB4IvYhTTCFn6SUmo=" "hash": "sha256-pQpattmS9VmO3ZIQUFn66az8GSmB4IvYhTTCFn6SUmo="
}, },
"phet": { "phet": {
"name": "phet_fr_all_2023-04.zim", "name": "phet_fr_all_2025-03.zim",
"hash": "sha256-pQpattmS9VmO3ZIQUFn66az8GSmB4IvYhTTCFn6SUmo=" "hash": "sha256-pQpattmS9VmO3ZIQUFn66az8GSmB4IvYhTTCFn6SUmo="
}, },
"wikibooks": { "wikibooks": {
"name": "wikibooks_fr_all_maxi_2024-06.zim", "name": "wikibooks_fr_all_maxi_2025-06.zim",
"hash": "sha256-w/3J2neHPWbz1kK2qR0OB64mkwuDI7RJMuoAWz9yyZs=" "hash": "sha256-pQpattmS9VmO3ZIQUFn66az8GSmB4IvYhTTCFn6SUmo="
}, },
"wikipedia": { "wikipedia": {
"name": "wikipedia_fr_all_maxi_2024-05.zim", "name": "wikipedia_fr_all_maxi_2024-05.zim",
"hash": "sha256-pQpattmS9VmO3ZIQUFn66az8GSmB4IvYhTTCFn6SUmo=" "hash": "sha256-pQpattmS9VmO3ZIQUFn66az8GSmB4IvYhTTCFn6SUmo="
}, },
"wikisource": { "wikisource": {
"name": "wikisource_fr_all_maxi_2022-04.zim", "name": "wikisource_fr_all_maxi_2025-06.zim",
"hash": "sha256-pQpattmS9VmO3ZIQUFn66az8GSmB4IvYhTTCFn6SUmo=" "hash": "sha256-pQpattmS9VmO3ZIQUFn66az8GSmB4IvYhTTCFn6SUmo="
}, },
"wikiversity": { "wikiversity": {
@@ -55,17 +55,17 @@
"hash": "sha256-pQpattmS9VmO3ZIQUFn66az8GSmB4IvYhTTCFn6SUmo=" "hash": "sha256-pQpattmS9VmO3ZIQUFn66az8GSmB4IvYhTTCFn6SUmo="
}, },
"wiktionary": { "wiktionary": {
"name": "wiktionary_fr_all_nopic_2024-06.zim", "name": "wiktionary_fr_all_nopic_2025-03.zim",
"hash": "sha256-pQpattmS9VmO3ZIQUFn66az8GSmB4IvYhTTCFn6SUmo=" "hash": "sha256-pQpattmS9VmO3ZIQUFn66az8GSmB4IvYhTTCFn6SUmo="
} }
}, },
"ht": { "ht": {
"phet": { "phet": {
"name": "phet_ht_all_2023-04.zim", "name": "phet_ht_all_2025-03.zim",
"hash": "sha256-pQpattmS9VmO3ZIQUFn66az8GSmB4IvYhTTCFn6SUmo=" "hash": "sha256-pQpattmS9VmO3ZIQUFn66az8GSmB4IvYhTTCFn6SUmo="
}, },
"wikipedia": { "wikipedia": {
"name": "wikipedia_ht_all_maxi_2024-06.zim", "name": "wikipedia_ht_all_maxi_2025-05.zim",
"hash": "sha256-pQpattmS9VmO3ZIQUFn66az8GSmB4IvYhTTCFn6SUmo=" "hash": "sha256-pQpattmS9VmO3ZIQUFn66az8GSmB4IvYhTTCFn6SUmo="
}, },
"wikisource": { "wikisource": {
+13 -12
View File
@@ -81,19 +81,20 @@ func getHash(ch chan result, file, category, language string) {
// in the existing file // in the existing file
fmt.Printf("Fetching hash for %s\n", file) fmt.Printf("Fetching hash for %s\n", file)
cmd := exec.Command("nix-prefetch", cmd := exec.Command("nix-prefetch",
"--option", "--option",
"extra-experimental-features", "extra-experimental-features",
"flakes", "flakes",
fmt.Sprintf(`fetchtorrent { fmt.Sprintf(`fetchtorrent {
url="%s/%s/%s.torrent"; url="%s/%s/%s.torrent";
hash="sha256-AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA="; hash="sha256-AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA=";
backend="rqbit";
}`, BASE, category, file), }`, BASE, category, file),
) )
out, err := cmd.Output() out, err := cmd.Output()
if err != nil { if err != nil {
panic(err) panic(err)
} }
ch <- result{ category, language, strings.TrimSpace(string(out)) } ch <- result{category, language, strings.TrimSpace(string(out))}
} }
func outputIsValid(o map[string]map[string]Zim) bool { func outputIsValid(o map[string]map[string]Zim) bool {
@@ -128,7 +129,7 @@ func main() {
if _, ok := output[lang]; !ok { if _, ok := output[lang]; !ok {
output[lang] = make(map[string]Zim) output[lang] = make(map[string]Zim)
} }
output[lang][t] = Zim{ file, "" } output[lang][t] = Zim{file, ""}
go getHash(comms, file, t, lang) go getHash(comms, file, t, lang)
} }
} }
@@ -144,6 +145,6 @@ func main() {
break break
} }
} }
ret, _ := json.Marshal(output) ret, _ := json.MarshalIndent(output, " ", "")
fmt.Println(string(ret)) fmt.Println(string(ret))
} }