-
-
Notifications
You must be signed in to change notification settings - Fork 1.6k
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
Remove curl deps in install script #5096
Conversation
scripts/install.in
Outdated
@@ -76,14 +76,14 @@ fi | |||
|
|||
tarball=$tmpDir/nix-@nixVersion@-$system.tar.xz | |||
|
|||
require_util curl "download the binary tarball" | |||
require_util wget "download the binary tarball" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is macOS not shipping curl
instead of wget
?
How about just checking for both?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah! That's right.
I've pushed a few changes to support both wget and curl. I'm not a pro in bash, so there's probably room for improvement, let me know what you think 🙂
The eval buisness looks quite complex. diff --git a/scripts/install.in b/scripts/install.in
index b2fe7bc5c..62ab432d6 100755
--- a/scripts/install.in
+++ b/scripts/install.in
@@ -24,16 +24,6 @@ require_util() {
oops "you do not have '$1' installed, which I need to $2"
}
-get_download_command() {
- if command -v wget > /dev/null 2>&1; then
- echo "wget '$1' -O '$2'"
- elif command -v curl > /dev/null 2>&1; then
- echo "curl -L '$1' -o '$2'"
- else
- oops "you don't have wget or curl installed, which I need to download $3"
- fi
-}
-
case "$(uname -s).$(uname -m)" in
Linux.x86_64)
hash=@tarballHash_x86_64-linux@
@@ -90,10 +80,16 @@ require_util tar "unpack the binary tarball"
if [ "$(uname -s)" != "Darwin" ]; then
require_util xz "unpack the binary tarball"
fi
+if command -v wget > /dev/null 2>&1; then
+ fetch() { wget "$1" -O "$2"; }
+elif command -v curl > /dev/null 2>&1; then
+ fetch() { curl -L "$1" -o "$2"; }
+else
+ oops "you don't have wget or curl installed, which I need to download the binary tarball"
+fi
-tarballDownloadCmd=$(get_download_command $url $tarball "the tarball binary") || exit 1
echo "downloading Nix @nixVersion@ binary tarball for $system from '$url' to '$tmpDir'..."
-eval $tarballDownloadCmd || oops "failed to download '$url'"
+fetch "$url" "$tarball" || oops "failed to download '$url'"
if command -v sha256sum > /dev/null 2>&1; then
hash2="$(sha256sum -b "$tarball" | cut -c1-64)" |
Yeah, that's definitely better. I've pushed the changes. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Untested, but looks good to me. @domenkozar thoughts?
Can do a basic installer test (here, or in someone else's fork) on it (I think #4577 has enough context for a start). Maybe not ideal in this exact case, since GH probably would probably add wget and curl to both the ubuntu and macOS CI images if they weren't already there. But it's at least an independent north-star... (aside: ~staged installer test cases with missing utils would be in-scope for an installer test suite; I've been trying to drum up interest in https://discourse.nixos.org/t/installer-test-suite-small-project-s-high-leverage-help-wanted/13662) |
This pull request has been mentioned on NixOS Discourse. There might be relevant details there: https://discourse.nixos.org/t/installer-test-suite-small-project-s-high-leverage-help-wanted/13662/3 |
Hi 👋
I believe wget is installed by default on pretty much every linux distros, while curl isn't (e.g. Ubuntu 20.x). The less dependencies the better 🙂
If this pr is accepted, I believe the installation command on https://nixos.org/download.html#nix-quick-install might also be changed to something like
wget https://nixos.org/nix/install -O - | sh
.