nix-community/nix-bundle

Make CLI similar to nix build

Opened this issue · 1 comments

I think that the command line interface for nix-bundle should be similar to nix build. That would improve learnability and usability. For reference, this is the output of nix build --help:

$ nix build --help
Usage: nix build <FLAGS>... <INSTALLABLES>...

Summary: build a derivation or fetch a store path.

Flags:
      --arg <NAME> <EXPR>       argument to be passed to Nix functions
      --argstr <NAME> <STRING>  string-valued argument to be passed to Nix functions
      --dry-run                 show what this command would do without doing it
  -f, --file <FILE>             evaluate FILE rather than the default
  -I, --include <PATH>          add a path to the list of locations used to look up <...> file names
      --no-link                 do not create a symlink to the build result
  -o, --out-link <PATH>         path of the symlink to the build result

Examples:

  To build and run GNU Hello from NixOS 17.03:
  $ nix build -f channel:nixos-17.03 hello; ./result/bin/hello

  To build the build.x86_64-linux attribute from release.nix:
  $ nix build -f release.nix build.x86_64-linux

Note: this program is EXPERIMENTAL and subject to change.

Of course there would need to be an additional option, for example --exec, to specify the executable. $ nix-bundle hello /bin/hello would then become:

$ nix-bundle -f '<nixpkgs>' hello --exec /bin/hello`

-f defaults to ./default.nix, so if one has a project with a default.nix, one can simply bundle it via:

$ nix-bundle --exec /bin/executablename

Reasonable options to support are:

  • --arg <NAME> <EXPR>
  • --argstr <NAME> <STRING>
  • -f, --file <FILE>
  • -I, --include <PATH>
  • A new option --exec as explained above. One could allow to omit this if there's only one executable in the built derivation.

I assume that most of these options can be supported simply by passing them on to the Nix tools used inside the nix-bundle script.

This is definitely something that would be worth exploring! I definitely agree we should have more consistency on this. I started nix-bundle before Nix 2.0 was out and so nix-bundle has kind of random CLI arguments.

I have also thought about trying to get bundle into Nix itself so that you could just run nix bundle.