Skip to content

Commit

Permalink
Merge pull request #40 from azuwis/gtar
Browse files Browse the repository at this point in the history
Use gtar to restore /nix on macOS
  • Loading branch information
rickynils authored Jan 8, 2024
2 parents dd58d2d + dbc9625 commit 7a1fd47
Showing 1 changed file with 7 additions and 13 deletions.
20 changes: 7 additions & 13 deletions nix-quick-install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -44,22 +44,16 @@ else
fi
fi

# Fetch nix archive
rel="$(head -n1 "$RELEASE_FILE")"
url="${NIX_ARCHIVES_URL:-https://github.com/nixbuild/nix-quick-install-action/releases/download/$rel}/nix-$NIX_VERSION-$sys.tar.zstd"
archive="$(mktemp)"
curl -sL --retry 3 --retry-connrefused "$url" | zstd -df - -o "$archive"

# Unpack nix
# Fetch and unpack nix archive
if [[ "$sys" =~ .*-darwin ]]; then
# MacOS tar doesn't have the --skip-old-files, so we use rsync instead
tmpdir="$(mktemp -d)"
tar --keep-old-files --strip-components 1 -x -f "$archive" -C "$tmpdir"
rsync --archive --ignore-existing "$tmpdir/" /nix/
# MacOS tar doesn't have the --skip-old-files, so we use gtar
tar=gtar
else
tar --skip-old-files --strip-components 1 -x -f "$archive" -C /nix
tar=tar
fi
rm -f "$archive"
rel="$(head -n1 "$RELEASE_FILE")"
url="${NIX_ARCHIVES_URL:-https://github.com/nixbuild/nix-quick-install-action/releases/download/$rel}/nix-$NIX_VERSION-$sys.tar.zstd"
curl -sL --retry 3 --retry-connrefused "$url" | $tar --skip-old-files --strip-components 1 -x -I unzstd -C /nix

# Setup nix.conf
NIX_CONF_FILE="${XDG_CONFIG_HOME:-$HOME/.config}/nix/nix.conf"
Expand Down

0 comments on commit 7a1fd47

Please sign in to comment.