diff --git a/pkgs/by-name/m1/m1n1/package.nix b/pkgs/by-name/m1/m1n1/package.nix index 960f27cef605..052c7e694266 100644 --- a/pkgs/by-name/m1/m1n1/package.nix +++ b/pkgs/by-name/m1/m1n1/package.nix @@ -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;