about summary refs log tree commit diff
path: root/pkgs/tools/text
diff options
context:
space:
mode:
authorAlexis Hildebrandt <afh@surryhill.net>2024-03-26 15:18:09 +0100
committerAlexis Hildebrandt <afh@surryhill.net>2024-04-14 22:06:35 +0200
commitc4415d2272ec2be13549086c3b87abc797073d2a (patch)
tree2939a42c8ee75014d34aa4595b02f7e1ba05487d /pkgs/tools/text
parent8f72bd17eae0d1a7fcb63e3f1a3baa7dadebef68 (diff)
validator-nu: fix version output and modernize package
Diffstat (limited to 'pkgs/tools/text')
-rw-r--r--pkgs/tools/text/validator-nu/default.nix27
1 files changed, 21 insertions, 6 deletions
diff --git a/pkgs/tools/text/validator-nu/default.nix b/pkgs/tools/text/validator-nu/default.nix
index 17f9a5ba8b595..56c227b46da45 100644
--- a/pkgs/tools/text/validator-nu/default.nix
+++ b/pkgs/tools/text/validator-nu/default.nix
@@ -6,6 +6,7 @@
 , python3
 , stdenvNoCC
 , lib
+, testers
 }:
 
 let
@@ -40,29 +41,43 @@ let
   };
 
 in
-stdenvNoCC.mkDerivation rec {
+stdenvNoCC.mkDerivation (finalAttrs: {
   inherit pname version src;
 
   nativeBuildInputs = [ git jdk_headless makeWrapper python3 ];
 
+  postPatch = ''
+    substituteInPlace build/build.py --replace-warn \
+      'validatorVersion = "%s.%s.%s" % (year, month, day)' \
+      'validatorVersion = "${finalAttrs.version}"'
+  '';
+
   buildPhase = ''
     ln -s '${deps}/dependencies' '${deps}/extras' .
     JAVA_HOME='${jdk_headless}' python checker.py build
   '';
 
   installPhase = ''
+    runHook preInstall
+
     mkdir -p "$out/bin" "$out/share/java"
     mv build/dist/vnu.jar "$out/share/java/"
     makeWrapper "${jre_headless}/bin/java" "$out/bin/vnu" \
       --add-flags "-jar '$out/share/java/vnu.jar'"
+
+    runHook postInstall
   '';
 
-  meta = with lib; {
+  passthru.tests.version = testers.testVersion {
+    package = finalAttrs.finalPackage;
+  };
+
+  meta = {
     description = "Helps you catch problems in your HTML/CSS/SVG";
     homepage = "https://validator.github.io/validator/";
-    license = licenses.mit;
-    maintainers = with maintainers; [ andersk ivan ];
+    license = lib.licenses.mit;
+    maintainers = with lib.maintainers; [ andersk ivan ];
     mainProgram = "vnu";
-    sourceProvenance = with sourceTypes; [ binaryBytecode fromSource ];
+    sourceProvenance = with lib.sourceTypes; [ binaryBytecode fromSource ];
   };
-}
+})