From 0650514998d3927446e80902b9ad030fbbd0e9d4 Mon Sep 17 00:00:00 2001 From: Adam Stephens Date: Wed, 1 May 2024 10:08:29 -0400 Subject: [PATCH] add uefi package and iso builder thanks to https://github.com/martiert/x13s-bios --- packages/part.nix | 9 ++++++++ packages/uefi-usbiso.nix | 50 ++++++++++++++++++++++++++++++++++++++++ packages/uefi.nix | 29 +++++++++++++++++++++++ 3 files changed, 88 insertions(+) create mode 100644 packages/uefi-usbiso.nix create mode 100644 packages/uefi.nix diff --git a/packages/part.nix b/packages/part.nix index 1686f58..a665de7 100644 --- a/packages/part.nix +++ b/packages/part.nix @@ -1,5 +1,14 @@ { lib, withSystem, ... }: { + perSystem = + { pkgs, ... }: + { + packages = rec { + uefi = pkgs.callPackage ./uefi.nix { }; + uefi-usbiso = pkgs.callPackage ./uefi-usbiso.nix { inherit uefi; }; + }; + }; + flake.packages.aarch64-linux = withSystem "aarch64-linux" ( { pkgs, ... }: import ./default.nix { inherit lib pkgs; } ); diff --git a/packages/uefi-usbiso.nix b/packages/uefi-usbiso.nix new file mode 100644 index 0000000..a0179d2 --- /dev/null +++ b/packages/uefi-usbiso.nix @@ -0,0 +1,50 @@ +{ + stdenv, + parted, + util-linux, + dosfstools, + mtools, + uefi, +}: + +stdenv.mkDerivation rec { + name = "usbdisk"; + version = uefi.version; + + src = ./.; + + nativeBuildInputs = [ + parted + util-linux + dosfstools + mtools + ]; + + doUnpack = false; + buildPhase = '' + img=${name}-${version}.iso + gap=8 + blocks=$(du -B 512 --summarize --apparent-size ${uefi} | awk '{ print $1 }') + blocks=$(( 2 * blocks )) + size=$(( 512 * blocks + gap * 1024 * 1024 + 34*512)) + truncate -s $size $img + sfdisk $img <