Take the terminal alacritty as example:
Normally people install it with
{
environment.systemPackages = [ pkgs.alacritty ];
}
But looking at the code, you can see there are two variants in the package, that depends on the variable withGraphics that can be set here and it is false by default.
In this case, To set withGraphics to true, use override:
{
environment.systemPackages = [
(pkgs.alacritty.override { withGraphics = true; })
];
}
If you don’t what those two predefined src and cargoHash, you can directly override them with overrideAttrs:
{
environment.systemPackages = [
(pkgs.alacritty.overrideAttrs {
src = .....;
version = ......;
cargoHash = .... ;
})
];
}
But actually, Rust packages are special and the above does not work and need extra steps, but you get the idea of override and overrideAttrs.
For both:
{
environment.systemPackages = [
((pkgs.alacritty.overrideAttrs {
src = .....;
version = ......;
cargoHash = .... ;
}).override { some_other_variable = something; })
];
}
For overlays, it is just the same, but it is applied system wide. That means all the package depending on alacritty now also depend on your custom one, which may also trigger rebuild.
overlays syntax for NixOS is just like this for above withGraphics = true
{
nixpkgs.overlays = [
(final: prev: {
alacritty = prev.alacritty.override { withGraphics = true; };
})
];
}