example:
nix run .#cowsay -- flakes are neat
Some explanation of what the heck this means would be really useful.example:
nix run .#cowsay -- flakes are neat
Some explanation of what the heck this means would be really useful.To explain what's happening:
- The example above is running `nix run <flake output attribute> -- <arguments to pass to the flake output's binary>`.
- The `<flake output attribute>` here is `.#cowsay`, which is to be read as: `<flake reference>#<attribute path>`. The # is a separator here.
- The `<flake reference>` being `.` implies its a local flake at the current directory. The `<attribute path>` in this case is the output from the flake i.e. the `cowsay` program.
further fun to be found at: https://nixos.org/manual/nix/stable/command-ref/new-cli/nix....
As a meta-comment, yeah, this is kinda non-trivial for most of us. This is why we build devbox which provides a more familiar UX like `devbox add cowsay && devbox run -- cowsay "flakes are neat"`
It's convenient for passing options and args to a subprocess, but it customarily means "don't interpret anything following this as a short or long option, just as a positional argument". For example:
touch -f # error
touch -- -f # creates a file named "-f"
rm * # oh crap we just passed "rm -f" a bunch of files
rm -- * # don't treat that "-f" as an option, just delete the file named "-f"The first -- argument that is not an option-argument should be accepted as a delimiter indicating the end of options. Any following arguments should be treated as operands, even if they begin with the '-' character.
So it's run the cowsay attribute from the flake in the current directory, passing flakes are neat as input to cowsay.