Skip to content

Conversation

@juliuskoskela
Copy link
Contributor

@juliuskoskela juliuskoskela commented May 12, 2025

Description of Changes

Bundle flash-script with image build. For example:

nix build .#lenovo-x1-carbon-gen11-debug

Will no produce

result/
  flash-script/bin/flash-script
  image/disk1.raw.zst

Instead of only the image.

Type of Change

  • Improvement / Refactor

Related Issues / Tickets

#927

Checklist

  • Clear summary in PR description
  • Detailed and meaningful commit message(s)
  • Commits are logically organized and squashed if appropriate
  • Contribution guidelines followed
  • Ghaf documentation updated with the commit - https://tiiuae.github.io/ghaf/
  • Author has run make-checks and it passes
  • All automatic GitHub Action checks pass - see actions
  • Author has added reviewers and removed PR draft status

Testing Instructions

Applicable Targets

  • Orin AGX aarch64
  • Orin NX aarch64
  • Lenovo X1 x86_64
  • Dell Latitude x86_64

Installation Method

  • Requires full re-installation
  • Can be updated with nixos-rebuild ... switch
  • Other:

Test Steps To Verify:

  1. ...

remimimimimi and others added 3 commits May 7, 2025 12:06
Signed-off-by: Valentin Kharin <[email protected]>
Signed-off-by: juliuskoskela-unikie <[email protected]>
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR updates the flake modules for various targets to wrap packages with a flash script as part of the build result. The primary changes include modifying package definitions in multiple target-specific modules to use the new flash script generator and introducing the helper function genPkgWithFlashScript in lib.nix.

Reviewed Changes

Copilot reviewed 5 out of 5 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
targets/nvidia-jetson-orin/flake-module.nix Wraps packages with genPkgWithFlashScript for aarch64-linux and x86_64-linux targets.
targets/microchip-icicle-kit/flake-module.nix Updates x86_64-linux package generation to include flash script.
targets/laptop/flake-module.nix Adjusts package mapping to use genPkgWithFlashScript with a dynamic system value.
targets/generic-x86_64/flake-module.nix Updates x86_64-linux package generation in a similar manner.
lib.nix Introduces genPkgWithFlashScript to combine package and flash-script components.
Comments suppressed due to low confidence (1)

targets/nvidia-jetson-orin/flake-module.nix:207

  • Verify that the hard-coded architecture string 'aarch64-linux' passed to genPkgWithFlashScript is consistent with all target definitions and matches downstream expectations.
t: lib.nameValuePair t.name (self.outputs.lib.genPkgWithFlashScript t.package "aarch64-linux")

in
lib.elem system platforms
);

Copy link

Copilot AI May 12, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Consider adding documentation comments to the 'genPkgWithFlashScript' function to explain its parameters, purpose, and the structure of the returned package, which will help maintainability and ease of use.

Suggested change
/*
*
Generates a Nix package that includes the given package and a flash script.
This function creates a "ghaf-image" package containing two components:
1. The provided package (`pkg`) as "image".
2. A flash script as "flash-script".
# Type
```
genPkgWithFlashScript :: AttrSet -> String -> AttrSet
```
# Arguments
- [pkg] The package to include in the "ghaf-image".
- [system] The target system platform (e.g., "x86_64-linux").
# Returns
An attribute set representing the "ghaf-image" package, which includes:
- `image`: The provided package.
- `flash-script`: A flash script package.
*/

Copilot uses AI. Check for mistakes.
@juliuskoskela juliuskoskela changed the title Reabse: Flash script as build result Rebase: Flash script as build result May 12, 2025
@juliuskoskela juliuskoskela marked this pull request as ready for review May 12, 2025 13:00
@juliuskoskela juliuskoskela self-assigned this May 12, 2025
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The arm targets already have their own flashing scripts

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a non maintained target

@brianmcgillion
Copy link
Collaborator

overall would it make more sense to add this to the devshell and also to have it exposed directly as a package in the outputs? you need the script to be downloaded/installed once and technically it is still generic as this PR does not "fill in" the target package that is to be flashed. so it I think it should be a one time build/download and installed when setting up a system.

@juliuskoskela
Copy link
Contributor Author

overall would it make more sense to add this to the devshell and also to have it exposed directly as a package in the outputs? you need the script to be downloaded/installed once and technically it is still generic as this PR does not "fill in" the target package that is to be flashed. so it I think it should be a one time build/download and installed when setting up a system.

I agree. So basically the same way it is done for Jetson targets. The original ticket reads:

Bootable drives for Ghaf devices are flashed with https://github.com/tiiuae/ghaf/blob/main/packages/flash/flash.sh 

Flash script is changing every now and then and each Ghaf binary images must be flashed to bootable drive with correct version of the flash.sh.

Currently flash.sh is not part of the build output. This is a problem for at least 

    User trial users
    Testers
    Open source users trying to download Ghaf binary images and flashing to their devices

Please provide flash.sh script as build output. Store it to the same folder with the target binary image.

So should we change the requirements slightly and just generate ${target}-flash-script targets for all targets and leave the base targets (that produce the image) as is?

@kajusnau
Copy link
Collaborator

kajusnau commented Dec 4, 2025

Flash script is now part of the devshell. Should this be closed? @brianmcgillion @juliuskoskela

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants