[Nix-dev] n00b question: nix-env --query that outputs Attributes

Andreas Källberg anka.213 at gmail.com
Mon Jun 11 15:38:14 CEST 2012


On 7 June 2012 14:59, Daniel Santa Cruz <dstcruz at gmail.com> wrote:
> After reading and re-reading the man page, I'm still not sure how to
> do a query that will output the attribute path of installed packages.
> I figured that I could change:
>
>> nix-env -qaP "*"
>
> into:
>
>> nix-env -q --installed -P "*"

If all your packages are the latest version and/or still exist in nixpkgs with
the same version this should work:

> nix-env -q '*' | xargs nix-env -qaP

This will search for all packages with the same name and version as the
already installed ones and print their attrPath. Note however that
this will fail
any of the packages has been updated to a newer version on nixpkgs (and the
old version was removed).

Otherwise you could search for all versions of the installed packages:

> nix-env -q '*'| sed 's/-[0-9].*//' |xargs nix-env -qaP

This will still fail if any of the packages was deleted, but I suppose
you can live with that.


More information about the nix-dev mailing list