Skip to content

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

Merged
edolstra merged 1 commit intoNixOS:masterfrom
chreekat:b/prefetch-executable
Sep 21, 2020
Merged

nix-prefetch-url: Add --executable flag#4036
edolstra merged 1 commit intoNixOS:masterfrom
chreekat:b/prefetch-executable

Conversation

@chreekat
Copy link
Contributor

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

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 b/prefetch-executable branch from c46d6bd to 5fe375a Compare September 18, 2020 16:10
@chreekat
Copy link
Contributor Author

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

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

Thanks!

@chreekat chreekat deleted the b/prefetch-executable branch September 22, 2020 06:42
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.

2 participants