From 696088306a68d85e1e8252105629a2a72ffea857 Mon Sep 17 00:00:00 2001 From: Brian McGillion Date: Wed, 18 Dec 2024 14:36:43 +0400 Subject: [PATCH] dummy tmp patch Signed-off-by: Brian McGillion --- flake.lock | 39 ++++----- flake.nix | 11 ++- lib/mk-flash-script/backup.nix | 92 +++++++++++++++++++++ lib/mk-flash-script/default.nix | 67 ++------------- targets/nvidia-jetson-orin/flake-module.nix | 13 +-- 5 files changed, 124 insertions(+), 98 deletions(-) create mode 100644 lib/mk-flash-script/backup.nix diff --git a/flake.lock b/flake.lock index 4476203c5..3c3ce57ea 100644 --- a/flake.lock +++ b/flake.lock @@ -91,11 +91,11 @@ ] }, "locked": { - "lastModified": 1734088167, - "narHash": "sha256-OIitVU+IstPbX/NWn2jLF+/sT9dVKcO2FKeRAzlyX6c=", + "lastModified": 1734343412, + "narHash": "sha256-b7G8oFp0Nj01BYUJ6ENC9Qf/HsYAIZvN9k/p0Kg/PFU=", "owner": "nix-community", "repo": "disko", - "rev": "d32f2d1750d61a476a236526b725ec5a32e16342", + "rev": "a08bfe06b39e94eec98dd089a2c1b18af01fef19", "type": "github" }, "original": { @@ -210,11 +210,11 @@ ] }, "locked": { - "lastModified": 1733291815, - "narHash": "sha256-J2lWG+T99LjS3dTp4c4ZrQGfj4qq50mDNodv6gM4fzY=", + "lastModified": 1734437131, + "narHash": "sha256-8Jijyp8QAcRPP4qngoC/FHi3goMP/p/f8oj0vzpLlIg=", "owner": "tiiuae", "repo": "ghafpkgs", - "rev": "39494827ae32568aab54868753add673ecec8390", + "rev": "e088f9dc4aa004a93517874e31e1ed578ed369d1", "type": "github" }, "original": { @@ -237,11 +237,11 @@ ] }, "locked": { - "lastModified": 1734279981, - "narHash": "sha256-NdaCraHPp8iYMWzdXAt5Nv6sA3MUzlCiGiR586TCwo0=", + "lastModified": 1734425854, + "narHash": "sha256-nzE5UbJ41aPEKf8R2ZFYtLkqPmF7EIUbNEdHMBLg0Ig=", "owner": "cachix", "repo": "git-hooks.nix", - "rev": "aa9f40c906904ebd83da78e7f328cd8aeaeae785", + "rev": "0ddd26d0925f618c3a5d85a4fa5eb1e23a09491d", "type": "github" }, "original": { @@ -329,16 +329,17 @@ "nixpkgs": "nixpkgs" }, "locked": { - "lastModified": 1732314023, - "narHash": "sha256-CsE099SEVK/ERuPNZXqzIom4FNz8C3BWE6AkUQ9M2F4=", + "lastModified": 1734547239, + "narHash": "sha256-CuH64kASEZJLeuYJG1hlZZKAWfgq+dSpwUG6QiXMcNY=", "owner": "anduril", "repo": "jetpack-nixos", - "rev": "abfe7f4cb93ac69bbd7b760307da2f80fd052993", + "rev": "b2e93894c48de6ce2fd98cf36a228cbc8123016d", "type": "github" }, "original": { "owner": "anduril", "repo": "jetpack-nixos", + "rev": "b2e93894c48de6ce2fd98cf36a228cbc8123016d", "type": "github" } }, @@ -465,11 +466,11 @@ }, "nixos-hardware": { "locked": { - "lastModified": 1733861262, - "narHash": "sha256-+jjPup/ByS0LEVIrBbt7FnGugJgLeG9oc+ivFASYn2U=", + "lastModified": 1734352517, + "narHash": "sha256-mfv+J/vO4nqmIOlq8Y1rRW8hVsGH3M+I2ESMjhuebDs=", "owner": "NixOS", "repo": "nixos-hardware", - "rev": "cf737e2eba82b603f54f71b10cb8fd09d22ce3f5", + "rev": "b12e314726a4226298fe82776b4baeaa7bcf3dcd", "type": "github" }, "original": { @@ -505,8 +506,8 @@ }, "original": { "owner": "NixOS", - "ref": "nixos-unstable", "repo": "nixpkgs", + "rev": "3566ab7246670a43abd2ffa913cc62dad9cdf7d5", "type": "github" } }, @@ -597,11 +598,11 @@ ] }, "locked": { - "lastModified": 1733761991, - "narHash": "sha256-s4DalCDepD22jtKL5Nw6f4LP5UwoMcPzPZgHWjAfqbQ=", + "lastModified": 1734543842, + "narHash": "sha256-/QceWozrNg915Db9x/Ie5k67n9wKgGdTFng+Z1Qw0kE=", "owner": "numtide", "repo": "treefmt-nix", - "rev": "0ce9d149d99bc383d1f2d85f31f6ebd146e46085", + "rev": "76159fc74eeac0599c3618e3601ac2b980a29263", "type": "github" }, "original": { diff --git a/flake.nix b/flake.nix index 219987c3a..1e4093dc8 100644 --- a/flake.nix +++ b/flake.nix @@ -28,7 +28,8 @@ #TODO: carrying the extra patch(es) until merged to unstable #nixpkgs.url = "github:tiiuae/nixpkgs/nixos-unstable-gbenchmark"; #nixpkgs.url = "flake:mylocalnixpkgs"; - nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable"; + #TODO pinned to the a version to get working + nixpkgs.url = "github:NixOS/nixpkgs/3566ab7246670a43abd2ffa913cc62dad9cdf7d5"; ghafpkgs = { url = "github:tiiuae/ghafpkgs"; @@ -114,11 +115,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/b2e93894c48de6ce2fd98cf36a228cbc8123016d"; disko = { url = "github:nix-community/disko"; diff --git a/lib/mk-flash-script/backup.nix b/lib/mk-flash-script/backup.nix new file mode 100644 index 000000000..cabba6f64 --- /dev/null +++ b/lib/mk-flash-script/backup.nix @@ -0,0 +1,92 @@ +# Copyright 2022-2024 TII (SSRC) and the Ghaf contributors +# SPDX-License-Identifier: Apache-2.0 +# +# 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; + + inherit (hostConfiguration) pkgs; + inherit (pkgs.nvidia-jetpack) mkFlashScript; + + # 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; + inherit (pkgs.nvidia-jetpack) mkFlashScript; + + 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; + + flashScript = ( + mkFlashScript { + inherit flash-tools; + args = [ ]; + # = 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 mkFlashScript flash-tools {inherit preFlashCommands;}; + +} diff --git a/lib/mk-flash-script/default.nix b/lib/mk-flash-script/default.nix index fba8966ae..7ca3515b4 100644 --- a/lib/mk-flash-script/default.nix +++ b/lib/mk-flash-script/default.nix @@ -8,65 +8,8 @@ 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 +# nixpkgs.legacyPackages.${flash-tools-system}.writeShellApplication { +# name = "flash-ghaf"; +# text = "${hostConfiguration.pkgs.nvidia-jetpack.flashScript}"; +# } diff --git a/targets/nvidia-jetson-orin/flake-module.nix b/targets/nvidia-jetson-orin/flake-module.nix index 6d1085eaf..e55377579 100644 --- a/targets/nvidia-jetson-orin/flake-module.nix +++ b/targets/nvidia-jetson-orin/flake-module.nix @@ -188,17 +188,8 @@ in packages = { aarch64-linux = - builtins.listToAttrs (map (t: lib.nameValuePair t.name t.package) targets) - # EXPERIMENTAL: The aarch64-linux hosted flashing support is experimental - # and it simply might not work. Providing the script anyway - // builtins.listToAttrs ( - map ( - t: lib.nameValuePair "${t.name}-flash-script" (generate-flash-script t "aarch64-linux") - ) targets - ) - // builtins.listToAttrs ( - map (t: lib.nameValuePair "${t.name}-flash-qspi" (generate-flash-qspi t "aarch64-linux")) targets - ); + # should only build images as the flashers are not supported on aarch64-linux + builtins.listToAttrs (map (t: lib.nameValuePair t.name t.package) targets); x86_64-linux = builtins.listToAttrs (map (t: lib.nameValuePair t.name t.package) crossTargets) // builtins.listToAttrs (