Overlays: Difference between revisions
imported>Krey No edit summary |
imported>Samueldr Adds code to use nixos configured overlays as <nixpkgs-overlays>. |
||
Line 38: | Line 38: | ||
There is a configuration option <code>nixpkgs.overlays</code>. Overlays set here will '''not''' be automatically applied by nix tools. | There is a configuration option <code>nixpkgs.overlays</code>. Overlays set here will '''not''' be automatically applied by nix tools. | ||
===== Using <code>nixpkgs.overlays</code> as <code><nixpkgs-overlays></code> ===== | |||
In <tt>configuration.nix</tt>, add to <code>nix.nixPath</code>. | |||
<syntaxhighlight lang="nix"> | |||
nix.nixPath = [ | |||
"nixpkgs-overlays=/etc/nixos/overlays-compat/" | |||
]; | |||
</syntaxhighlight> | |||
And, add the file <tt>/etc/nixos/overlays-compat/default.nix</tt>: | |||
<syntaxhighlight lang="nix"> | |||
self: super: | |||
with super.lib; | |||
let | |||
# Using the nixos plumbing that's used to evaluate the config... | |||
eval = import <nixpkgs/nixos/lib/eval-config.nix>; | |||
# Evaluate the config, | |||
paths = (eval {modules = [(import <nixos-config>)];}) | |||
# then get the `nixpkgs.overlays` option. | |||
.config.nixpkgs.overlays | |||
; | |||
in | |||
foldl' (flip extends) (_: super) paths self | |||
</syntaxhighlight> | |||
== External Documentation == | == External Documentation == |