Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use gtar to restore /nix on macOS #40

Merged
merged 2 commits into from
Jan 8, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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