Skip to content

Commit

Permalink
Merge pull request #499 from input-output-hk/betterNixWrapped
Browse files Browse the repository at this point in the history
nixWrapped: allow non-git and supported-systems.nix in ./nix
  • Loading branch information
jbgi committed Oct 5, 2021
2 parents db2c75a + 5dce427 commit dc03db8
Showing 1 changed file with 16 additions and 2 deletions.
18 changes: 16 additions & 2 deletions overlays/utils/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,23 @@ final: prev: let
inherit (final) system git nixFlakes cabal writeShellScriptBin;
in {
nixWrapped = writeShellScriptBin "nix" ''
if [[ "$@" == "flake show"* ]] || [[ "$@" == "flake check"* ]]; then
find_up() {
while [[ $PWD != / ]] ; do
if [[ -e "$1" ]]; then
echo "$PWD"
return
fi
if [[ -e "nix/$1" ]]; then
echo "$PWD/nix"
return
fi
cd ..
done
}
if [[ "$@" == *"flake"*" "*"show"* ]] || [[ "$@" == *"flake"*" "*"check"* ]]; then
>&2 echo 'Temporary override `supported-systems.nix` original content to be able to use `nix flake show|check` on dev machines (workaround for https://github.com/NixOS/nix/issues/4265)'
SYSTEMS="$(${git}/bin/git rev-parse --show-toplevel)/supported-systems.nix"
nixdir=$(find_up "supported-systems.nix")
SYSTEMS="$nixdir/supported-systems.nix"
BACKUP="$(mktemp)"
mv "$SYSTEMS" "$BACKUP"
echo '[ "${system}" ]' > "$SYSTEMS"
Expand Down

0 comments on commit dc03db8

Please sign in to comment.