Re: [PATCH] EFI Loader: use correct arch suffix

Alyssa Ross
2022-09-27T11:18:32Z

[-- Attachment #1: Type: text/plain, Size: 2025 bytes --]

Ivan Nikolaenko <ivan.nikolaenko@unikie.com> writes:

> Previously there were hardcoded "x64" in EFI loaders' filenames.
>
> Signed-off-by: Ivan Nikolaenko <ivan.nikolaenko@unikie.com>
> ---
> img/combined/default.nix | 5 +++--
> img/live/Makefile | 2 +-
> img/live/default.nix | 5 +++--
> nix/eval-config.nix | 11 ++++++++++-
> 4 files changed, 17 insertions(+), 6 deletions(-)

Thanks for looking at this. I knew this would come up at some point!

Your patch looks good, except:

> diff --git a/nix/eval-config.nix b/nix/eval-config.nix
> index 467f877..4234321 100644
> --- a/nix/eval-config.nix
> +++ b/nix/eval-config.nix
> @@ -8,6 +8,15 @@
> else {}
> }:
>
> -({ pkgs ? import <nixpkgs> {} }: {
> +({ pkgs ? import <nixpkgs> {} }: with pkgs; {
> inherit pkgs;
> +
> + archSuffix =
> + if pkgs.stdenv.isx86_64 then
> + "x64"
> + else if pkgs.stdenv.isAarch64 then
> + "aa64"
> + else
> + throw "Unsupported architecture";
> +
> }) config
> --
> 2.25.1

I don't really want this file to turn into an unstructured list of
global constants, but I think there might be a better way:

Nixpkgs already has an unexposed mapping of Nixpkgs platforms to EFI
architecture names[1], so it would be a shame to have to duplicate it
ourselves. What if instead, we moved that list somewhere accessible in
Nixpkgs, like how Nixpkgs already exposes the Linux and QEMU names for
architectures[2]? Then we could just access stdenv.hostPlatform.efiArch
or whatever in our Nix expressions, and so could Nixpkgs.

I imagine that'd be a welcome (and small) Nixpkgs refactoring, and I'd
gladly backport it to Spectrum's Nixpkgs immediately after it was
accepted upstream.

[1]: https://github.com/NixOS/nixpkgs/blob/68770d269df8d7d8c7deba87156f66b0f997c071/nixos/modules/installer/cd-dvd/iso-image.nix#L434-L445
[2]: https://github.com/NixOS/nixpkgs/blob/68770d269df8d7d8c7deba87156f66b0f997c071/lib/systems/default.nix#L118

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 832 bytes --]