From bf8f67dce6c1f815e9b446f5e0505cc54b1a5de5 Mon Sep 17 00:00:00 2001 From: Greg Hellings Date: Thu, 12 Mar 2026 21:04:49 -0500 Subject: [PATCH] chore: make zim updater more awesome --- pkgs/zim/go.mod | 3 +++ pkgs/zim/updater.go | 13 +------------ pkgs/zim/updater.nix | 24 +++++------------------- 3 files changed, 9 insertions(+), 31 deletions(-) create mode 100644 pkgs/zim/go.mod diff --git a/pkgs/zim/go.mod b/pkgs/zim/go.mod new file mode 100644 index 0000000..5ac9cf7 --- /dev/null +++ b/pkgs/zim/go.mod @@ -0,0 +1,3 @@ +module src.thehellings.com/greg/nixos/pkgs/zim/updater + +go 1.25.5 diff --git a/pkgs/zim/updater.go b/pkgs/zim/updater.go index 9aedf7d..2be4745 100644 --- a/pkgs/zim/updater.go +++ b/pkgs/zim/updater.go @@ -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 // in the existing file fmt.Printf("Fetching hash for %s\n", file) - cmd := exec.Command("nix-prefetch", - "--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), - ) + cmd := exec.Command( "nix-prefetch-url", fmt.Sprintf("%s/%s/%s.torrent", BASE, category, file)) out, err := cmd.Output() if err != nil { fmt.Printf("Error fetching hash for %s (category: %s, language: %s): %v\n", file, category, language, err) diff --git a/pkgs/zim/updater.nix b/pkgs/zim/updater.nix index cbdb526..f63d4d2 100644 --- a/pkgs/zim/updater.nix +++ b/pkgs/zim/updater.nix @@ -1,22 +1,8 @@ { - writeShellApplication, - nix-prefetch, - gcc, - go, - ... + buildGoModule, }: -let - goscript = ./updater.go; -in -writeShellApplication { - name = "update-zims"; - runtimeInputs = [ - gcc - go - nix-prefetch - ]; - text = '' - go build -o updater ${goscript} - ./updater "$@" - ''; +buildGoModule { + name = "updater"; + src = ./.; + vendorHash = null; }