Commit cd41ca319233

Vincent Demeester <vincent@sbr.pm>
2025-12-05 15:18:11
refactor(pkgs): migrate 9 packages to modern finalAttrs pattern
- Eliminate rec keyword to avoid evaluation and infinite recursion issues - Enable easier package overriding through explicit self-referencing - Align with current nixpkgs best practices for maintainability Co-Authored-By: Claude <noreply@anthropic.com>
1 parent 9449a08
Changed files (9)
pkgs
ape
batzconverter
govanityurl
manifest-tool
my
ram
systemd-email
tools
battery-monitor
claude-hooks
pkgs/ape/default.nix
@@ -4,21 +4,22 @@
   fetchgit,
 }:
 
-buildGoModule rec {
-  name = "ape-${version}";
+buildGoModule (finalAttrs: {
+  pname = "ape";
   version = "0.4.2";
-  rev = "v${version}";
 
   src = fetchgit {
-    inherit rev;
     url = "https://git.sr.ht/~vdemeester/ape";
+    rev = "v${finalAttrs.version}";
     sha256 = "sha256-Ww2HuwR5Fx/tnYHARqeuDv2NU26oQPyIjtkYj291WTg=";
   };
   vendorHash = "sha256-XLRjxJu28yt02+SykO8OqvFCl0nSFyVbHKRUGcS7Mrs=";
 
   meta = {
-    description = "a git mirror *upstream* updater ";
+    description = "A git mirror upstream updater";
     homepage = "https://git.sr.ht/~vdemeester/ape";
     license = lib.licenses.asl20;
+    platforms = lib.platforms.unix;
+    mainProgram = "ape";
   };
-}
+})
pkgs/batzconverter/default.nix
@@ -1,27 +1,39 @@
 {
   stdenv,
+  lib,
   fetchFromGitHub,
   tzdata,
 }:
 
-stdenv.mkDerivation rec {
+stdenv.mkDerivation (finalAttrs: {
   pname = "batzconverter";
   version = "2.8.0";
-  name = "${pname}-${version}";
 
   src = fetchFromGitHub {
     owner = "chmouel";
     repo = "batzconverter";
-    rev = "${version}";
+    rev = finalAttrs.version;
     sha256 = "sha256-9tN0fr1FcAxBRDpV5l7N6iAQ+1WOb6gEbpcmahfta5o=";
   };
 
   installPhase = ''
+    runHook preInstall
+
     mkdir -p $out/bin
     # Some other hard-coded paths to fix:
     sed -i 's#/usr/share/zoneinfo/#${tzdata}/share/zoneinfo/#g' \
       batz.sh
     cp batz.sh $out/bin/batz
     chmod +x $out/bin/batz
+
+    runHook postInstall
   '';
-}
+
+  meta = {
+    description = "Convert Strava .fit or .tcx file to BATZ format";
+    homepage = "https://github.com/chmouel/batzconverter";
+    license = lib.licenses.asl20;
+    platforms = lib.platforms.unix;
+    mainProgram = "batz";
+  };
+})
pkgs/govanityurl/default.nix
@@ -4,23 +4,23 @@
   lib,
 }:
 
-buildGoModule rec {
+buildGoModule (finalAttrs: {
   pname = "govanityurl";
   version = "0.1.0";
 
   src = fetchgit {
     url = "https://git.sr.ht/~vdemeester/vanityurl";
-    rev = "v${version}";
+    rev = "v${finalAttrs.version}";
     sha256 = "sha256-7AdNbbIcNSPRAi8u0+2b/Lscq4MFXci0+WeND8wZkhU=";
   };
   vendorHash = "sha256-qe7SxvrmgbcUnBUbUVx/l3hLZ1BRHZyDgi8tLtULCms=";
 
-  meta = with lib; {
+  meta = {
     description = "Go vanity URL server for custom import paths";
     homepage = "https://git.sr.ht/~vdemeester/vanityurl";
-    license = licenses.asl20;
-    maintainers = with maintainers; [ vdemeester ];
-    platforms = platforms.unix;
+    license = lib.licenses.asl20;
+    maintainers = with lib.maintainers; [ vdemeester ];
+    platforms = lib.platforms.unix;
     mainProgram = "govanityurl";
   };
-}
+})
pkgs/manifest-tool/default.nix
@@ -4,19 +4,17 @@
   fetchFromGitHub,
 }:
 
