For installing a package, you have to specify the package repository. For uninstalling, you don't because you're operating against a separate repository containing locally installed packages. This should be the same for the new CLI too.
Looking at the manual[1], instead of:
nix profile remove nixpkgs#ripgrep
You'd probably need to run:
nix profile remove packages.x86_64-linux.ripgrep
For searching packages,
nix search nixpkgs ripgrep
is faster than
nix-env -qaP ripgrep
But I find the online search UI[2] to be far more superior.
I think nix already does what you want for search, but the install suggestion is a good idea.
`nix install packagename` would fall outside the current command convention (since `profile` is a command and `install` is a subcommand of profile), so they would have to introduce a new top-level command "install" which is aliased to `profile install`. Given the `nix` command itself is a newer/experimental alternative to `nix-env`, et al., in a seemingly similar spirit to `apt-get/apt-cache` -vs- `apt`, I think creating such an alias would be a very reasonable thing to do.
`nix search packagename` afaik currently does what you (probably) want. It defaults to searching in both `packages.<system>` & `legacyPackages.<system>`, so nixpkgs will be included. I suspect the inclusion of `nixpkgs` in the examples above is actually narrowing the search, possibly for speed: doing `nix search packagename` is currently a bit slow.
nix-env is a little worse than your examples suggest. It's really:
nix-env -iA nixpkgs.package_name
Can't forget the leading `nixpkgs.`. And searching is:
nix-env -qaP '.*keyword.*'
Because `--query` takes a regex -- unlike all of the other nix-env subcommands, which take globs.
But `nix search` has been available for years, and works great.
There's still no nice interface for installing packages, but that's not actually an operation you do very often with Nix, since you're mostly specifying environments in files, rather than mutating your own user environment. Of course, newcomers don't know that, and they want to manipulate things in their PATH like every other package manager, so that's not an excuse for the bad ergonomics. The upcoming version of Nix adds `nix profile install` which is a bit more intuitive.
I think Nix's current CLI makes git look positively humane, but I'm encouraged that it's been steadily improving.
It does slowly happen. There's a new `nix` command (a.k.a. Nix 2.0), which has a better CLI, though it's not yet 100% complete, I believe. But already useful (e.g. `nix search`).
I learned about this very recently[1] and it seems like an amazing use case that I wish got more play in the marketing of Nix. I have a lot of dumb "productivity" scripts that I wrote at work (Linux) that I can't run at home (macOS) because of differences in the behavior of `find` or `date` whatever. I plan on porting them to use `nixpkgs.findutils` etc. and never having to worry about this again.
I would also love to see a tutorial for beginners on Linux that covers common tasks like viewing changelogs, creating a simple package, and pinning multiple dependencies in an environment.
2. How common is it to install from outside nixpkgs?
Depending on the answers to the above:
`nix install packagename` should default to nixpkgs and install into currently active profile (if auch a thing as currently active profile is a thing in nix, of course)
`nix search packagename` should default to searching nixpkgs
Boom. You improved developer/user experience 100-fold with little effort.
Edit: 99.9% of examples in the linked page have nixpkgs# prefix for packages. Just drop it, and make it default. Everyone will thank you.
Cheers.
Yeah for sure, I was too lazy to make a PR on nixpkgs, but this[0] is what I wrote if anyone stumbles on this using NixOS. The nix package manager can be installed on top of most OS's too.
reply