Skip to content

Commit

Permalink
Merge pull request #22 from helsinki-systems/feat/custom-m1n1-logo
Browse files Browse the repository at this point in the history
m1n1: Support custom logo
  • Loading branch information
tpwrules authored Sep 27, 2022
2 parents 3bae9a3 + dc1b42a commit 7e85e75
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 9 deletions.
27 changes: 19 additions & 8 deletions nix/m1-support/boot-m1n1/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ let
bootM1n1 = buildPkgs.callPackage ../m1n1 {
isRelease = true;
withTools = false;
customLogo = config.boot.m1n1CustomLogo;
};

bootUBoot = buildPkgs.callPackage ../u-boot {
Expand Down Expand Up @@ -42,13 +43,23 @@ in {
];
};

options.boot.m1n1ExtraOptions = lib.mkOption {
type = lib.types.str;
default = "";
description = ''
Append extra options to the m1n1 boot binary. Might be useful for fixing
display problems on Mac minis.
https://github.com/AsahiLinux/m1n1/issues/159
'';
options.boot = {
m1n1ExtraOptions = lib.mkOption {
type = lib.types.str;
default = "";
description = ''
Append extra options to the m1n1 boot binary. Might be useful for fixing
display problems on Mac minis.
https://github.com/AsahiLinux/m1n1/issues/159
'';
};

m1n1CustomLogo = lib.mkOption {
type = lib.types.nullOr lib.types.path;
default = null;
description = ''
Custom logo to build into m1n1. The path must point to a 256x256 PNG.
'';
};
};
}
19 changes: 18 additions & 1 deletion nix/m1-support/m1n1/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,12 @@
, pkgsCross
, python3
, dtc
, imagemagick
, isRelease ? false
, withTools ? true
, withChainloading ? false
, rust-bin ? null
, customLogo ? null
}:

assert withChainloading -> rust-bin != null;
Expand Down Expand Up @@ -41,14 +43,29 @@ in stdenv.mkDerivation rec {
nativeBuildInputs = [
dtc
pkgsCross.aarch64-multiplatform.buildPackages.gcc
] ++ lib.optional withChainloading rustenv;
] ++ lib.optional withChainloading rustenv
++ lib.optional (customLogo != null) imagemagick;

postPatch = ''
substituteInPlace proxyclient/m1n1/asm.py \
--replace 'aarch64-linux-gnu-' 'aarch64-unknown-linux-gnu-' \
--replace 'TOOLCHAIN = ""' 'TOOLCHAIN = "'$out'/toolchain-bin/"'
'';

preConfigure = lib.optionalString (customLogo != null) ''
pushd data &>/dev/null
ln -fs ${customLogo} bootlogo_256.png
if [[ "$(magick identify bootlogo_256.png)" != 'bootlogo_256.png PNG 256x256'* ]]; then
echo "Custom logo is not a 256x256 PNG"
exit 1
fi
rm bootlogo_128.png
convert bootlogo_256.png -resize 128x128 bootlogo_128.png
./makelogo.sh
popd &>/dev/null
'';

installPhase = ''
runHook preInstall
Expand Down

0 comments on commit 7e85e75

Please sign in to comment.