Skip to content

devshell: add ghaf-flash to devshell, improve readability#1613

Merged
brianmcgillion merged 1 commit intotiiuae:mainfrom
kajusnau:devshell-flash
Dec 3, 2025
Merged

devshell: add ghaf-flash to devshell, improve readability#1613
brianmcgillion merged 1 commit intotiiuae:mainfrom
kajusnau:devshell-flash

Conversation

@kajusnau
Copy link
Copy Markdown
Collaborator

@kajusnau kajusnau commented Dec 3, 2025

Description of Changes

Added flash-script as ghaf-flash to ghaf devshell.
Some improvements:

  • Progress bar (if pv is available)
  • Summary print
  • Ask for user confirmation before wiping
    • Can be skipped with -f flag
  • Dependency check for running outside the devshell
  • Colored errors, warnings, and success messages

Type of Change

  • New Feature
  • Bug Fix
  • Improvement / Refactor

Related Issues / Tickets

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
  • System 76 x86_64

Installation Method

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

Test Steps To Verify:

  1. ...

Copy link
Copy Markdown
Collaborator

@brianmcgillion brianmcgillion left a comment

Choose a reason for hiding this comment

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

fairly big wrapper for

zstdcat result/disk1.raw.zst | sudo dd of=/dev/sda bs=32M status=progress conv=sync oflag=direct iflag=fullblock

:) :)

@kajusnau
Copy link
Copy Markdown
Collaborator Author

kajusnau commented Dec 3, 2025

fairly big wrapper for

zstdcat result/disk1.raw.zst | sudo dd of=/dev/sda bs=32M status=progress conv=sync oflag=direct iflag=fullblock

:) :)

Haha indeed
I figure this should be less scary and more informative for folks who are not as familiar with Ghaf 🤞

Copy link
Copy Markdown
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 adds a user-friendly ghaf-flash command to the development shell and significantly improves the flash script's usability with colored output, progress indicators, and better error messaging.

Key Changes:

  • Adds ghaf-flash command alias to devshell for easier access to the flash script
  • Enhances flash.sh with colored output, progress bars (using pv), and interactive confirmation
  • Fixes typo in package description ("Flashingscript" → "Flashing script")

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 13 comments.

File Description
packages/pkgs-by-name/flash-script/package.nix Adds pv dependency for progress display and fixes description typo
packages/pkgs-by-name/flash-script/flash.sh Major UX improvements: adds colored output, progress bars, better help text, force flag, and user confirmation prompts
nix/devshell.nix Adds ghaf-flash command to devshell builder category for convenient access
Comments suppressed due to low confidence (1)

packages/pkgs-by-name/flash-script/flash.sh:181

  • Using eval with user-controlled variable $FILENAME embedded in PV_CMD can lead to command injection vulnerabilities. While the filename is validated earlier, it's safer to avoid eval altogether. Instead, construct the command directly:
if [[ -n $IMGSIZE ]]; then
  zstdcat "$FILENAME" | pv -tpreb -N "$FILENAME" -s "$IMGSIZE" | dd of="$DEVICE" bs=32M conv=fsync oflag=direct iflag=fullblock status=none
else
  zstdcat "$FILENAME" | pv -tpreb -N "$FILENAME" | dd of="$DEVICE" bs=32M conv=fsync oflag=direct iflag=fullblock status=none
fi
  PV_CMD="pv -tpreb -N \"$FILENAME\""
  if [[ -n $IMGSIZE ]]; then
    PV_CMD="$PV_CMD -s $IMGSIZE"
  fi
  set +e
  zstdcat "$FILENAME" | eval "$PV_CMD" | dd of="$DEVICE" bs=32M conv=fsync oflag=direct iflag=fullblock status=none

Signed-off-by: Kajus Naujokaitis <kajus.naujokaitis@unikie.com>
@kajusnau
Copy link
Copy Markdown
Collaborator Author

kajusnau commented Dec 3, 2025

Adjusted some parts based on copilot notes. Ready for review.

@kajusnau kajusnau marked this pull request as ready for review December 3, 2025 14:35
@brianmcgillion brianmcgillion merged commit b3436f8 into tiiuae:main Dec 3, 2025
30 checks passed
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.

3 participants