mirror of
https://codeberg.org/mart-w/nixos-x13s.git
synced 2024-11-08 17:14:48 +01:00
add uefi package and iso builder
thanks to https://github.com/martiert/x13s-bios
This commit is contained in:
parent
3fa14acfdd
commit
0650514998
|
@ -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; }
|
||||
);
|
||||
|
|
50
packages/uefi-usbiso.nix
Normal file
50
packages/uefi-usbiso.nix
Normal file
|
@ -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 <<EOF
|
||||
label: gpt
|
||||
start=''${gap}M, size=$blocks, type=uefi
|
||||
EOF
|
||||
|
||||
eval $(partx $img -o START,SECTORS --nr 1 --pairs)
|
||||
truncate -s $(( SECTORS * 512 )) part.img
|
||||
mkfs.vfat part.img
|
||||
mcopy -spvm -i ./part.img ${uefi}/EFI "::/EFI"
|
||||
mcopy -spvm -i ./part.img ${uefi}/Flash "::/Flash"
|
||||
|
||||
dd conv=notrunc if=part.img of=$img seek=$START count=$SECTORS
|
||||
rm -fr part.img
|
||||
'';
|
||||
|
||||
installPhase = ''
|
||||
mkdir $out
|
||||
mv ${name}-${version}.iso $out/
|
||||
'';
|
||||
}
|
29
packages/uefi.nix
Normal file
29
packages/uefi.nix
Normal file
|
@ -0,0 +1,29 @@
|
|||
{
|
||||
stdenv,
|
||||
fetchurl,
|
||||
innoextract,
|
||||
}:
|
||||
|
||||
stdenv.mkDerivation {
|
||||
name = "uefi";
|
||||
version = "1.60";
|
||||
|
||||
src = fetchurl {
|
||||
url = "https://download.lenovo.com/pccbbs/mobiles/n3huj19w.exe";
|
||||
hash = "sha256-ZSjkvbMb0e9CoL2OYo3Aioyz3or1YkOX/BdOOeAuL7I=";
|
||||
};
|
||||
|
||||
nativeBuildInputs = [ innoextract ];
|
||||
|
||||
unpackPhase = ''
|
||||
innoextract $src
|
||||
'';
|
||||
|
||||
doBuild = false;
|
||||
|
||||
installPhase = ''
|
||||
mkdir --parent $out/{EFI/Boot,Flash}
|
||||
cp code\$GetExtractPath\$/Rfs/Usb/Bootaa64.efi $out/EFI/Boot/
|
||||
cp -r code\$GetExtractPath\$/Rfs/Fw/* $out/Flash/
|
||||
'';
|
||||
}
|
Loading…
Reference in a new issue