main
 1<!DOCTYPE html>
 2<html lang="en">
 3<head>
 4<!-- Oct 07, 2022 -->
 5<meta charset="utf-8" />
 6<meta name="viewport" content="width=device-width, initial-scale=1" />
 7<title>NixOS overlay notes</title>
 8<meta name="author" content="Vincent Demeester" />
 9<meta name="keywords" content="article" />
10<meta name="generator" content="Org Mode" />
11<link rel='icon' type='image/x-icon' href='/images/favicon.ico'/>
12<meta name='viewport' content='width=device-width, initial-scale=1'>
13<link rel='stylesheet' href='/css/new.css' type='text/css'/>
14<link rel='stylesheet' href='/css/syntax.css' type='text/css'/>
15<link href='/index.xml' rel='alternate' type='application/rss+xml' title='Vincent Demeester' />
16</head>
17<body>
18<main id="content" class="content">
19<header>
20<h1 class="title">NixOS overlay notes</h1>
21</header><p>
22<a href="https://nixos.org">NixOS</a> has a concept of <code>overlays</code> since a while (<a href="https://nixos.org/nix-dev/2016-December/022386.html">around 2016</a>). The
23official manual has a chapter on it : <a href="https://nixos.org/nixpkgs/manual/#chap-overlays">Overlays</a>.
24</p>
25
26<blockquote>
27<p>
28Overlays are used to add layers in the fix-point used by Nixpkgs to
29compose the set of all packages.
30</p>
31</blockquote>
32
33<p>
34There is two distinct element to overlays:
35</p>
36
37<ul class="org-ul">
38<li>How to define overlays ?</li>
39<li>Where <code>nix</code> (and NixOS) looks for it ?</li>
40</ul>
41
42<section id="outline-container-h:56de4f99-53be-49fd-b969-a419d8e9273f" class="outline-2">
43<h2 id="h:56de4f99-53be-49fd-b969-a419d8e9273f">Define an overlay</h2>
44<div class="outline-text-2" id="text-h:56de4f99-53be-49fd-b969-a419d8e9273f">
45<p>
46According to the documentation, « Overlays are Nix functions which
47accept two arguments, conventionally called self and super, and return
48a set of packages ». The documentation gives an example :
49</p>
50
51<div class="org-src-container">
52<pre class="src src-nix">self: super:
53
54{
55  <span class="org-nix-attribute">boost</span> = super.boost.override {
56    <span class="org-nix-attribute">python</span> = self.python3;
57  };
58  <span class="org-nix-attribute">rr</span> = super.callPackage <span class="org-nix-constant">./pkgs/rr</span> {
59    <span class="org-nix-attribute">stdenv</span> = self.stdenv_32bit;
60  };
61}
62</pre>
63</div>
64
65<p>
66I used to have a personal channels on github : <a href="https://github.com/vdemeester/sbrpkgs/">sbrpkgs</a>. Let&rsquo;s convert
67this repository to an overlay by updating the <code>default.nix</code> file.
68</p>
69</div>
70</section>
71</main>
72<footer id="postamble" class="status">
73<footer>
74     <small><a href="/" rel="history">Index</a><a href="/sitemap.html">Sitemap</a><a href="https://dl.sbr.pm/">Files</a></small><br/>
75     <small class='questions'>Questions, comments ? Please use my <a href="https://lists.sr.ht/~vdemeester/public-inbox">public inbox</a> by sending a plain-text email to <a href="mailto:~vdemeester/public-inbox@lists.sr.ht">~vdemeester/public-inbox@lists.sr.ht</a>.</small><br/>
76     <small class='copyright'>
77      Content and design by Vincent Demeester
78      (<a rel='licence' href='http://creativecommons.org/licenses/by-nc-sa/3.0/'>Some rights reserved</a>)
79    </small><br />
80</footer>
81</footer>
82</body>
83</html>