Skip to content

Commit

Permalink
Fix nixos-rebuild when cross building flakes
Browse files Browse the repository at this point in the history
  • Loading branch information
Enzime authored and nix-conf committed Jan 1, 2024
1 parent 5f64a12 commit 454c080
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions pkgs/os-specific/linux/nixos-rebuild/nixos-rebuild.sh
Original file line number Diff line number Diff line change
Expand Up @@ -397,9 +397,12 @@ if [[ -z $_NIXOS_REBUILD_REEXEC && -n $canRun && -z $fast ]]; then
SHOULD_REEXEC=1
fi
else
runCmd nix "${flakeFlags[@]}" build --out-link "${tmpDir}/nixos-rebuild" "$flake#$flakeAttr.config.system.build.nixos-rebuild" "${extraBuildFlags[@]}" "${lockFlags[@]}"
if p=$(readlink -e "${tmpDir}/nixos-rebuild"); then
SHOULD_REEXEC=1
targetSystem=$(runCmd nix eval --raw "$flake#$flakeAttr.pkgs.system")
if [[ $(nix show-config --json | jq -r '.system.value') == $targetSystem ]]; then
runCmd nix "${flakeFlags[@]}" build --out-link "${tmpDir}/nixos-rebuild" "$flake#$flakeAttr.config.system.build.nixos-rebuild" "${extraBuildFlags[@]}" "${lockFlags[@]}"
if p=$(readlink -e "${tmpDir}/nixos-rebuild"); then
SHOULD_REEXEC=1
fi
fi
fi

Expand Down

0 comments on commit 454c080

Please sign in to comment.