refresh-bootfs.nix (1322B)
1 { config, pkgs, lib, ... }: 2 3 # nixos/mobile-nixos don't currently (June 2022) update the kernel and 4 # initrd used by the bootloader when nixos-rebuild is run. This is a 5 # workaround until they do. Mount your boot filesystem somewhere 6 # and run "refresh-bootfs /path/to/mounted/bootfs" after switching 7 # configuration 8 9 let 10 inherit (config.mobile.outputs) recovery stage-0; 11 inherit (pkgs) writeScriptBin buildPackages imageBuilder runCommandNoCC; 12 13 kernel = stage-0.mobile.boot.stage-1.kernel.package; 14 kernel_file = "${kernel}/${if kernel ? file then kernel.file else pkgs.stdenv.hostPlatform.linux-kernel.target}"; 15 # bootscr = runCommandNoCC "boot.scr" { 16 # nativeBuildInputs = [ 17 # buildPackages.ubootTools 18 # ]; 19 # } '' 20 # mkimage -C none -A arm64 -T script -d {bootcmd} $out 21 # ''; 22 23 in writeScriptBin "refresh-bootfs" '' 24 #!${pkgs.runtimeShell} 25 test -n "$1" || exit 1 26 test -d "$1" || exit 1 27 cd $1 28 test -f ./boot.scr || exit 1 29 mkdir -vp mobile-nixos/{boot,recovery} 30 ( 31 cd mobile-nixos/boot 32 cp -v ${stage-0.mobile.outputs.initrd} stage-1 33 cp -v ${kernel_file} kernel 34 cp -vr ${kernel}/dtbs dtbs 35 ) 36 ( 37 cd mobile-nixos/recovery 38 cp -v ${recovery.mobile.outputs.initrd} stage-1 39 cp -v ${kernel_file} kernel 40 cp -vr ${kernel}/dtbs dtbs 41 ) 42 # cp -v {bootscr} ./boot.scr 43 ''