From 50c6120a3e14a15b507f07237d4748c6ebacbba5 Mon Sep 17 00:00:00 2001 From: Raito Bezarius Date: Sat, 16 Sep 2023 04:02:37 +0200 Subject: [PATCH 1/2] buildUBoot: supports Python scripts with their own environment Sometimes, U-Boot has interesting Python scripts in tools/, the issue is that they rely on implicit dependencies described by their code itself. For this, we offer an attribute set-style option to install Python scripts with specific dependencies. For example, you could do `pythonScriptsToInstall."tools/efivar.py" = python3.withPackages (ps: [ ps.pyopenssl ]);` which will be added in a next PR. --- pkgs/misc/uboot/default.nix | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/pkgs/misc/uboot/default.nix b/pkgs/misc/uboot/default.nix index 9ac761601270..6c002851db6f 100644 --- a/pkgs/misc/uboot/default.nix +++ b/pkgs/misc/uboot/default.nix @@ -34,6 +34,7 @@ let version ? null , src ? null , filesToInstall + , pythonScriptsToInstall ? { } , installDir ? "$out" , defconfig , extraConfig ? "" @@ -52,6 +53,10 @@ let ] ++ extraPatches; postPatch = '' + ${lib.concatMapStrings (script: '' + substituteInPlace ${script} \ + --replace "#!/usr/bin/env python3" "#!${pythonScriptsToInstall.${script}}/bin/python3" + '') (builtins.attrNames pythonScriptsToInstall)} patchShebangs tools patchShebangs arch/arm/mach-rockchip ''; @@ -105,12 +110,12 @@ let runHook preInstall mkdir -p ${installDir} - cp ${lib.concatStringsSep " " filesToInstall} ${installDir} + cp ${lib.concatStringsSep " " (filesToInstall ++ builtins.attrNames pythonScriptsToInstall)} ${installDir} mkdir -p "$out/nix-support" ${lib.concatMapStrings (file: '' echo "file binary-dist ${installDir}/${builtins.baseNameOf file}" >> "$out/nix-support/hydra-build-products" - '') filesToInstall} + '') (filesToInstall ++ builtins.attrNames pythonScriptsToInstall)} runHook postInstall ''; @@ -123,7 +128,7 @@ let license = licenses.gpl2; maintainers = with maintainers; [ bartsch dezgeg samueldr lopsided98 ]; } // extraMeta; - } // removeAttrs args [ "extraMeta" ])); + } // removeAttrs args [ "extraMeta" "pythonScriptsToInstall" ])); in { inherit buildUBoot; From 32104c2fec1299dcd2e1253dfcfc1894b1096469 Mon Sep 17 00:00:00 2001 From: Raito Bezarius Date: Sat, 16 Sep 2023 04:03:52 +0200 Subject: [PATCH 2/2] ubootTools: add `efivar.py` as a tool `efivar.py` enable a user to manipulate the EFI variable store on disk that U-Boot uses. This is useful to prepare a SecureBoot set of variables that can be seeded inside of U-Boot directly if you do not have a proper OP-TEE on your platform. --- pkgs/misc/uboot/default.nix | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/pkgs/misc/uboot/default.nix b/pkgs/misc/uboot/default.nix index 6c002851db6f..d4be6a73b9fc 100644 --- a/pkgs/misc/uboot/default.nix +++ b/pkgs/misc/uboot/default.nix @@ -15,6 +15,7 @@ , openssl , swig , which +, python3 , armTrustedFirmwareAllwinner , armTrustedFirmwareAllwinnerH6 , armTrustedFirmwareAllwinnerH616 @@ -152,6 +153,10 @@ in { "tools/mkenvimage" "tools/mkimage" ]; + + pythonScriptsToInstall = { + "tools/efivar.py" = (python3.withPackages (ps: [ ps.pyopenssl ])); + }; }; ubootA20OlinuxinoLime = buildUBoot {