Skip to content

Commit

Permalink
hardware config: fix git add logic
Browse files Browse the repository at this point in the history
Fixing the git add hardware config logic in case the user provides a
relative path. We're doing two things:

1. Failing loudly if the git add command fails. At that point, we
   already know git is in $PATH. If the git add fails, the evaluation
   will likely fail in a flake setting. Better fail early with a helpful
   git error message.
2. We're resolving the hardware config path in the CLI parsing layer
   to make sure this path has the meaning the user intented it to have.
  • Loading branch information
picnoir committed Nov 12, 2024
1 parent 51d347d commit 83714e3
Showing 1 changed file with 2 additions and 4 deletions.
6 changes: 2 additions & 4 deletions src/nixos-anywhere.sh
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,7 @@ parseArgs() {
abort "Unknown hardware config backend: $2"
;;
esac
hardwareConfigPath=$3
hardwareConfigPath=$(realpath $3)
shift
shift
;;
Expand Down Expand Up @@ -455,9 +455,7 @@ generateHardwareConfig() {

# to make sure nix knows about the new file
if command -v git >/dev/null; then
pushd "$(dirname "$hardwareConfigPath")"
git add --intent-to-add --force -- "$hardwareConfigPath" >/dev/null 2>&1 || true
popd
git add --intent-to-add --force -- "$hardwareConfigPath"
fi
}

Expand Down

0 comments on commit 83714e3

Please sign in to comment.