diff --git a/flake.lock b/flake.lock index c2dd88d3b..20aae671e 100644 --- a/flake.lock +++ b/flake.lock @@ -329,16 +329,17 @@ "nixpkgs": "nixpkgs" }, "locked": { - "lastModified": 1732314023, - "narHash": "sha256-CsE099SEVK/ERuPNZXqzIom4FNz8C3BWE6AkUQ9M2F4=", + "lastModified": 1734622751, + "narHash": "sha256-eSy32Rx0SjLWEXo5mvMfHjFAxE8C9ZHXkc7j8bGU3zw=", "owner": "anduril", "repo": "jetpack-nixos", - "rev": "abfe7f4cb93ac69bbd7b760307da2f80fd052993", + "rev": "4dc254268aea59921268206628b9d911b6703e9e", "type": "github" }, "original": { "owner": "anduril", "repo": "jetpack-nixos", + "rev": "4dc254268aea59921268206628b9d911b6703e9e", "type": "github" } }, @@ -465,11 +466,11 @@ }, "nixos-hardware": { "locked": { - "lastModified": 1735388221, - "narHash": "sha256-e5IOgjQf0SZcFCEV/gMGrsI0gCJyqOKShBQU0iiM3Kg=", + "lastModified": 1734352517, + "narHash": "sha256-mfv+J/vO4nqmIOlq8Y1rRW8hVsGH3M+I2ESMjhuebDs=", "owner": "NixOS", "repo": "nixos-hardware", - "rev": "7c674c6734f61157e321db595dbfcd8523e04e19", + "rev": "b12e314726a4226298fe82776b4baeaa7bcf3dcd", "type": "github" }, "original": { @@ -505,8 +506,8 @@ }, "original": { "owner": "NixOS", - "ref": "nixos-unstable", "repo": "nixpkgs", + "rev": "3566ab7246670a43abd2ffa913cc62dad9cdf7d5", "type": "github" } }, diff --git a/flake.nix b/flake.nix index 219987c3a..04b6fa456 100644 --- a/flake.nix +++ b/flake.nix @@ -114,11 +114,9 @@ nixos-hardware.url = "github:NixOS/nixos-hardware"; - jetpack-nixos = { - #url = "github:anduril/jetpack-nixos - url = "github:anduril/jetpack-nixos"; - #inputs.nixpkgs.follows = "nixpkgs"; - }; + #jetpack-nixos.url = "flake:mylocaljetpack"; + #pinned to the pr https://github.com/anduril/jetpack-nixos/pull/257 until merged + jetpack-nixos.url = "github:anduril/jetpack-nixos/4dc254268aea59921268206628b9d911b6703e9e"; disko = { url = "github:nix-community/disko"; diff --git a/lib/mk-flash-script/default.nix b/lib/mk-flash-script/default.nix index fba8966ae..e0d84190f 100644 --- a/lib/mk-flash-script/default.nix +++ b/lib/mk-flash-script/default.nix @@ -3,70 +3,6 @@ # # Function to generate NVIDIA Jetson Orin flash script { - nixpkgs, hostConfiguration, - jetpack-nixos, - flash-tools-system, }: -let - cfg = hostConfiguration.config.hardware.nvidia-jetpack; - inherit (jetpack-nixos.legacyPackages.${flash-tools-system}) flash-tools; - - # jetpack-nixos has the cross-compilation set up in a slightly strange way, - # the packages under x86_64-linux are actually cross-compiled packages for - # aarch64-linux. So we will get devicePkgs from x86_64-linux if we are cross - # compiling, otherwise we end up building UEFI firmware etc. binaries used by - # flash-script natively. - isCross = - hostConfiguration.config.nixpkgs.buildPlatform.system - != hostConfiguration.config.nixpkgs.hostPlatform.system; - devicePkgsSystem = if isCross then "x86_64-linux" else "aarch64-linux"; - devicePkgs = - jetpack-nixos.legacyPackages.${devicePkgsSystem}.devicePkgsFromNixosConfig - hostConfiguration.config; - - inherit (jetpack-nixos.legacyPackages.${devicePkgsSystem}) l4tVersion; - - flashScript = devicePkgs.mkFlashScript { - flash-tools = flash-tools.overrideAttrs ( - { - postPatch ? "", - ... - }: - { - postPatch = postPatch + cfg.flashScriptOverrides.postPatch; - } - ); - preFlashCommands = - nixpkgs.lib.optionalString (flash-tools-system == "aarch64-linux") '' - echo "WARNING! WARNING! WARNING!" - echo "You are trying to run aarch64-linux hosted version of the flash-script." - echo "It runs flashing tools with QEMU using user-mode emulation of x86 cpu." - echo "There are no known reports from anyone who would have gotten this working ever." - echo "If this fails, YOU HAVE BEEN WARNED, and don't open a bug report!" - echo "" - '' - + hostConfiguration.config.ghaf.hardware.nvidia.orin.flashScriptOverrides.preFlashCommands; - }; - - patchFlashScript = - builtins.replaceStrings - [ - "@pzstd@" - "@sed@" - "@patch@" - "@l4tVersion@" - "@isCross@" - ] - [ - "${nixpkgs.legacyPackages.${flash-tools-system}.zstd}/bin/pzstd" - "${nixpkgs.legacyPackages.${flash-tools-system}.gnused}/bin/sed" - "${nixpkgs.legacyPackages.${flash-tools-system}.patch}/bin/patch" - "${l4tVersion}" - "${if isCross then "true" else "false"}" - ]; -in -nixpkgs.legacyPackages.${flash-tools-system}.writeShellApplication { - name = "flash-ghaf"; - text = patchFlashScript flashScript; -} +hostConfiguration.pkgs.nvidia-jetpack.flashScript diff --git a/modules/reference/hardware/jetpack/nvidia-jetson-orin/partition-template.nix b/modules/reference/hardware/jetpack/nvidia-jetson-orin/partition-template.nix index fda796b80..1172cb049 100644 --- a/modules/reference/hardware/jetpack/nvidia-jetson-orin/partition-template.nix +++ b/modules/reference/hardware/jetpack/nvidia-jetson-orin/partition-template.nix @@ -108,15 +108,12 @@ in { config = lib.mkIf cfg.enable { hardware.nvidia-jetpack.flashScriptOverrides.partitionTemplate = partitionTemplate; - - ghaf.hardware.nvidia.orin.flashScriptOverrides.preFlashCommands = + hardware.nvidia-jetpack.flashScriptOverrides.preFlashCommands = '' echo "============================================================" echo "ghaf flashing script" echo "============================================================" echo "ghaf version: ${config.ghaf.version}" - echo "cross-compiled build: @isCross@" - echo "l4tVersion: @l4tVersion@" echo "som: ${config.hardware.nvidia-jetpack.som}" echo "carrierBoard: ${config.hardware.nvidia-jetpack.carrierBoard}" echo "============================================================" @@ -131,7 +128,7 @@ in # # In Section: Adaptation to the Carrier Board with HDMI for the Orin # NX/Nano Modules - @patch@ -p0 < ${./tegra2-mb2-bct-scr.patch} + "${pkgs.pkgsBuildBuild.patch}/bin/patch" -p0 < ${./tegra2-mb2-bct-scr.patch} '' + lib.optionalString (!cfg.flashScriptOverrides.onlyQSPI) '' ESP_OFFSET=$(cat "${images}/esp.offset") @@ -141,12 +138,12 @@ in img="${images}/sd-image/${config.sdImage.imageName}.zst" echo "Extracting ESP partition to $WORKDIR/bootloader/esp.img ..." - dd if=<(@pzstd@ -d "$img" -c) of="$WORKDIR/bootloader/esp.img" bs=512 iseek="$ESP_OFFSET" count="$ESP_SIZE" + dd if=<("${pkgs.pkgsBuildBuild.zstd}/bin/pzstd" -d "$img" -c) of="$WORKDIR/bootloader/esp.img" bs=512 iseek="$ESP_OFFSET" count="$ESP_SIZE" echo "Extracting root partition to $WORKDIR/root.img ..." - dd if=<(@pzstd@ -d "$img" -c) of="$WORKDIR/bootloader/root.img" bs=512 iseek="$ROOT_OFFSET" count="$ROOT_SIZE" + dd if=<("${pkgs.pkgsBuildBuild.zstd}/bin/pzstd" -d "$img" -c) of="$WORKDIR/bootloader/root.img" bs=512 iseek="$ROOT_OFFSET" count="$ROOT_SIZE" echo "Patching flash.xml with absolute paths to esp.img and root.img ..." - @sed@ -i \ + "${pkgs.pkgsBuildBuild.gnused}/bin/sed" -i \ -e "s#bootloader/esp.img#$WORKDIR/bootloader/esp.img#" \ -e "s#root.img#$WORKDIR/root.img#" \ -e "s#ESP_SIZE#$((ESP_SIZE * 512))#" \ diff --git a/targets/nvidia-jetson-orin/flake-module.nix b/targets/nvidia-jetson-orin/flake-module.nix index 6d1085eaf..67059755f 100644 --- a/targets/nvidia-jetson-orin/flake-module.nix +++ b/targets/nvidia-jetson-orin/flake-module.nix @@ -160,24 +160,18 @@ let mkFlashScript = import ../../lib/mk-flash-script; # Generate flash script variant which flashes both QSPI and eMMC generate-flash-script = - tgt: flash-tools-system: + tgt: _flash-tools-system: mkFlashScript { - inherit nixpkgs; inherit (tgt) hostConfiguration; - inherit jetpack-nixos; - inherit flash-tools-system; }; # Generate flash script variant which flashes QSPI only. Useful for Orin NX # and non-eMMC based development. generate-flash-qspi = - tgt: flash-tools-system: + tgt: _flash-tools-system: mkFlashScript { - inherit nixpkgs; hostConfiguration = tgt.hostConfiguration.extendModules { modules = [ { ghaf.hardware.nvidia.orin.flashScriptOverrides.onlyQSPI = true; } ]; }; - inherit jetpack-nixos; - inherit flash-tools-system; }; in {