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

Remove curl deps in install script #5096

Merged
merged 1 commit into from
Aug 30, 2021
Merged

Conversation

AnatoleLucet
Copy link
Contributor

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.

@@ -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"
Copy link
Member

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?

Copy link
Contributor Author

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 🙂

@Mic92
Copy link
Member

Mic92 commented Aug 8, 2021

The eval buisness looks quite complex.
I think the following approach is easier to read:.

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)"

@AnatoleLucet
Copy link
Contributor Author

Yeah, that's definitely better. I've pushed the changes.

Copy link
Member

@Mic92 Mic92 left a 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?

@abathur
Copy link
Member

abathur commented Aug 10, 2021

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)

@nixos-discourse
Copy link

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants