NixOS / nixos-search

Search NixOS packages and options
https://search.nixos.org
MIT License
384 stars 98 forks source link

fix: wording when a package has no platforms list #774

Closed Aleksanaa closed 1 month ago

Aleksanaa commented 2 months ago

"This package is not available on any platform" is misleading and confusing, so I changed that.

Related https://github.com/NixOS/nixpkgs/issues/270206 Closes https://github.com/NixOS/nixos-search/issues/734

Aleksanaa commented 1 month ago

Wait, I didn't look carefully at how our search works, does it only list x86_64-linux, aarch64-linux, i686-linux, x86_64-darwin and aarch64-darwin? Have we stated this somewhere?

If so, maybe we can change the error message a little better, but I have no idea how.

dasJ commented 1 month ago

@garbas this should be ready for merge ;)

wegank commented 1 month ago

If so, maybe we can change the error message a little better, but I have no idea how.

Maybe try deferring filterPlatforms to have a non-empty item.source.platforms even if it doesn't intersect the five platforms?

diff --git a/frontend/src/Page/Packages.elm b/frontend/src/Page/Packages.elm
index b951294..5bf6eab 100644
--- a/frontend/src/Page/Packages.elm
+++ b/frontend/src/Page/Packages.elm
@@ -492,8 +492,11 @@ viewResultItem nixosChannels channel showInstallDetails show item =
                         (if List.isEmpty item.source.platforms then
                             [ p [] [ text "This package does not list its available platforms." ] ]

+                         else if List.isEmpty (filterPlatforms item.source.platforms) then
+                            [ p [] [ text "This package is not available on platforms supported by Hydra." ] ]
+
                          else
-                            [ ul [] (List.map showPlatform (List.sort item.source.platforms)) ]
+                            [ ul [] (List.map showPlatform (List.sort (filterPlatforms item.source.platforms))) ]
                         )
                     )
                 ]
@@ -962,7 +965,7 @@ decodeResultItemSource =
         |> Json.Decode.Pipeline.required "package_longDescription" (Json.Decode.nullable Json.Decode.string)
         |> Json.Decode.Pipeline.required "package_license" (Json.Decode.list decodeResultPackageLicense)
         |> Json.Decode.Pipeline.required "package_maintainers" (Json.Decode.list decodeResultPackageMaintainer)
-        |> Json.Decode.Pipeline.required "package_platforms" (Json.Decode.map filterPlatforms (Json.Decode.list Json.Decode.string))
+        |> Json.Decode.Pipeline.required "package_platforms" (Json.Decode.list Json.Decode.string)
         |> Json.Decode.Pipeline.required "package_position" (Json.Decode.nullable Json.Decode.string)
         |> Json.Decode.Pipeline.required "package_homepage" decodeHomepage
         |> Json.Decode.Pipeline.required "package_system" Json.Decode.string