Overlays: Difference between revisions
imported>Mcdonc Distinguish between extensible and non-extensible attribute sets |
Adisbladis (talk | contribs) Separate python overlay args from nixpkgs overlay args |
||
(6 intermediate revisions by 6 users not shown) | |||
Line 18: | Line 18: | ||
== Data flow of overlays == | == Data flow of overlays == | ||
The data flow | The data flow of overlays, especially regarding <tt>prev</tt> and <tt>final</tt> arguments can be a bit confusing if you are not familiar with how overlays work. This graph shows the data flow: | ||
[[File:Dram-overlay-final-prev.png]] | [[File:Dram-overlay-final-prev.png]] | ||
Line 43: | Line 43: | ||
And <syntaxhighlight lang="nix">final: prev: firefox = final.firefox.override { ... };</syntaxhighlight> would cause infinite recursion. | And <syntaxhighlight lang="nix">final: prev: { firefox = final.firefox.override { ... }; }</syntaxhighlight> would cause infinite recursion. | ||
== Using overlays == | == Using overlays == | ||
Line 148: | Line 148: | ||
</syntaxhighlight> | </syntaxhighlight> | ||
Then, add the following contents to <tt>/etc/nixos/overlays-compat/overlays.nix</tt><ref>Based on [https://gitlab.com/samueldr/nixos-configuration/blob/3febd83b15210282d6435932944d426cd0a9e0ca/modules/overlays-compat/overlays.nix [[User: | Then, add the following contents to <tt>/etc/nixos/overlays-compat/overlays.nix</tt><ref>Based on [https://gitlab.com/samueldr/nixos-configuration/blob/3febd83b15210282d6435932944d426cd0a9e0ca/modules/overlays-compat/overlays.nix][[User:Samueldr|@samueldr]]<span>'s configuration: overlays-compat</span></ref>: | ||
<syntaxhighlight lang="nix"> | <syntaxhighlight lang="nix"> | ||
Line 225: | Line 225: | ||
final: prev: { | final: prev: { | ||
# elements of pkgs.gnome must be taken from gfinal and gprev | # elements of pkgs.gnome must be taken from gfinal and gprev | ||
gnome = prev.gnome.overrideScope | gnome = prev.gnome.overrideScope (gfinal: gprev: { | ||
mutter = gprev.mutter.overrideAttrs (oldAttrs: { | mutter = gprev.mutter.overrideAttrs (oldAttrs: { | ||
patches = oldAttrs.patches ++ [ | patches = oldAttrs.patches ++ [ | ||
Line 295: | Line 295: | ||
final: prev: | final: prev: | ||
# Within the overlay we use a recursive set, though I think we can use `final` as well. | # Within the overlay we use a recursive set, though I think we can use `final` as well. | ||
{ | |||
# nix-shell -p python.pkgs.my_stuff | # nix-shell -p python.pkgs.my_stuff | ||
python = prev.python.override { | python = prev.python.override { | ||
# Careful, we're using a different final and prev here! | # Careful, we're using a different final and prev here! | ||
packageOverrides = | packageOverrides = pyfinal: pyprev: { | ||
my_stuff = | my_stuff = pyprev.buildPythonPackage rec { | ||
pname = "pyaes"; | pname = "pyaes"; | ||
version = "1.6.0"; | version = "1.6.0"; | ||
src = | src = pyprev.fetchPypi { | ||
inherit pname version; | inherit pname version; | ||
hash = "0bp9bjqy1n6ij1zb86wz9lqa1dhla8qr1d7w2kxyn7jbj56sbmcw"; | hash = "0bp9bjqy1n6ij1zb86wz9lqa1dhla8qr1d7w2kxyn7jbj56sbmcw"; | ||
Line 311: | Line 311: | ||
}; | }; | ||
# nix-shell -p pythonPackages.my_stuff | # nix-shell -p pythonPackages.my_stuff | ||
pythonPackages = python.pkgs; | pythonPackages = final.python.pkgs; | ||
# nix-shell -p my_stuff | # nix-shell -p my_stuff | ||
my_stuff = pythonPackages.buildPythonPackage rec { | my_stuff = final.pythonPackages.buildPythonPackage rec { | ||
pname = "pyaes"; | pname = "pyaes"; | ||
version = "1.6.0"; | version = "1.6.0"; | ||
Line 397: | Line 397: | ||
* [https://nixos.org/manual/nixpkgs/unstable/#using-community-maintained-rust-toolchains Details in the Nixpkgs manual for using Rust overlays] | * [https://nixos.org/manual/nixpkgs/unstable/#using-community-maintained-rust-toolchains Details in the Nixpkgs manual for using Rust overlays] | ||
* [https://github.com/peter-sa/nixos-rocm Overlay for Radeon Open-Compute packages] | * [https://github.com/peter-sa/nixos-rocm Overlay for Radeon Open-Compute packages] | ||
* [https://github.com/garbas/nixpkgs-python Overlay by Rok Garbas for a set of python packages built by pypi2nix] | * [https://github.com/garbas/nixpkgs-python Overlay by Rok Garbas for a set of python packages built by pypi2nix (archived)] | ||
== See also == | == See also == | ||
Line 403: | Line 403: | ||
* [https://nixos.org/nixpkgs/manual/#chap-overlays Overlays in nixpkgs manual] | * [https://nixos.org/nixpkgs/manual/#chap-overlays Overlays in nixpkgs manual] | ||
* [https://blog.flyingcircus.io/2017/11/07/nixos-the-dos-and-donts-of-nixpkgs-overlays/ Blog post "The DOs and DON’Ts of nixpkgs overlays"] | * [https://blog.flyingcircus.io/2017/11/07/nixos-the-dos-and-donts-of-nixpkgs-overlays/ Blog post "The DOs and DON’Ts of nixpkgs overlays"] | ||
* [https://www.youtube.com/watch?v=s2fkgkN55vk&list=PLgknCdxP89ReD6gxl755B6G_CI65z4J2e Nixpkgs Overlays – A place for all excluded packages] - Talk by Nicolas B. Pierron at NixCon 2017 | |||
==== References ==== | ==== References ==== |