chore: make zim updater more awesome
This commit is contained in:
@@ -0,0 +1,3 @@
|
|||||||
|
module src.thehellings.com/greg/nixos/pkgs/zim/updater
|
||||||
|
|
||||||
|
go 1.25.5
|
||||||
+1
-12
@@ -83,18 +83,7 @@ func getHash(ch chan result, file, category, language string) {
|
|||||||
// TODO: Only call this if the file doesn't already have a hash
|
// TODO: Only call this if the file doesn't already have a hash
|
||||||
// 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-url", fmt.Sprintf("%s/%s/%s.torrent", BASE, category, file))
|
||||||
"--option",
|
|
||||||
"extra-experimental-features",
|
|
||||||
"flakes",
|
|
||||||
"--check-store",
|
|
||||||
fmt.Sprintf(`fetchtorrent {
|
|
||||||
url="%s/%s/%s.torrent";
|
|
||||||
hash="sha256-AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA=";
|
|
||||||
backend="transmission";
|
|
||||||
postUnpack="mkdir -p $downloadedDirectory/tmp; mv $downloadedDirectory/*.zim $downloadedDirectory/tmp";
|
|
||||||
}`, BASE, category, file),
|
|
||||||
)
|
|
||||||
out, err := cmd.Output()
|
out, err := cmd.Output()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
fmt.Printf("Error fetching hash for %s (category: %s, language: %s): %v\n", file, category, language, err)
|
fmt.Printf("Error fetching hash for %s (category: %s, language: %s): %v\n", file, category, language, err)
|
||||||
|
|||||||
+5
-19
@@ -1,22 +1,8 @@
|
|||||||
{
|
{
|
||||||
writeShellApplication,
|
buildGoModule,
|
||||||
nix-prefetch,
|
|
||||||
gcc,
|
|
||||||
go,
|
|
||||||
...
|
|
||||||
}:
|
}:
|
||||||
let
|
buildGoModule {
|
||||||
goscript = ./updater.go;
|
name = "updater";
|
||||||
in
|
src = ./.;
|
||||||
writeShellApplication {
|
vendorHash = null;
|
||||||
name = "update-zims";
|
|
||||||
runtimeInputs = [
|
|
||||||
gcc
|
|
||||||
go
|
|
||||||
nix-prefetch
|
|
||||||
];
|
|
||||||
text = ''
|
|
||||||
go build -o updater ${goscript}
|
|
||||||
./updater "$@"
|
|
||||||
'';
|
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user