From ee0f02af4467e7e67c06b0234571c3be45bc0423 Mon Sep 17 00:00:00 2001 From: Samuel Dionne-Riel Date: Wed, 8 Apr 2026 14:23:13 -0400 Subject: [PATCH] lib.meta: Drop incorrect `cpePatchVersionInUpdateWithVendor` and `cpePatchVersionInUpdateWithVendor` See the previous commits for the explanation as to why this is an invalid value. See the follow-up commits for the complete removal of the helpers. --- lib/meta.nix | 128 --------------------------------------------------- 1 file changed, 128 deletions(-) diff --git a/lib/meta.nix b/lib/meta.nix index 1a1676f56aff..3341caf0e0fb 100644 --- a/lib/meta.nix +++ b/lib/meta.nix @@ -633,132 +633,4 @@ rec { update = "*"; }; - /** - Alternate version of [`lib.meta.cpePatchVersionInUpdateWithVendor`](#function-library-lib.meta.cpePatchVersionInUpdateWithVendor). - If `cpePatchVersionInUpdateWithVendor` succeeds, returns an attribute set with `success` set to `true` and `value` set to the result. - Otherwise, `success` is set to `false` and `error` is set to the string representation of the error. - - # Inputs - - `vendor` - - : package's vendor - - `version` - - : package's version - - # Type - - ``` - tryCPEPatchVersionInUpdateWithVendor :: String -> String -> ({ success = true; value :: { update :: String; vendor :: String; version :: String; }; } | { success = false; error :: String; }) - ``` - - # Examples - :::{.example} - ## `lib.meta.tryCPEPatchVersionInUpdateWithVendor` usage example - - ```nix - lib.meta.tryCPEPatchVersionInUpdateWithVendor "gnu" "1.2.3" - => { - success = true; - value = { - vendor = "gnu"; - version = "1.2"; - update = "3"; - }; - } - ``` - - ::: - :::{.example} - ## `lib.meta.cpePatchVersionInUpdateWithVendor` error example - - ```nix - lib.meta.tryCPEPatchVersionInUpdateWithVendor "gnu" "5.3p0" - => { - success = false; - error = "version 5.3p0 doesn't match regex `([0-9]+\\.[0-9]+)\\.([0-9]+)`"; - } - ``` - - ::: - */ - tryCPEPatchVersionInUpdateWithVendor = - vendor: version: - let - regex = "([0-9]+\\.[0-9]+)\\.([0-9]+)"; - # we have to call toString here in case version is an attrset with __toString attribute - versionMatch = builtins.match regex (toString version); - in - if versionMatch == null then - { - success = false; - error = "version ${version} doesn't match regex `${regex}`"; - } - else - { - success = true; - value = { - inherit vendor; - version = elemAt versionMatch 0; - update = elemAt versionMatch 1; - }; - }; - - /** - Generate [CPE parts](#var-meta-identifiers-cpeParts) from inputs. Copies `vendor` to the result. When `version` matches `X.Y.Z` where all parts are numerical, sets `version` and `update` fields to `X.Y` and `Z`. Throws an error if the version doesn't match the expected template. - - # Inputs - - `vendor` - - : package's vendor - - `version` - - : package's version - - # Type - - ``` - cpePatchVersionInUpdateWithVendor :: String -> String -> { update :: String; vendor :: String; version :: String; } - ``` - - # Examples - :::{.example} - ## `lib.meta.cpePatchVersionInUpdateWithVendor` usage example - - ```nix - lib.meta.cpePatchVersionInUpdateWithVendor "gnu" "1.2.3" - => { - vendor = "gnu"; - version = "1.2"; - update = "3"; - } - ``` - - ::: - :::{.example} - ## `lib.meta.cpePatchVersionInUpdateWithVendor` usage in derivations - - ```nix - mkDerivation rec { - version = "1.2.3"; - # ... - meta = { - # ... - identifiers.cpeParts = lib.meta.cpePatchVersionInUpdateWithVendor "gnu" version; - }; - } - ``` - - ::: - */ - cpePatchVersionInUpdateWithVendor = - vendor: version: - let - result = tryCPEPatchVersionInUpdateWithVendor vendor version; - in - if result.success then result.value else throw result.error; }