From 48d8b7fe412e0da25ebc60b0a90d5958b7bf7016 Mon Sep 17 00:00:00 2001 From: Xavier Lambein Date: Mon, 22 Aug 2022 12:24:31 +0200 Subject: [PATCH] google-cloud-sdk: simplify `toNixPlatform` implementation Co-authored-by: Jonas Chevalier --- pkgs/tools/admin/google-cloud-sdk/components.nix | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/pkgs/tools/admin/google-cloud-sdk/components.nix b/pkgs/tools/admin/google-cloud-sdk/components.nix index 1deaffcc114e..99069fe4fd9e 100644 --- a/pkgs/tools/admin/google-cloud-sdk/components.nix +++ b/pkgs/tools/admin/google-cloud-sdk/components.nix @@ -25,12 +25,10 @@ let # Convert an archicecture + OS to a Nix platform toNixPlatform = arch: os: let - arch' = builtins.getAttr arch arches; - os' = builtins.getAttr os oses; + arch' = arches.${arch} or (throw "unsupported architecture '${arch}'"); + os' = oses.${os} or (throw "unsupported OS '${os}'"); in - if (builtins.hasAttr arch arches && builtins.hasAttr os oses) - then "${arch'}-${os'}" - else throw "unsupported architecture '${arch}' and/or os '${os}'"; + "${arch'}-${os'}"; # All architectures that are supported allArches = builtins.attrValues arches;