moby: properly flash firmware as part of the image build

This commit is contained in:
colin 2022-06-23 16:57:25 -07:00
parent 7bf962942e
commit b244e8e845
5 changed files with 47 additions and 7 deletions

View File

@ -4,6 +4,7 @@
(import "${mobile-nixos}/lib/configuration.nix" {
device = "pine64-pinephone";
})
./firmware.nix
./fs.nix
];
# XXX colin: phosh doesn't work well with passwordless login

View File

@ -0,0 +1,8 @@
{ config, pkgs, ... }:
{
system.build.img = pkgs.runCommandNoCC "nixos_full-disk-image.img" {} ''
cp -v ${config.system.build.img-without-firmware}/nixos.img $out
chmod +w $out
dd if=${pkgs.tow-boot-pinephone}/Tow-Boot.noenv.bin of=$out bs=1024 seek=8 conv=notrunc
'';
}

View File

@ -39,7 +39,11 @@ in
system.build.img-without-firmware = with pkgs; imageBuilder.diskImage.makeGPT {
name = "nixos";
diskID = vfatUuidFromFs bootFs;
# headerHole = imageBuilder.size.MiB 16;
# leave some space for firmware
# TODO: we'd prefer to turn this into a protected firmware partition, rather than reserving space in the GPT header itself
# Tow-Boot manages to do that; not sure how.
# TODO: does this method work on all systems (test on lappy)
headerHole = imageBuilder.size.MiB 16;
partitions = [
(fsBuilderMapBoot."${bootFs.fsType}" {
# fs properties
@ -83,10 +87,4 @@ in
];
};
system.build.img = lib.mkDefault config.system.build.img-without-firmware;
# TODO: pinephone build:
# system.build.img = pkgs.runCommandNoCC "nixos_full-disk-image.img" {} ''
# cp -v ${config.system.build.without-bootloader}/nixos.img $out
# chmod +w $out
# dd if=${pkgs.tow-boot-pinephone}/Tow-Boot.noenv.bin of=$out bs=1024 seek=8 conv=notrunc
# '';
}

View File

@ -1,6 +1,9 @@
(next: prev: {
#### my own, non-upstreamable packages:
sane-scripts = prev.callPackage ./sane-scripts { };
tow-boot-pinephone = prev.callPackage ./pkgs/tow-boot-pinephone { };
#### customized packages
# nixos-unstable pleroma is too far out-of-date for our db
pleroma = prev.callPackage ./pleroma { };

View File

@ -0,0 +1,30 @@
{ lib, stdenv, fetchurl }:
stdenv.mkDerivation rec {
pname = "tow-boot-pinephone";
version = "2021.10-004";
src = fetchurl {
url = "https://github.com/Tow-Boot/Tow-Boot/releases/download/release-2021.10-004/pine64-pinephoneA64-2021.10-004.tar.xz";
sha256 = "sha256-UZSzzzTp8PQ/wuLUA3RJyTa/vbQ0HdhfagJ8574leoA=";
};
unpackPhase = ''
mkdir -p src
tar -xf ${src} -C src
'';
installPhase = ''
mkdir -p "$out"
cp -R src/pine64-pinephoneA64-2021.10-004/*.img "$out"/
cp -R src/pine64-pinephoneA64-2021.10-004/binaries/* "$out"/
'';
meta = with lib; {
description = "An opinionated distribution of U-Boot";
homepage = "https://tow-boot.org/";
platforms = [ "aarch64-linux" ];
};
}