From 853562128e648b394d47d566b19025a3b67c1500 Mon Sep 17 00:00:00 2001 From: Greg Hellings Date: Tue, 24 Jun 2025 22:44:32 -0500 Subject: [PATCH] Update zims --- pkgs/zim.nix | 22 +++++++++++++++++----- pkgs/zim/blobs.json | 20 ++++++++++---------- pkgs/zim/updater.go | 25 +++++++++++++------------ 3 files changed, 40 insertions(+), 27 deletions(-) diff --git a/pkgs/zim.nix b/pkgs/zim.nix index fa5ca1b..873089a 100644 --- a/pkgs/zim.nix +++ b/pkgs/zim.nix @@ -2,7 +2,7 @@ callPackage, fetchtorrent, lib, - stdenv, + stdenvNoCC, ... }: let @@ -10,9 +10,21 @@ let # Converts the inputs from the file into a fetchtorrent command zim = type: val: - (fetchtorrent { - inherit (val) hash name; - url = "https://download.kiwix.org/zim/${type}/${val.name}.torrent"; + stdenvNoCC.mkDerivation (finalAttrs: { + inherit (val) name; + 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); # Uses the function above to convert the JSON into a structure of fetchtorrent derivations @@ -26,7 +38,7 @@ let ) ); in -stdenv.mkDerivation { +stdenvNoCC.mkDerivation { name = "zims"; version = "2024-10"; diff --git a/pkgs/zim/blobs.json b/pkgs/zim/blobs.json index 0ddc9d2..7558223 100644 --- a/pkgs/zim/blobs.json +++ b/pkgs/zim/blobs.json @@ -5,7 +5,7 @@ "hash": "sha256-pQpattmS9VmO3ZIQUFn66az8GSmB4IvYhTTCFn6SUmo=" }, "phet": { - "name": "phet_en_all_2023-04.zim", + "name": "phet_en_all_2025-03.zim", "hash": "sha256-pQpattmS9VmO3ZIQUFn66az8GSmB4IvYhTTCFn6SUmo=" }, "wikibooks": { @@ -21,8 +21,8 @@ "hash": "sha256-pQpattmS9VmO3ZIQUFn66az8GSmB4IvYhTTCFn6SUmo=" }, "wikiversity": { - "name": "wikiversity_en_all_maxi_2021-03.zim", - "hash": "sha256-w/3J2neHPWbz1kK2qR0OB64mkwuDI7RJMuoAWz9yyZs=" + "name": "wikiversity_en_all_maxi_2025-05.zim", + "hash": "sha256-pQpattmS9VmO3ZIQUFn66az8GSmB4IvYhTTCFn6SUmo=" }, "wiktionary": { "name": "wiktionary_en_all_nopic_2024-05.zim", @@ -35,19 +35,19 @@ "hash": "sha256-pQpattmS9VmO3ZIQUFn66az8GSmB4IvYhTTCFn6SUmo=" }, "phet": { - "name": "phet_fr_all_2023-04.zim", + "name": "phet_fr_all_2025-03.zim", "hash": "sha256-pQpattmS9VmO3ZIQUFn66az8GSmB4IvYhTTCFn6SUmo=" }, "wikibooks": { - "name": "wikibooks_fr_all_maxi_2024-06.zim", - "hash": "sha256-w/3J2neHPWbz1kK2qR0OB64mkwuDI7RJMuoAWz9yyZs=" + "name": "wikibooks_fr_all_maxi_2025-06.zim", + "hash": "sha256-pQpattmS9VmO3ZIQUFn66az8GSmB4IvYhTTCFn6SUmo=" }, "wikipedia": { "name": "wikipedia_fr_all_maxi_2024-05.zim", "hash": "sha256-pQpattmS9VmO3ZIQUFn66az8GSmB4IvYhTTCFn6SUmo=" }, "wikisource": { - "name": "wikisource_fr_all_maxi_2022-04.zim", + "name": "wikisource_fr_all_maxi_2025-06.zim", "hash": "sha256-pQpattmS9VmO3ZIQUFn66az8GSmB4IvYhTTCFn6SUmo=" }, "wikiversity": { @@ -55,17 +55,17 @@ "hash": "sha256-pQpattmS9VmO3ZIQUFn66az8GSmB4IvYhTTCFn6SUmo=" }, "wiktionary": { - "name": "wiktionary_fr_all_nopic_2024-06.zim", + "name": "wiktionary_fr_all_nopic_2025-03.zim", "hash": "sha256-pQpattmS9VmO3ZIQUFn66az8GSmB4IvYhTTCFn6SUmo=" } }, "ht": { "phet": { - "name": "phet_ht_all_2023-04.zim", + "name": "phet_ht_all_2025-03.zim", "hash": "sha256-pQpattmS9VmO3ZIQUFn66az8GSmB4IvYhTTCFn6SUmo=" }, "wikipedia": { - "name": "wikipedia_ht_all_maxi_2024-06.zim", + "name": "wikipedia_ht_all_maxi_2025-05.zim", "hash": "sha256-pQpattmS9VmO3ZIQUFn66az8GSmB4IvYhTTCFn6SUmo=" }, "wikisource": { diff --git a/pkgs/zim/updater.go b/pkgs/zim/updater.go index 3a71293..0cebf8c 100644 --- a/pkgs/zim/updater.go +++ b/pkgs/zim/updater.go @@ -81,19 +81,20 @@ func getHash(ch chan result, file, category, language string) { // in the existing file fmt.Printf("Fetching hash for %s\n", file) cmd := exec.Command("nix-prefetch", - "--option", - "extra-experimental-features", - "flakes", - fmt.Sprintf(`fetchtorrent { + "--option", + "extra-experimental-features", + "flakes", + fmt.Sprintf(`fetchtorrent { url="%s/%s/%s.torrent"; hash="sha256-AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA="; + backend="rqbit"; }`, BASE, category, file), - ) - out, err := cmd.Output() - if err != nil { - panic(err) - } - ch <- result{ category, language, strings.TrimSpace(string(out)) } + ) + out, err := cmd.Output() + if err != nil { + panic(err) + } + ch <- result{category, language, strings.TrimSpace(string(out))} } func outputIsValid(o map[string]map[string]Zim) bool { @@ -128,7 +129,7 @@ func main() { if _, ok := output[lang]; !ok { output[lang] = make(map[string]Zim) } - output[lang][t] = Zim{ file, "" } + output[lang][t] = Zim{file, ""} go getHash(comms, file, t, lang) } } @@ -144,6 +145,6 @@ func main() { break } } - ret, _ := json.Marshal(output) + ret, _ := json.MarshalIndent(output, " ", "") fmt.Println(string(ret)) }