|
1 |
| -{ config, pkgs, lib, ... }: |
| 1 | +{ config, pkgs, lib, utils, ... }: |
2 | 2 |
|
3 | 3 | # Convenience package that allows you to set options for the flash script using the NixOS module system.
|
4 | 4 | # You could do the overrides yourself if you'd prefer.
|
|
403 | 403 | }.${cfg.som}
|
404 | 404 | )) else lib.mkOptionDefault [ ];
|
405 | 405 |
|
406 |
| - systemd.services = lib.mkIf (cfg.flashScriptOverrides.targetBoard != null) { |
407 |
| - setup-jetson-efi-variables = { |
408 |
| - enable = true; |
409 |
| - description = "Setup Jetson OTA UEFI variables"; |
410 |
| - wantedBy = [ "multi-user.target" ]; |
411 |
| - after = [ "opt-nvidia-esp.mount" ]; |
412 |
| - serviceConfig.Type = "oneshot"; |
413 |
| - serviceConfig.ExecStart = "${pkgs.nvidia-jetpack.otaUtils}/bin/ota-setup-efivars ${cfg.flashScriptOverrides.targetBoard}"; |
414 |
| - }; |
| 406 | + systemd.services.setup-jetson-efi-variables = lib.mkIf (cfg.flashScriptOverrides.targetBoard != null) { |
| 407 | + description = "Setup Jetson OTA UEFI variables"; |
| 408 | + wantedBy = [ "multi-user.target" ]; |
| 409 | + after = [ "opt-nvidia-esp.mount" ]; |
| 410 | + serviceConfig.Type = "oneshot"; |
| 411 | + serviceConfig.ExecStart = "${pkgs.nvidia-jetpack.otaUtils}/bin/ota-setup-efivars ${cfg.flashScriptOverrides.targetBoard}"; |
415 | 412 | };
|
416 | 413 |
|
417 |
| - boot.loader.systemd-boot.extraInstallCommands = lib.mkIf (cfg.firmware.autoUpdate && cfg.som != null && cfg.flashScriptOverrides.targetBoard != null) '' |
418 |
| - # Jetpack 5.0 didn't expose this DMI variable, |
419 |
| - if [[ ! -f /sys/devices/virtual/dmi/id/bios_version ]]; then |
420 |
| - echo "Unable to determine current Jetson firmware version." |
421 |
| - echo "You should reflash the firmware with the new version to ensure compatibility" |
422 |
| - else |
| 414 | + systemd.services.firmware-update = lib.mkIf (cfg.firmware.autoUpdate && cfg.som != null && cfg.flashScriptOverrides.targetBoard != null) { |
| 415 | + wantedBy = [ "multi-user.target" ]; |
| 416 | + path = [ pkgs.nvidia-jetpack.otaUtils ]; |
| 417 | + after = [ |
| 418 | + "${utils.escapeSystemdPath config.boot.loader.efi.efiSysMountPoint}.mount" |
| 419 | + "opt-nvidia-esp.mount" |
| 420 | + ]; |
| 421 | + unitConfig = { |
| 422 | + ConditionPathExists = "/sys/devices/virtual/dmi/id/bios_version"; |
| 423 | + # This directory is populated by ota-apply-capsule-update, don't run |
| 424 | + # if we already have a capsule update present on the ESP. |
| 425 | + ConditionDirectoryNotEmpty = "!${config.boot.loader.efi.efiSysMountPoint}/EFI/UpdateCapsule"; |
| 426 | + }; |
| 427 | + script = '' |
423 | 428 | CUR_VER=$(cat /sys/devices/virtual/dmi/id/bios_version)
|
424 | 429 | NEW_VER=${pkgs.nvidia-jetpack.l4tVersion}
|
425 | 430 |
|
|
433 | 438 | # systemd service. Plus, this ota-setup-efivars will be from the
|
434 | 439 | # generation we're switching to, which can contain additional
|
435 | 440 | # fixes/improvements.
|
436 |
| - ${pkgs.nvidia-jetpack.otaUtils}/bin/ota-setup-efivars ${cfg.flashScriptOverrides.targetBoard} |
| 441 | + ota-setup-efivars ${cfg.flashScriptOverrides.targetBoard} |
437 | 442 |
|
438 |
| - ${pkgs.nvidia-jetpack.otaUtils}/bin/ota-apply-capsule-update ${config.system.build.jetsonDevicePkgs.uefiCapsuleUpdate} |
| 443 | + ota-apply-capsule-update ${config.system.build.jetsonDevicePkgs.uefiCapsuleUpdate} |
439 | 444 | fi
|
440 |
| - fi |
441 |
| - ''; |
| 445 | + ''; |
| 446 | + }; |
442 | 447 |
|
443 | 448 | environment.systemPackages = lib.mkIf (cfg.firmware.autoUpdate && cfg.som != null && cfg.flashScriptOverrides.targetBoard != null) [
|
444 | 449 | (pkgs.writeShellScriptBin "ota-apply-capsule-update-included" ''
|
|
0 commit comments