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

nix-prefetch-url: Add --executable flag #4036

Merged
merged 1 commit into from Sep 21, 2020

Conversation

@chreekat
Copy link
Contributor

@chreekat chreekat commented Sep 18, 2020

pkgs.fetchurl supports an executable argument, which is especially nice
when downloading a large executable. This patch adds the same option to
nix-prefetch-url.

I have tested this to work on the simple case of prefetching a little
executable:

  1. nix-prefetch-url --executable https://my/little/script
  2. Paste the hash into a pkgs.fetchurl-based package, script-pkg.nix
  3. Delete the output from the store to avoid any misidentified artifacts
  4. Realise the package script-pkg.nix

I repeated the above while using --name, as well.

I suspect --executable would have no meaningful effect if combined with
--unpack, but I have not tried it.

@chreekat
Copy link
Contributor Author

@chreekat chreekat commented Sep 18, 2020

Although I forgot to mention it in the commit, I also tested that I could execute the file. :)

pkgs.fetchurl supports an executable argument, which is especially nice
when downloading a large executable. This patch adds the same option to
nix-prefetch-url.

I have tested this to work on the simple case of prefetching a little
executable:

1. nix-prefetch-url --executable https://my/little/script
2. Paste the hash into a pkgs.fetchurl-based package, script-pkg.nix
3. Delete the output from the store to avoid any misidentified artifacts
4. Realise the package script-pkg.nix
5. Run the executable

I repeated the above while using --name, as well.

I suspect --executable would have no meaningful effect if combined with
--unpack, but I have not tried it.
@chreekat chreekat force-pushed the chreekat:b/prefetch-executable branch from c46d6bd to 5fe375a Sep 18, 2020
@chreekat
Copy link
Contributor Author

@chreekat chreekat commented Sep 18, 2020

Rebased onto latest master because I don't think the CI failure was related to my changes. Let's see.

@chreekat
Copy link
Contributor Author

@chreekat chreekat commented Sep 21, 2020

According to a comment by @edolstra, "We shouldn't add new flags to nix-prefetch-url. Any new functionality should be added to the nix command (e.g. as a nix prefetch subcommand)."

Unfortunately, adding an entire new subcommand to nix, which is still marked as experimental so I don't want to use it anyway, is probably not something I have time for right now.

@edolstra edolstra merged commit d93b373 into NixOS:master Sep 21, 2020
2 checks passed
2 checks passed
tests (ubuntu-latest)
Details
tests (macos-latest)
Details
@edolstra
Copy link
Member

@edolstra edolstra commented Sep 21, 2020

Thanks!

@chreekat chreekat deleted the chreekat:b/prefetch-executable branch Sep 22, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked issues

Successfully merging this pull request may close these issues.

None yet

2 participants
You can’t perform that action at this time.