Commit 9be1d6b9 authored by Yureka's avatar Yureka
Browse files

m1n1: add option to build with chainloading support



Co-authored-by: default avatarJasi <normalcea@posteo.net>
parent 0f1ed07c
Loading
Loading
Loading
Loading
+34 −3
Original line number Diff line number Diff line
@@ -7,8 +7,30 @@
  python3Packages,
  nix-update-script,
  nixos-icons,
  buildPackages,
  customLogo ? "${nixos-icons}/share/icons/hicolor/256x256/apps/nix-snowflake.png",
  withChainloading ? false,
}:

let
  stdenvOpts = {
    targetPlatform.system = "aarch64-none-elf";
    targetPlatform.rust.rustcTarget = "${stdenv.hostPlatform.parsed.cpu.name}-unknown-none-softfloat";
    targetPlatform.rust.rustcTargetSpec = "${stdenv.hostPlatform.parsed.cpu.name}-unknown-none-softfloat";
  };
  rust = buildPackages.rust.override {
    stdenv = lib.recursiveUpdate buildPackages.stdenv stdenvOpts;
  };
  rustPackages = rust.packages.stable.overrideScope (
    f: p: {
      rustc-unwrapped = p.rustc-unwrapped.override {
        stdenv = lib.recursiveUpdate p.rustc-unwrapped.stdenv stdenvOpts;
      };
    }
  );
  rustPlatform = buildPackages.makeRustPlatform rustPackages;

in
stdenv.mkDerivation (finalAttrs: {
  pname = "m1n1";
  version = "1.5.2";
@@ -17,9 +39,12 @@ stdenv.mkDerivation (finalAttrs: {
    owner = "AsahiLinux";
    repo = "m1n1";
    tag = "v${finalAttrs.version}";
    hash = "sha256-/TQpR/3OUM4OIrfv6cBgZigyLR0VKw6Rd1v9465wy3o=";
    hash = "sha256-rxop5r+EVXnp1OVkGT6MUwcl6yNTJxJSJuruZiaou7g=";
    fetchSubmodules = true;
  };

  cargoVendorDir = ".";

  postPatch = lib.optionalString (customLogo != null) ''
    magick ${customLogo} -resize 128x128 data/custom_128.png
    magick ${customLogo} -resize 256x256 data/custom_256.png
@@ -27,6 +52,11 @@ stdenv.mkDerivation (finalAttrs: {

  nativeBuildInputs = [
    imagemagick
  ]
  ++ lib.optionals withChainloading [
    rustPackages.rustc
    rustPackages.cargo
    rustPlatform.cargoSetupHook
  ];

  postConfigure = ''
@@ -40,8 +70,9 @@ stdenv.mkDerivation (finalAttrs: {
  makeFlags = [
    "ARCH=${stdenv.cc.targetPrefix}"
    "RELEASE=1"
    (lib.optionalString (customLogo != null) "LOGO=custom")
  ];
  ]
  ++ lib.optional (customLogo != null) "LOGO=custom"
  ++ lib.optional withChainloading "CHAINLOADING=1";

  enableParallelBuilding = true;