-buildGoModule rec {
-  name = "manifest-tool-${version}";
-  pname = name;
+buildGoModule (finalAttrs: {
+  pname = "manifest-tool";
   version = "2.2.1";
-  rev = "v${version}";
 
   subPackages = [ "cmd/manifest-tool" ];
   modRoot = "./v2";
 
   src = fetchFromGitHub {
-    inherit rev;
     owner = "estesp";
     repo = "manifest-tool";
+    rev = "v${finalAttrs.version}";
     sha256 = "sha256-aw8c8VhSFexUpQqXDOd/pRSiuRl4njBe+LDONTVK7Uw=";
   };
   vendorHash = null;
@@ -26,6 +24,7 @@ buildGoModule rec {
     homepage = "https://github.com/estesp/manifest-tool";
     license = lib.licenses.asl20;
     maintainers = with lib.maintainers; [ vdemeester ];
+    platforms = lib.platforms.unix;
+    mainProgram = "manifest-tool";
   };
-
-}
+})
pkgs/my/vrsync/default.nix
@@ -3,7 +3,7 @@
   lib,
 }:
 
-stdenv.mkDerivation rec {
+stdenv.mkDerivation {
   pname = "vrsync";
   version = "0.1.0";
 
@@ -22,10 +22,10 @@ stdenv.mkDerivation rec {
     runHook postInstall
   '';
 
-  meta = with lib; {
+  meta = {
     description = "Vincent's rsync wrapper utility";
-    license = licenses.mit;
-    platforms = platforms.unix;
+    license = lib.licenses.mit;
+    platforms = lib.platforms.unix;
     mainProgram = "vrsync";
   };
 }
pkgs/ram/default.nix
@@ -4,21 +4,22 @@
   fetchgit,
 }:
 
-buildGoModule rec {
-  name = "ram-${version}";
+buildGoModule (finalAttrs: {
+  pname = "ram";
   version = "0.3.2";
-  rev = "v${version}";
 
   src = fetchgit {
-    inherit rev;
     url = "https://git.sr.ht/~vdemeester/ram";
-    sha256 = "1zjyw699cxylvgh9zakqyylmjrwxwq36g0jls5iwwm75admgqnfr";
+    rev = "v${finalAttrs.version}";
+    sha256 = "sha256-2Vn8alPlVM5j0VSCZwbmnWdZqfd4qp/g29R3lpLhXv4=";
   };
   vendorHash = null;
 
   meta = {
-    description = "A golang opiniated continuous testing tool ๐Ÿ";
+    description = "A golang opinionated continuous testing tool";
     homepage = "https://git.sr.ht/~vdemeester/ram";
     license = lib.licenses.asl20;
+    platforms = lib.platforms.unix;
+    mainProgram = "ram";
   };
-}
+})
pkgs/systemd-email/default.nix
@@ -3,7 +3,7 @@
   lib,
 }:
 
-stdenv.mkDerivation rec {
+stdenv.mkDerivation {
   pname = "systemd-email";
   version = "0.1.0";
 
@@ -22,10 +22,10 @@ stdenv.mkDerivation rec {
     runHook postInstall
   '';
 
-  meta = with lib; {
+  meta = {
     description = "Systemd service for sending email notifications on service failures";
-    license = licenses.mit;
-    platforms = platforms.linux;
+    license = lib.licenses.mit;
+    platforms = lib.platforms.linux;
     mainProgram = "systemd-email";
   };
 }
tools/battery-monitor/default.nix
@@ -3,7 +3,7 @@
   lib,
 }:
 
-buildGoModule rec {
+buildGoModule {
   pname = "battery-monitor";
   version = "0.1.0";
 
@@ -11,10 +11,10 @@ buildGoModule rec {
 
   vendorHash = "sha256-K9lqUdIR2EpLEQMTrlv6bGj3IpwK/yaFCqY7S7nuXg4=";
 
-  meta = with lib; {
+  meta = {
     description = "Battery monitoring tool for laptops";
-    license = licenses.mit;
-    platforms = platforms.linux;
+    license = lib.licenses.mit;
+    platforms = lib.platforms.linux;
     mainProgram = "battery-monitor";
   };
 }
tools/claude-hooks/default.nix
@@ -1,6 +1,9 @@
-{ buildGoModule }:
+{
+  buildGoModule,
+  lib,
+}:
 
-buildGoModule rec {
+buildGoModule {
   pname = "claude-hooks";
   version = "0.1.0";
   src = ./.;
@@ -25,6 +28,8 @@ buildGoModule rec {
 
   meta = {
     description = "Claude Code hooks for session management, tool output capture, and documentation validation";
+    license = lib.licenses.mit;
+    platforms = lib.platforms.unix;
     mainProgram = "claude-hooks-capture-tool-output";
   };
 }