3 ms·
[apt/dnf/brew] install package_name vs. nix-env -iA package_name [apt/dnf/brew] search keyword vs. nix-env -qaP '*keyword*' Is Nix going t
by Evidlo 5y ago
[apt/dnf/brew] install package_name
vs.
nix-env -iA package_name
[apt/dnf/brew] search keyword
vs.
nix-env -qaP '*keyword*'
Is Nix going to become the git of package managers? Why can't there be a 'nix install' or 'nix search' for people who just want to use software?
That's why I like pip. I can tell a newbie to 'pip install' a package and they can immediately intuit what it does. It gets installed to their PATH, too.
- akiselev 5y agoNot to mention nix-env has been kinda-sorta-but-not-really-but-yes-really deprecated in favor of nix-shell... or has it? I don't know.
- callahad 5y agoThis is an active area of work; check out the docs for "experimental commands" at https://nixos.org/manual/nix/unstable/command-ref/new-cli/nix.html https://nixos.org/manual/nix/unstable/command-ref/new-cli/ni..., especially `nix profile` and `nix search`, where your examples would become: nix profile install nixpkgs#package_name nix search nixpkgs keyword
- dmitriid 5y ago1. How common is it to search outside nixpkgs? 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.
- kaba0 5y agoI remember there is a thread on this exact issue. The problem is more that there is no one nixpkgs channel, but several.
- callahad 5y agoMuch more common than you would expect coming from a traditional package manager, since Nix freely allows multiple versions of packages to coexist. E.g., many folks run a stable release of NixOS but install select user packages from unstable, while most development environment and packaging scenarios will pin to a specific commit of nixpkgs. Nevertheless, there is an alternative CLI that infers "nixpkgs" when omitted, but I can't seem to find it right now.
- lucideer 5y agoI 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.
- ianthehenry 5y agonix-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.
- dmitriid 5y agoHeh. Just came in to say that when I saw this: > You can search the package list using: > $ nix-env -qaP git I immediately said to myself "nope, not going to use this". For some reason unbeknownst to me developers think that CLI must be as inscrutable and cryptic as possible. You don't have to leak your tool's internals everywhere to provide a reasonable `nix search package-name`
- kaba0 5y agoNix search package-name does work actually. These are the older CLI tools and there is WIP for a newer interface.
- ris 5y agoMost people on the Nix world are moving away from stateful package management entirely, identifying it as precisely what causes complexity and mixed up & stale dependencies in the first place. It's much simpler to be able to either just name what you need when you're about to use it or put together a list of packages for an environment you're going to repeatedly use. The comparison in this case would be nix-shell -p qemu Which is gone and not junking up your system as soon as you've finished with the shell provided.