Is there a way to combine packages with common prefixes in brackets? For example, if I install qt5 components, I would like to do something in my environment.systemPackages like qt = { full qtwebkit } rather than qt5.full qt5.qtwebkit and so on.
you’re looking for with
buildInputs = with qt5; [ qtwebkit qtbase ];
Thank you for this suggestion. I’m not sure how to use it. I also looked here nix pill buildInput but I don’t see how the buildInputs statement fits into my configuration.nix file. I mostly see it used in package builds.
@jonringer probably should have said environment.systemPackages
instead of buildInputs
.
EDIT: Err, actually, qtwebkit
is a library, not an application. You don’t install libraries in configuration.nix
.
Ok, well perhaps not a good example. Let me use xfce: if I have a bunch of xfce.this and xfce.that packages in my configuration.nix, can I simplify the code to read xfce = [ this that ]
Essentially:
environment.systemPackages = with pkgs; [
xfce = [ this that ];
];
The with
keyword allows the following Nix expression (in this case, the list denoted with square brackets) to use all the names within an attrset directly. So with pkgs;
is saying that you can write with pkgs; [ hello wget ]
instead of [ pkgs.hello pkgs.wget ]
. So if you also want the xfce
packages, you just add another with
.
environment.systemPackages = with pkgs; with xfce; [
this
that
];
EDIT: The Nix manual covers this pretty well: Introduction I recommend reading the whole Nix Expression Language section.
Yea, environment.systemPackages would have been more aligned with the original question. I just got done reviewing a few PRs
@ElvishJerricco is right, qtwebkit wouldn’t be used directly, but will be declared by the packages that care to use it. You should be able to just declare the packages that you care about and they will pull in their needed dependencies.
Thank you both for these suggestions.
Or, if you want to abuse the lib to be a bit cleaner:
environment.systemPackages = lib.attrValues rec {
inherit (pkgs) xfce
this that;
inherit (xfce) something and_something_else;
}
This way, it is evident from where something is imported. Using multiple 'with
's can become quite a mess.
The rec
is only required to recursively use xfce
. Otherwise, you would inherit
from (pkgs.xfce)
instead of (xcfe)
. That’s taste.