···4444 packedRefsName = toString path + "/packed-refs";
4545 in if lib.pathExists fileName
4646 then
4747- let fileContent = readFile fileName;
4747+ let fileContent = lib.fileContents fileName;
4848 # Sometimes git stores the commitId directly in the file but
4949 # sometimes it stores something like: «ref: refs/heads/branch-name»
5050- matchRef = match "^ref: (.*)\n$" fileContent;
5050+ matchRef = match "^ref: (.*)$" fileContent;
5151 in if isNull matchRef
5252- then lib.removeSuffix "\n" fileContent
5252+ then fileContent
5353 else readCommitFromFile path (lib.head matchRef)
5454 # Sometimes, the file isn't there at all and has been packed away in the
5555 # packed-refs file, so we have to grep through it:
···3333following incompatible changes:</para>
34343535<itemizedlist>
3636+3637 <listitem>
3738 <para>Shell aliases for systemd sub-commands
3839 <link xlink:href="https://github.com/NixOS/nixpkgs/pull/15598">were dropped</link>:
3940 <command>start</command>, <command>stop</command>,
4041 <command>restart</command>, <command>status</command>.</para>
4142 </listitem>
4343+4444+ <listitem>
4545+ <para>Redis now binds to 127.0.0.1 only instead of listening to all network interfaces. This is the default
4646+ behavior of Redis 3.2</para>
4747+ </listitem>
4848+4249</itemizedlist>
43504451
+12-27
nixos/modules/misc/version.nix
···3535 nixosLabel = mkOption {
3636 type = types.str;
3737 description = ''
3838- NixOS version name to be used in the names of generated
3939- outputs and boot labels.
4040-4141- If you ever wanted to influence the labels in your GRUB menu,
4242- this is option is for you.
4343-4444- Can be set directly or with <envar>NIXOS_LABEL</envar>
4545- environment variable for <command>nixos-rebuild</command>,
4646- e.g.:
4747-4848- <screen>
4949- #!/bin/sh
5050- today=`date +%Y%m%d`
5151- branch=`(cd nixpkgs ; git branch 2>/dev/null | sed -n '/^\* / { s|^\* ||; p; }')`
5252- revision=`(cd nixpkgs ; git rev-parse HEAD)`
5353- export NIXOS_LABEL="$today.$branch-''${revision:0:7}"
5454- nixos-rebuild switch</screen>
3838+ Label to be used in the names of generated outputs and boot
3939+ labels.
5540 '';
5641 };
57425843 nixosVersion = mkOption {
5944 internal = true;
6045 type = types.str;
6161- description = "NixOS version.";
4646+ description = "The full NixOS version (e.g. <literal>16.03.1160.f2d4ee1</literal>).";
6247 };
63486449 nixosRelease = mkOption {
6550 readOnly = true;
6651 type = types.str;
6767- default = readFile releaseFile;
6868- description = "NixOS release.";
5252+ default = fileContents releaseFile;
5353+ description = "The NixOS release (e.g. <literal>16.03</literal>).";
6954 };
70557156 nixosVersionSuffix = mkOption {
7257 internal = true;
7358 type = types.str;
7474- default = if pathExists suffixFile then readFile suffixFile else "pre-git";
7575- description = "NixOS version suffix.";
5959+ default = if pathExists suffixFile then fileContents suffixFile else "pre-git";
6060+ description = "The NixOS version suffix (e.g. <literal>1160.f2d4ee1</literal>).";
7661 };
77627863 nixosRevision = mkOption {
7964 internal = true;
8065 type = types.str;
8181- default = if pathExists revisionFile then readFile revisionFile else "master";
8282- description = "NixOS Git revision hash.";
6666+ default = if pathExists revisionFile then fileContents revisionFile else "master";
6767+ description = "The Git revision from which this NixOS configuration was built.";
8368 };
84698570 nixosCodeName = mkOption {
8671 readOnly = true;
8772 type = types.str;
8888- description = "NixOS release code name.";
7373+ description = "The NixOS release code name (e.g. <literal>Emu</literal>).";
8974 };
90759176 defaultChannel = mkOption {
···10287 system = {
10388 # These defaults are set here rather than up there so that
10489 # changing them would not rebuild the manual
105105- nixosLabel = mkDefault (maybeEnv "NIXOS_LABEL" cfg.nixosVersion);
106106- nixosVersion = mkDefault (maybeEnv "NIXOS_VERSION" (cfg.nixosRelease + cfg.nixosVersionSuffix));
9090+ nixosLabel = mkDefault cfg.nixosVersion;
9191+ nixosVersion = mkDefault (cfg.nixosRelease + cfg.nixosVersionSuffix);
10792 nixosRevision = mkIf (pathIsDirectory gitRepo) (mkDefault gitCommitId);
10893 nixosVersionSuffix = mkIf (pathIsDirectory gitRepo) (mkDefault (".git." + gitCommitId));
10994
+1-1
nixos/modules/security/grsecurity.nix
···97979898 # Configure system tunables
9999 boot.kernel.sysctl = {
100100- # Removed under grsecurity
100100+ # Read-only under grsecurity
101101 "kernel.kptr_restrict" = mkForce null;
102102 } // optionalAttrs config.nix.useSandbox {
103103 # chroot(2) restrictions that conflict with sandboxed Nix builds
+1
nixos/modules/services/audio/mopidy.nix
···4747 };
48484949 configuration = mkOption {
5050+ default = "";
5051 type = types.lines;
5152 description = ''
5253 The configuration that Mopidy should use.
+578
nixos/modules/services/editors/emacs.xml
···11+<chapter xmlns="http://docbook.org/ns/docbook"
22+ xmlns:xlink="http://www.w3.org/1999/xlink"
33+ xmlns:xi="http://www.w3.org/2001/XInclude"
44+ version="5.0"
55+ xml:id="module-services-emacs">
66+77+ <title>Emacs</title>
88+99+ <!--
1010+ Documentation contributors:
1111+ Damien Cassou @DamienCassou
1212+ Thomas Tuegel @ttuegel
1313+ Rodney Lorrimar @rvl
1414+ -->
1515+1616+ <para>
1717+ <link xlink:href="http://www.gnu.org/software/emacs/">Emacs</link>
1818+ is an extensible, customizable, self-documenting real-time display
1919+ editor — and more. At its core is an interpreter for Emacs Lisp, a
2020+ dialect of the Lisp programming language with extensions to
2121+ support text editing.
2222+ </para>
2323+2424+ <para>
2525+ Emacs runs within a graphical desktop environment using the X
2626+ Window System, but works equally well on a text terminal. Under
2727+ <productname>OS X</productname>, a "Mac port" edition is
2828+ available, which uses Apple's native GUI frameworks.
2929+ </para>
3030+3131+ <para>
3232+ <productname>Nixpkgs</productname> provides a superior environment
3333+ for running <application>Emacs</application>. It's simple to
3434+ create custom builds by overriding the default packages. Chaotic
3535+ collections of Emacs Lisp code and extensions can be brought under
3636+ control using declarative package
3737+ management. <productname>NixOS</productname> even provides a
3838+ <command>systemd</command> user service for automatically
3939+ starting the Emacs daemon.
4040+ </para>
4141+4242+ <section>
4343+ <title>Installing <application>Emacs</application></title>
4444+4545+ <para>
4646+ Emacs can installed in the normal way for Nix (see <xref
4747+ linkend="sec-package-management" />). In addition, a NixOS
4848+ <emphasis>service</emphasis> can be enabled.
4949+ </para>
5050+5151+ <section>
5252+ <title>The Different Releases of Emacs</title>
5353+5454+ <para>
5555+ <productname>Nixpkgs</productname> defines several basic Emacs
5656+ packages. The following are attributes belonging to the
5757+ <varname>pkgs</varname> set:
5858+5959+ <variablelist>
6060+ <varlistentry>
6161+ <term><varname>emacs</varname></term>
6262+ <term><varname>emacs24</varname></term>
6363+ <listitem>
6464+ <para>
6565+ The latest stable version of Emacs 24 using the <link
6666+ xlink:href="http://www.gtk.org">GTK+ 2</link> widget
6767+ toolkit.
6868+ </para>
6969+ </listitem>
7070+ </varlistentry>
7171+ <varlistentry>
7272+ <term><varname>emacs24-nox</varname></term>
7373+ <listitem>
7474+ <para>
7575+ Emacs 24 built without any dependency on X11
7676+ libraries.
7777+ </para>
7878+ </listitem>
7979+ </varlistentry>
8080+ <varlistentry>
8181+ <term><varname>emacs24Macport</varname></term>
8282+ <listitem>
8383+ <para>
8484+ Emacs 24 with the "Mac port" patches, providing a more
8585+ native look and feel under OS X.
8686+ </para>
8787+ </listitem>
8888+ </varlistentry>
8989+ <varlistentry>
9090+ <term><varname>emacs25pre</varname></term>
9191+ <listitem>
9292+ <para>
9393+ A pretest version of what will become the first
9494+ version of Emacs 25.
9595+ </para>
9696+ </listitem>
9797+ </varlistentry>
9898+ </variablelist>
9999+ </para>
100100+101101+ <para>
102102+ If those aren't suitable, then the following imitation Emacs
103103+ editors are also available in Nixpkgs:
104104+ <link xlink:href="https://www.gnu.org/software/zile/">Zile</link>,
105105+ <link xlink:href="http://homepage.boetes.org/software/mg/">mg</link>,
106106+ <link xlink:href="http://yi-editor.github.io/">Yi</link>.
107107+ </para>
108108+109109+ </section>
110110+ <section>
111111+ <title>Adding Packages to Emacs</title>
112112+ <para>
113113+ Emacs includes an entire ecosystem of functionality beyond
114114+ text editing, including a project planner, mail and news
115115+ reader, debugger interface, calendar, and more.
116116+ </para>
117117+118118+ <para>
119119+ Most extensions are gotten with the Emacs packaging system
120120+ (<filename>package.el</filename>) from <link
121121+ xlink:href="https://elpa.gnu.org/">Emacs Lisp Package Archive
122122+ (<acronym>ELPA</acronym>)</link>,
123123+ <link xlink:href="https://melpa.org/"><acronym>MELPA</acronym></link>,
124124+ <link xlink:href="https://stable.melpa.org/">MELPA Stable</link>,
125125+ and <link xlink:href="http://orgmode.org/elpa.html">Org ELPA</link>.
126126+ Nixpkgs is regularly updated to mirror all these archives.
127127+ </para>
128128+129129+ <para>
130130+ Under NixOS, you can continue to use
131131+ <function>package-list-packages</function> and
132132+ <function>package-install</function> to install packages. You
133133+ can also declare the set of Emacs packages you need using the
134134+ derivations from Nixpkgs. The rest of this section discusses
135135+ declarative installation of Emacs packages through nixpkgs.
136136+ </para>
137137+138138+ <note>
139139+ <para>
140140+ This documentation describes the new Emacs packages
141141+ framework in NixOS 16.03
142142+ (<varname>emacsPackagesNg</varname>) which should not be
143143+ confused with the previous and deprecated framework
144144+ (<varname>emacs24Packages</varname>).
145145+ </para>
146146+ </note>
147147+148148+ <para>
149149+ The first step to declare the list of packages you want in
150150+ your Emacs installation is to create a dedicated
151151+ derivation. This can be done in a dedicated
152152+ <filename>emacs.nix</filename> file such as:
153153+154154+ <example xml:id="ex-emacsNix">
155155+ <title>Nix expression to build Emacs with packages (<filename>emacs.nix</filename>)</title>
156156+ <programlisting language="nix">
157157+/*
158158+This is a nix expression to build Emacs and some Emacs packages I like
159159+from source on any distribution where Nix is installed. This will install
160160+all the dependencies from the nixpkgs repository and build the binary files
161161+without interfering with the host distribution.
162162+163163+To build the project, type the following from the current directory:
164164+165165+$ nix-build emacs.nix
166166+167167+To run the newly compiled executable:
168168+169169+$ ./result/bin/emacs
170170+*/
171171+{ pkgs ? import <nixpkgs> {} }: <co xml:id="ex-emacsNix-1" />
172172+173173+let
174174+ myEmacs = pkgs.emacs; <co xml:id="ex-emacsNix-2" />
175175+ emacsWithPackages = (pkgs.emacsPackagesNgGen myEmacs).emacsWithPackages; <co xml:id="ex-emacsNix-3" />
176176+in
177177+ emacsWithPackages (epkgs: (with epkgs.melpaStablePackages; [ <co xml:id="ex-emacsNix-4" />
178178+ magit # ; Integrate git <C-x g>
179179+ zerodark-theme # ; Nicolas' theme
180180+ ]) ++ (with epkgs.melpaPackages; [ <co xml:id="ex-emacsNix-5" />
181181+ undo-tree # ; <C-x u> to show the undo tree
182182+ zoom-frm # ; increase/decrease font size for all buffers %lt;C-x C-+>
183183+ ]) ++ (with epkgs.elpaPackages; [ <co xml:id="ex-emacsNix-6" />
184184+ auctex # ; LaTeX mode
185185+ beacon # ; highlight my cursor when scrolling
186186+ nameless # ; hide current package name everywhere in elisp code
187187+ ]) ++ [
188188+ pkgs.notmuch # From main packages set <co xml:id="ex-emacsNix-7" />
189189+ ])
190190+</programlisting>
191191+ </example>
192192+193193+ <calloutlist>
194194+ <callout arearefs="ex-emacsNix-1">
195195+ <para>
196196+ The first non-comment line in this file
197197+ (<literal>{ pkgs ? ... }</literal>)
198198+ indicates that the whole file represents a function.
199199+ </para>
200200+ </callout>
201201+202202+ <callout arearefs="ex-emacsNix-2">
203203+ <para>
204204+ The <varname>let</varname> expression below defines a
205205+ <varname>myEmacs</varname> binding pointing to the current
206206+ stable version of Emacs. This binding is here to separate the
207207+ choice of the Emacs binary from the specification of the
208208+ required packages.
209209+ </para>
210210+ </callout>
211211+212212+ <callout arearefs="ex-emacsNix-3">
213213+ <para>
214214+ This generates an <varname>emacsWithPackages</varname>
215215+ function. It takes a single argument: a function from a
216216+ package set to a list of packages (the packages that will
217217+ be available in Emacs).
218218+ </para>
219219+ </callout>
220220+221221+ <callout arearefs="ex-emacsNix-4">
222222+ <para>
223223+ The rest of the file specifies the list of packages to
224224+ install. In the example, two packages
225225+ (<varname>magit</varname> and
226226+ <varname>zerodark-theme</varname>) are taken from MELPA
227227+ stable.
228228+ </para>
229229+ </callout>
230230+231231+ <callout arearefs="ex-emacsNix-5">
232232+ <para>
233233+ Two packages (<varname>undo-tree</varname> and
234234+ <varname>zoom-frm</varname>) are taken from MELPA.
235235+ </para>
236236+ </callout>
237237+238238+ <callout arearefs="ex-emacsNix-6">
239239+ <para>Three packages are taken from GNU ELPA.</para>
240240+ </callout>
241241+242242+ <callout arearefs="ex-emacsNix-7">
243243+ <para>
244244+ <varname>notmuch</varname> is taken from a nixpkgs derivation
245245+ which contains an Emacs mode.
246246+ </para>
247247+ </callout>
248248+249249+ </calloutlist>
250250+ </para>
251251+252252+ <para>
253253+ The result of this configuration will be an
254254+ <command>emacs</command> command which launches Emacs with all
255255+ of your chosen packages in the <varname>load-path</varname>.
256256+ </para>
257257+258258+ <para>
259259+ You can check that it works by executing this in a terminal:
260260+261261+<screen>
262262+$ nix-build emacs.nix
263263+$ ./result/bin/emacs -q
264264+</screen>
265265+266266+ and then typing <literal>M-x package-initialize</literal>.
267267+ Check that you can use all the packages you want in this
268268+ Emacs instance. For example, try switching to the zerodark
269269+ theme through
270270+ <literal>M-x load-theme <RET> zerodark <RET> y</literal>.
271271+ </para>
272272+273273+ <tip>
274274+ <para>
275275+ A few popular extensions worth checking out are: auctex,
276276+ company, edit-server, flycheck, helm, iedit, magit,
277277+ multiple-cursors, projectile, and yasnippet.
278278+ </para>
279279+ </tip>
280280+281281+ <para>
282282+ The list of available packages in the various ELPA
283283+ repositories can be seen with the following commands:
284284+ <example>
285285+ <title>Querying Emacs packages</title>
286286+ <programlisting><![CDATA[
287287+nix-env -f "<nixpkgs>" -qaP -A emacsPackagesNg.elpaPackages
288288+nix-env -f "<nixpkgs>" -qaP -A emacsPackagesNg.melpaPackages
289289+nix-env -f "<nixpkgs>" -qaP -A emacsPackagesNg.melpaStablePackages
290290+nix-env -f "<nixpkgs>" -qaP -A emacsPackagesNg.orgPackages
291291+]]></programlisting>
292292+ </example>
293293+ </para>
294294+295295+ <para>
296296+ If you are on NixOS, you can install this particular Emacs for
297297+ all users by adding it to the list of system packages
298298+ (see <xref linkend="sec-declarative-package-mgmt" />). Simply
299299+ modify your file <filename>configuration.nix</filename> to
300300+ make it contain:
301301+ <example>
302302+ <title>Custom Emacs in <filename>configuration.nix</filename></title>
303303+ <programlisting><![CDATA[
304304+{
305305+ environment.systemPackages = [
306306+ # [...]
307307+ (import /path/to/emacs.nix { inherit pkgs; })
308308+ ];
309309+}
310310+]]></programlisting>
311311+ </example>
312312+ </para>
313313+314314+ <para>
315315+ In this case, the next <command>nixos-rebuild switch</command>
316316+ will take care of adding your <command>emacs</command> to the
317317+ <varname>PATH</varname> environment variable
318318+ (see <xref linkend="sec-changing-config" />).
319319+ </para>
320320+321321+<!-- fixme: i think the following is better done with config.nix
322322+https://nixos.org/nixpkgs/manual/#sec-modify-via-packageOverrides
323323+-->
324324+ <para>
325325+ If you are not on NixOS or want to install this particular
326326+ Emacs only for yourself, you can do so by adding it to your
327327+ <filename>~/.nixpkgs/config.nix</filename>
328328+ (see <link xlink:href="http://nixos.org/nixpkgs/manual/#sec-modify-via-packageOverrides">Nixpkgs manual</link>):
329329+ <example>
330330+ <title>Custom Emacs in <filename>~/.nixpkgs/system.nix</filename></title>
331331+ <programlisting><![CDATA[
332332+{
333333+ packageOverrides = super: let self = super.pkgs; in {
334334+ myemacs = import /path/to/emacs.nix { pkgs = self; };
335335+ };
336336+}
337337+]]></programlisting>
338338+ </example>
339339+ </para>
340340+341341+ <para>
342342+ In this case, the next
343343+ <literal>nix-env -f '<nixpkgs>' -iA myemacs</literal>
344344+ will take care of adding your emacs to the
345345+ <varname>PATH</varname> environment variable.
346346+ </para>
347347+ </section>
348348+349349+ <section>
350350+ <title>Advanced Emacs Configuration</title>
351351+352352+ <para>
353353+ If you want, you can tweak the Emacs package itself from your
354354+ <filename>emacs.nix</filename>. For example, if you want to
355355+ have a GTK+3-based Emacs instead of the default GTK+2-based
356356+ binary and remove the automatically generated
357357+ <filename>emacs.desktop</filename> (useful is you only use
358358+ <command>emacsclient</command>), you can change your file
359359+ <filename>emacs.nix</filename> in this way:
360360+ </para>
361361+362362+ <example xml:id="ex-emacsGtk3Nix">
363363+ <title>Custom Emacs build</title>
364364+ <programlisting><![CDATA[
365365+{ pkgs ? import <nixpkgs> {} }:
366366+let
367367+ myEmacs = pkgs.lib.overrideDerivation (pkgs.emacs.override {
368368+ # Use gtk3 instead of the default gtk2
369369+ withGTK3 = true;
370370+ withGTK2 = false;
371371+ }) (attrs: {
372372+ # I don't want emacs.desktop file because I only use
373373+ # emacsclient.
374374+ postInstall = attrs.postInstall + ''
375375+ rm $out/share/applications/emacs.desktop
376376+ '';
377377+ });
378378+in [...]
379379+]]></programlisting>
380380+ </example>
381381+382382+ <para>
383383+ After building this file as shown in <xref linkend="ex-emacsNix" />,
384384+ you will get an GTK3-based Emacs binary pre-loaded with your
385385+ favorite packages.
386386+ </para>
387387+ </section>
388388+ </section>
389389+390390+<section>
391391+ <title>Running Emacs as a Service</title>
392392+ <para>
393393+ <productname>NixOS</productname> provides an optional
394394+ <command>systemd</command> service which launches
395395+ <link xlink:href="https://www.gnu.org/software/emacs/manual/html_node/emacs/Emacs-Server.html">
396396+ Emacs daemon
397397+ </link>
398398+ with the user's login session.
399399+ </para>
400400+401401+ <para>
402402+ <emphasis>Source:</emphasis>
403403+ <filename>modules/services/editors/emacs.nix</filename>
404404+ </para>
405405+406406+ <section>
407407+ <title>Enabling the Service</title>
408408+409409+ <para>
410410+ To install and enable the <command>systemd</command>
411411+ user service for Emacs daemon, add the following to your
412412+ <filename>configuration.nix</filename>:
413413+414414+ <programlisting><![CDATA[
415415+services.emacs.enable = true;
416416+services.emacs.package = import /home/cassou/.emacs.d { pkgs = pkgs; };
417417+]]></programlisting>
418418+ </para>
419419+420420+ <para>
421421+ The <varname>services.emacs.package</varname> option allows a
422422+ custom derivation to be used, for example, one created by
423423+ <function>emacsWithPackages</function>.
424424+ </para>
425425+426426+ <para>
427427+ Ensure that the Emacs server is enabled for your user's Emacs
428428+ configuration, either by customizing the
429429+ <varname>server-mode</varname> variable, or by adding
430430+ <literal>(server-start)</literal> to
431431+ <filename>~/.emacs.d/init.el</filename>.
432432+ </para>
433433+434434+ <para>
435435+ To start the daemon, execute the following:
436436+437437+<screen>
438438+$ nixos-rebuild switch # to activate the new configuration.nix
439439+$ systemctl --user daemon-reload # to force systemd reload
440440+$ systemctl --user start emacs.service # to start the Emacs daemon
441441+</screen>
442442+443443+ The server should now be ready to serve Emacs clients.
444444+ </para>
445445+446446+ </section>
447447+448448+ <section>
449449+ <title>Starting the client</title>
450450+ <para>
451451+ Ensure that the emacs server is enabled, either by customizing
452452+ the <varname>server-mode</varname> variable, or by adding
453453+ <literal>(server-start)</literal> to
454454+ <filename>~/.emacs</filename>.
455455+ </para>
456456+457457+ <para>
458458+ To connect to the emacs daemon, run one of the following:
459459+ <programlisting><![CDATA[
460460+emacsclient FILENAME
461461+emacsclient --create-frame # opens a new frame (window)
462462+emacsclient --create-frame --tty # opens a new frame on the current terminal
463463+]]></programlisting>
464464+ </para>
465465+ </section>
466466+467467+ <section>
468468+ <title>Configuring the <varname>EDITOR</varname> variable</title>
469469+ <!--<title><command>emacsclient</command> as the Default Editor</title>-->
470470+471471+ <para>
472472+ If <varname>services.emacs.defaultEditor</varname> is
473473+ <literal>true</literal>, the <varname>EDITOR</varname> variable
474474+ will be set to a wrapper script which launches
475475+ <command>emacsclient</command>.
476476+ </para>
477477+478478+ <para>
479479+ Any setting of <varname>EDITOR</varname> in the shell config
480480+ files will override
481481+ <varname>services.emacs.defaultEditor</varname>.
482482+ To make sure <varname>EDITOR</varname> refers to the Emacs
483483+ wrapper script, remove any existing <varname>EDITOR</varname>
484484+ assignment from <filename>.profile</filename>,
485485+ <filename>.bashrc</filename>, <filename>.zshenv</filename> or
486486+ any other shell config file.
487487+ </para>
488488+489489+ <para>
490490+ If you have formed certain bad habits when editing files,
491491+ these can be corrected with a shell alias to the wrapper
492492+ script:
493493+ <programlisting>alias vi=$EDITOR</programlisting>
494494+ </para>
495495+ </section>
496496+497497+ <section>
498498+ <title>Per-User Enabling of the Service</title>
499499+500500+ <para>
501501+ In general, <command>systemd</command> user services
502502+ are globally enabled by symlinks in
503503+ <filename>/etc/systemd/user</filename>. In the case where
504504+ Emacs daemon is not wanted for all users, it is possible to
505505+ install the service but not globally enable it:
506506+507507+ <programlisting><![CDATA[
508508+services.emacs.enable = false;
509509+services.emacs.install = true;
510510+]]></programlisting>
511511+ </para>
512512+513513+ <para>
514514+ To enable the <command>systemd</command> user service for just
515515+ the currently logged in user, run:
516516+517517+ <programlisting>systemctl --user enable emacs</programlisting>
518518+519519+ This will add the symlink
520520+ <filename>~/.config/systemd/user/emacs.service</filename>.
521521+ </para>
522522+ </section>
523523+</section>
524524+525525+<section>
526526+ <title>Configuring Emacs</title>
527527+528528+ <para>
529529+ The Emacs init file should be changed to load the extension
530530+ packages at startup:
531531+532532+ <example>
533533+ <title>Package initialization in <filename>.emacs</filename></title>
534534+ <programlisting><![CDATA[
535535+(require 'package)
536536+537537+;; optional. makes unpure packages archives unavailable
538538+(setq package-archives nil)
539539+540540+(setq package-enable-at-startup nil)
541541+(package-initialize)
542542+]]></programlisting>
543543+ </example>
544544+ </para>
545545+546546+ <para>
547547+ After the declarative emacs package configuration has been
548548+ tested, previously downloaded packages can be cleaned up by
549549+ removing <filename>~/.emacs.d/elpa</filename> (do make a backup
550550+ first, in case you forgot a package).
551551+ </para>
552552+553553+ <!--
554554+ todo: is it worth documenting customizations for
555555+ server-switch-hook, server-done-hook?
556556+ -->
557557+558558+ <section>
559559+ <title>A Major Mode for Nix Expressions</title>
560560+561561+ <para>
562562+ Of interest may be <varname>melpaPackages.nix-mode</varname>,
563563+ which provides syntax highlighting for the Nix language. This is
564564+ particularly convenient if you regularly edit Nix files.
565565+ </para>
566566+ </section>
567567+568568+ <section>
569569+ <title>Accessing man pages</title>
570570+ <para>
571571+ You can use <function>woman</function> to get completion of all
572572+ available man pages. For example, type <literal>M-x woman
573573+ <RET> nixos-rebuild <RET>.</literal>
574574+ </para>
575575+ </section>
576576+</section>
577577+578578+</chapter>
+3-9
nixos/modules/services/misc/nixos-manual.nix
···11111212 cfg = config.services.nixosManual;
13131414- versionModule =
1515- { system.nixosVersionSuffix = config.system.nixosVersionSuffix;
1616- system.nixosRevision = config.system.nixosRevision;
1717- nixpkgs.system = config.nixpkgs.system;
1818- };
1919-2014 /* For the purpose of generating docs, evaluate options with each derivation
2115 in `pkgs` (recursively) replaced by a fake with path "\${pkgs.attribute.path}".
2216 It isn't perfect, but it seems to cover a vast majority of use cases.
···2418 the path above will be shown and not e.g. `${config.services.foo.package}`. */
2519 manual = import ../../../doc/manual {
2620 inherit pkgs;
2727- version = config.system.nixosVersion;
2828- revision = config.system.nixosRevision;
2121+ version = config.system.nixosRelease;
2222+ revision = "release-${config.system.nixosRelease}";
2923 options =
3024 let
3125 scrubbedEval = evalModules {
3232- modules = [ versionModule ] ++ baseModules;
2626+ modules = [ { nixpkgs.system = config.nixpkgs.system; } ] ++ baseModules;
3327 args = (config._module.args) // { modules = [ ]; };
3428 specialArgs = { pkgs = scrubDerivations "pkgs" pkgs; };
3529 };
···5555 ''; };
5656 localAddress = mkOption {
5757 default = "127.0.0.1";
5858- type = types.string;
5858+ type = types.str;
5959 description = ''
6060 Listen for DNS queries to relay on this address. The only reason to
6161 change this from its default value is to proxy queries on behalf
···7474 };
7575 resolverName = mkOption {
7676 default = "dnscrypt.eu-nl";
7777- type = types.nullOr types.string;
7777+ type = types.nullOr types.str;
7878 description = ''
7979 The name of the upstream DNSCrypt resolver to use, taken from the
8080 list named in the <literal>resolverList</literal> option.
···9090 example = literalExample "${pkgs.dnscrypt-proxy}/share/dnscrypt-proxy/dnscrypt-resolvers.csv";
9191 default = pkgs.fetchurl {
9292 url = https://raw.githubusercontent.com/jedisct1/dnscrypt-proxy/master/dnscrypt-resolvers.csv;
9393- sha256 = "171zvdqcqqvcw3zr7wl9h1wmdmk6m3h55xr4gq2z1j7a0x0ba2in";
9393+ sha256 = "1i9wzw4zl052h5nyp28bwl8d66cgj0awvjhw5wgwz0warkjl1g8g";
9494 };
9595 defaultText = "pkgs.fetchurl { url = ...; sha256 = ...; }";
9696 };
···11+# This file defines the options that can be used both for the Apache
22+# main server configuration, and for the virtual hosts. (The latter
33+# has additional options that affect the web server as a whole, like
44+# the user/group to run under.)
55+66+{ lib }:
77+88+with lib;
99+1010+{
1111+ options = {
1212+ proxyPass = mkOption {
1313+ type = types.nullOr types.str;
1414+ default = null;
1515+ example = "http://www.example.org/";
1616+ description = ''
1717+ Adds proxy_pass directive and sets default proxy headers Host, X-Real-Ip
1818+ and X-Forwarded-For.
1919+ '';
2020+ };
2121+2222+ root = mkOption {
2323+ type = types.nullOr types.path;
2424+ default = null;
2525+ example = "/your/root/directory";
2626+ description = ''
2727+ Root directory for requests.
2828+ '';
2929+ };
3030+3131+ extraConfig = mkOption {
3232+ type = types.lines;
3333+ default = "";
3434+ description = ''
3535+ These lines go to the end of the location verbatim.
3636+ '';
3737+ };
3838+ };
3939+}
4040+
···11+# This file defines the options that can be used both for the Apache
22+# main server configuration, and for the virtual hosts. (The latter
33+# has additional options that affect the web server as a whole, like
44+# the user/group to run under.)
55+66+{ lib }:
77+88+with lib;
99+{
1010+ options = {
1111+ serverAliases = mkOption {
1212+ type = types.listOf types.str;
1313+ default = [];
1414+ example = ["www.example.org" "example.org"];
1515+ description = ''
1616+ Additional names of virtual hosts served by this virtual host configuration.
1717+ '';
1818+ };
1919+2020+ port = mkOption {
2121+ type = types.nullOr types.int;
2222+ default = null;
2323+ description = ''
2424+ Port for the server. Defaults to 80 for http
2525+ and 443 for https (i.e. when enableSSL is set).
2626+ '';
2727+ };
2828+2929+ enableACME = mkOption {
3030+ type = types.bool;
3131+ default = false;
3232+ description = "Whether to ask Let's Encrypt to sign a certificate for this vhost.";
3333+ };
3434+3535+ acmeRoot = mkOption {
3636+ type = types.str;
3737+ default = "/var/lib/acme/acme-challenge";
3838+ description = "Directory to store certificates and keys managed by the ACME service.";
3939+ };
4040+4141+ acmeFallbackHost = mkOption {
4242+ type = types.str;
4343+ default = "0.0.0.0";
4444+ description = ''
4545+ Host which to proxy requests to if acme challenge is not found. Useful
4646+ if you want multiple hosts to be able to verify the same domain name.
4747+ '';
4848+ };
4949+5050+ enableSSL = mkOption {
5151+ type = types.bool;
5252+ default = false;
5353+ description = "Whether to enable SSL (https) support.";
5454+ };
5555+5656+ forceSSL = mkOption {
5757+ type = types.bool;
5858+ default = false;
5959+ description = "Whether to always redirect to https.";
6060+ };
6161+6262+ sslCertificate = mkOption {
6363+ type = types.path;
6464+ example = "/var/host.cert";
6565+ description = "Path to server SSL certificate.";
6666+ };
6767+6868+ sslCertificateKey = mkOption {
6969+ type = types.path;
7070+ example = "/var/host.key";
7171+ description = "Path to server SSL certificate key.";
7272+ };
7373+7474+ root = mkOption {
7575+ type = types.nullOr types.path;
7676+ default = null;
7777+ example = "/data/webserver/docs";
7878+ description = ''
7979+ The path of the web root directory.
8080+ '';
8181+ };
8282+8383+ default = mkOption {
8484+ type = types.bool;
8585+ default = false;
8686+ description = ''
8787+ Makes this vhost the default.
8888+ '';
8989+ };
9090+9191+ extraConfig = mkOption {
9292+ type = types.lines;
9393+ default = "";
9494+ description = ''
9595+ These lines go to the end of the vhost verbatim.
9696+ '';
9797+ };
9898+9999+ globalRedirect = mkOption {
100100+ type = types.nullOr types.str;
101101+ default = null;
102102+ example = http://newserver.example.org/;
103103+ description = ''
104104+ If set, all requests for this host are redirected permanently to
105105+ the given URL.
106106+ '';
107107+ };
108108+109109+ basicAuth = mkOption {
110110+ type = types.attrsOf types.str;
111111+ default = {};
112112+ example = literalExample ''
113113+ {
114114+ user = "password";
115115+ };
116116+ '';
117117+ description = ''
118118+ Basic Auth protection for a vhost.
119119+120120+ WARNING: This is implemented to store the password in plain text in the
121121+ nix store.
122122+ '';
123123+ };
124124+125125+ locations = mkOption {
126126+ type = types.attrsOf (types.submodule (import ./location-options.nix {
127127+ inherit lib;
128128+ }));
129129+ default = {};
130130+ example = literalExample ''
131131+ {
132132+ "/" = {
133133+ proxyPass = "http://localhost:3000";
134134+ };
135135+ };
136136+ '';
137137+ description = "Declarative location config";
138138+ };
139139+ };
140140+}
+280-179
nixos/modules/virtualisation/containers.nix
···6677 # The container's init script, a small wrapper around the regular
88 # NixOS stage-2 init script.
99- containerInit = pkgs.writeScript "container-init"
99+ containerInit = (cfg:
1010+ let
1111+ renderExtraVeth = (name: cfg:
1212+ ''
1313+ echo "Bringing ${name} up"
1414+ ip link set dev ${name} up
1515+ ${optionalString (cfg . "localAddress" or null != null) ''
1616+ echo "Setting ip for ${name}"
1717+ ip addr add ${cfg . "localAddress"} dev ${name}
1818+ ''}
1919+ ${optionalString (cfg . "localAddress6" or null != null) ''
2020+ echo "Setting ip6 for ${name}"
2121+ ip -6 addr add ${cfg . "localAddress6"} dev ${name}
2222+ ''}
2323+ ${optionalString (cfg . "hostAddress" or null != null) ''
2424+ echo "Setting route to host for ${name}"
2525+ ip route add ${cfg . "hostAddress"} dev ${name}
2626+ ''}
2727+ ${optionalString (cfg . "hostAddress6" or null != null) ''
2828+ echo "Setting route6 to host for ${name}"
2929+ ip -6 route add ${cfg . "hostAddress6"} dev ${name}
3030+ ''}
3131+ ''
3232+ );
3333+ in
3434+ pkgs.writeScript "container-init"
3535+ ''
3636+ #! ${pkgs.stdenv.shell} -e
3737+3838+ # Initialise the container side of the veth pair.
3939+ if [ "$PRIVATE_NETWORK" = 1 ]; then
4040+4141+ ip link set host0 name eth0
4242+ ip link set dev eth0 up
4343+4444+ if [ -n "$LOCAL_ADDRESS" ]; then
4545+ ip addr add $LOCAL_ADDRESS dev eth0
4646+ fi
4747+ if [ -n "$LOCAL_ADDRESS6" ]; then
4848+ ip -6 addr add $LOCAL_ADDRESS6 dev eth0
4949+ fi
5050+ if [ -n "$HOST_ADDRESS" ]; then
5151+ ip route add $HOST_ADDRESS dev eth0
5252+ ip route add default via $HOST_ADDRESS
5353+ fi
5454+ if [ -n "$HOST_ADDRESS6" ]; then
5555+ ip -6 route add $HOST_ADDRESS6 dev eth0
5656+ ip -6 route add default via $HOST_ADDRESS6
5757+ fi
5858+5959+ ${concatStringsSep "\n" (mapAttrsToList renderExtraVeth cfg . "extraVeths" or {})}
6060+ ip a
6161+ ip r
6262+ fi
6363+6464+ # Start the regular stage 1 script.
6565+ exec "$1"
6666+ ''
6767+ );
6868+6969+ nspawnExtraVethArgs = (name: cfg: "--network-veth-extra=${name}");
7070+ startScript = (cfg:
1071 ''
1111- #! ${pkgs.stdenv.shell} -e
7272+ mkdir -p -m 0755 "$root/etc" "$root/var/lib"
7373+ mkdir -p -m 0700 "$root/var/lib/private" "$root/root" /run/containers
7474+ if ! [ -e "$root/etc/os-release" ]; then
7575+ touch "$root/etc/os-release"
7676+ fi
7777+7878+ if ! [ -e "$root/etc/machine-id" ]; then
7979+ touch "$root/etc/machine-id"
8080+ fi
8181+8282+ mkdir -p -m 0755 \
8383+ "/nix/var/nix/profiles/per-container/$INSTANCE" \
8484+ "/nix/var/nix/gcroots/per-container/$INSTANCE"
8585+8686+ cp --remove-destination /etc/resolv.conf "$root/etc/resolv.conf"
12871313- # Initialise the container side of the veth pair.
1488 if [ "$PRIVATE_NETWORK" = 1 ]; then
8989+ extraFlags+=" --network-veth"
9090+ if [ -n "$HOST_BRIDGE" ]; then
9191+ extraFlags+=" --network-bridge=$HOST_BRIDGE"
9292+ fi
9393+ fi
15941616- ip link set host0 name eth0
1717- ip link set dev eth0 up
9595+ ${if cfg . "extraVeths" or null != null then
9696+ ''extraFlags+=" ${concatStringsSep " " (mapAttrsToList nspawnExtraVethArgs cfg . "extraVeths" or {})}"''
9797+ else
9898+ ''# No extra veth pairs to create''
9999+ }
181001919- if [ -n "$LOCAL_ADDRESS" ]; then
2020- ip addr add $LOCAL_ADDRESS dev eth0
2121- fi
2222- if [ -n "$LOCAL_ADDRESS6" ]; then
2323- ip -6 addr add $LOCAL_ADDRESS6 dev eth0
2424- fi
2525- if [ -n "$HOST_ADDRESS" ]; then
2626- ip route add $HOST_ADDRESS dev eth0
2727- ip route add default via $HOST_ADDRESS
2828- fi
2929- if [ -n "$HOST_ADDRESS6" ]; then
3030- ip -6 route add $HOST_ADDRESS6 dev eth0
3131- ip -6 route add default via $HOST_ADDRESS6
101101+ for iface in $INTERFACES; do
102102+ extraFlags+=" --network-interface=$iface"
103103+ done
104104+105105+ for iface in $MACVLANS; do
106106+ extraFlags+=" --network-macvlan=$iface"
107107+ done
108108+109109+ # If the host is 64-bit and the container is 32-bit, add a
110110+ # --personality flag.
111111+ ${optionalString (config.nixpkgs.system == "x86_64-linux") ''
112112+ if [ "$(< ''${SYSTEM_PATH:-/nix/var/nix/profiles/per-container/$INSTANCE/system}/system)" = i686-linux ]; then
113113+ extraFlags+=" --personality=x86"
32114 fi
115115+ ''}
116116+117117+ # Run systemd-nspawn without startup notification (we'll
118118+ # wait for the container systemd to signal readiness).
119119+ EXIT_ON_REBOOT=1 \
120120+ exec ${config.systemd.package}/bin/systemd-nspawn \
121121+ --keep-unit \
122122+ -M "$INSTANCE" -D "$root" $extraFlags \
123123+ $EXTRA_NSPAWN_FLAGS \
124124+ --notify-ready=yes \
125125+ --bind-ro=/nix/store \
126126+ --bind-ro=/nix/var/nix/db \
127127+ --bind-ro=/nix/var/nix/daemon-socket \
128128+ --bind="/nix/var/nix/profiles/per-container/$INSTANCE:/nix/var/nix/profiles" \
129129+ --bind="/nix/var/nix/gcroots/per-container/$INSTANCE:/nix/var/nix/gcroots" \
130130+ --setenv PRIVATE_NETWORK="$PRIVATE_NETWORK" \
131131+ --setenv HOST_BRIDGE="$HOST_BRIDGE" \
132132+ --setenv HOST_ADDRESS="$HOST_ADDRESS" \
133133+ --setenv LOCAL_ADDRESS="$LOCAL_ADDRESS" \
134134+ --setenv HOST_ADDRESS6="$HOST_ADDRESS6" \
135135+ --setenv LOCAL_ADDRESS6="$LOCAL_ADDRESS6" \
136136+ --setenv PATH="$PATH" \
137137+ ${containerInit cfg} "''${SYSTEM_PATH:-/nix/var/nix/profiles/system}/init"
138138+ ''
139139+ );
140140+141141+ preStartScript = (cfg:
142142+ ''
143143+ # Clean up existing machined registration and interfaces.
144144+ machinectl terminate "$INSTANCE" 2> /dev/null || true
145145+146146+ if [ "$PRIVATE_NETWORK" = 1 ]; then
147147+ ip link del dev "ve-$INSTANCE" 2> /dev/null || true
148148+ ip link del dev "vb-$INSTANCE" 2> /dev/null || true
33149 fi
341503535- # Start the regular stage 1 script.
3636- exec "$1"
3737- '';
151151+ ${concatStringsSep "\n" (
152152+ mapAttrsToList (name: cfg:
153153+ ''ip link del dev ${name} 2> /dev/null || true ''
154154+ ) cfg . "extraVeths" or {}
155155+ )}
156156+ ''
157157+ );
158158+ postStartScript = (cfg:
159159+ let
160160+ ipcall = (cfg: ipcmd: variable: attribute:
161161+ if cfg . attribute or null == null then
162162+ ''
163163+ if [ -n "${variable}" ]; then
164164+ ${ipcmd} add ${variable} dev $ifaceHost
165165+ fi
166166+ ''
167167+ else
168168+ ''${ipcmd} add ${cfg . attribute} dev $ifaceHost''
169169+ );
170170+ renderExtraVeth = (name: cfg:
171171+ if cfg . "hostBridge" or null != null then
172172+ ''
173173+ # Add ${name} to bridge ${cfg.hostBridge}
174174+ ip link set dev ${name} master ${cfg.hostBridge} up
175175+ ''
176176+ else
177177+ ''
178178+ # Set IPs and routes for ${name}
179179+ ${optionalString (cfg . "hostAddress" or null != null) ''
180180+ ip addr add ${cfg . "hostAddress"} dev ${name}
181181+ ''}
182182+ ${optionalString (cfg . "hostAddress6" or null != null) ''
183183+ ip -6 addr add ${cfg . "hostAddress6"} dev ${name}
184184+ ''}
185185+ ${optionalString (cfg . "localAddress" or null != null) ''
186186+ ip route add ${cfg . "localAddress"} dev ${name}
187187+ ''}
188188+ ${optionalString (cfg . "localAddress6" or null != null) ''
189189+ ip -6 route add ${cfg . "localAddress6"} dev ${name}
190190+ ''}
191191+ ''
192192+ );
193193+ in
194194+ ''
195195+ if [ "$PRIVATE_NETWORK" = 1 ]; then
196196+ if [ -z "$HOST_BRIDGE" ]; then
197197+ ifaceHost=ve-$INSTANCE
198198+ ip link set dev $ifaceHost up
199199+200200+ ${ipcall cfg "ip addr" "$HOST_ADDRESS" "hostAddress"}
201201+ ${ipcall cfg "ip -6 addr" "$HOST_ADDRESS6" "hostAddress6"}
202202+ ${ipcall cfg "ip route" "$LOCAL_ADDRESS" "localAddress"}
203203+ ${ipcall cfg "ip -6 route" "$LOCAL_ADDRESS6" "localAddress6"}
204204+ fi
205205+ ${concatStringsSep "\n" (mapAttrsToList renderExtraVeth cfg . "extraVeths" or {})}
206206+ fi
207207+208208+ # Get the leader PID so that we can signal it in
209209+ # preStop. We can't use machinectl there because D-Bus
210210+ # might be shutting down. FIXME: in systemd 219 we can
211211+ # just signal systemd-nspawn to do a clean shutdown.
212212+ machinectl show "$INSTANCE" | sed 's/Leader=\(.*\)/\1/;t;d' > "/run/containers/$INSTANCE.pid"
213213+ ''
214214+ );
3821539216 system = config.nixpkgs.system;
40217···7325074251 mkBindFlags = bs: concatMapStrings mkBindFlag (lib.attrValues bs);
75252253253+ networkOptions = {
254254+ hostBridge = mkOption {
255255+ type = types.nullOr types.string;
256256+ default = null;
257257+ example = "br0";
258258+ description = ''
259259+ Put the host-side of the veth-pair into the named bridge.
260260+ Only one of hostAddress* or hostBridge can be given.
261261+ '';
262262+ };
263263+264264+ hostAddress = mkOption {
265265+ type = types.nullOr types.str;
266266+ default = null;
267267+ example = "10.231.136.1";
268268+ description = ''
269269+ The IPv4 address assigned to the host interface.
270270+ (Not used when hostBridge is set.)
271271+ '';
272272+ };
273273+274274+ hostAddress6 = mkOption {
275275+ type = types.nullOr types.string;
276276+ default = null;
277277+ example = "fc00::1";
278278+ description = ''
279279+ The IPv6 address assigned to the host interface.
280280+ (Not used when hostBridge is set.)
281281+ '';
282282+ };
283283+284284+ localAddress = mkOption {
285285+ type = types.nullOr types.str;
286286+ default = null;
287287+ example = "10.231.136.2";
288288+ description = ''
289289+ The IPv4 address assigned to the interface in the container.
290290+ If a hostBridge is used, this should be given with netmask to access
291291+ the whole network. Otherwise the default netmask is /32 and routing is
292292+ set up from localAddress to hostAddress and back.
293293+ '';
294294+ };
295295+296296+ localAddress6 = mkOption {
297297+ type = types.nullOr types.string;
298298+ default = null;
299299+ example = "fc00::2";
300300+ description = ''
301301+ The IPv6 address assigned to the interface in the container.
302302+ If a hostBridge is used, this should be given with netmask to access
303303+ the whole network. Otherwise the default netmask is /128 and routing is
304304+ set up from localAddress6 to hostAddress6 and back.
305305+ '';
306306+ };
307307+308308+ };
309309+76310in
7731178312{
···133367 '';
134368 };
135369136136- hostBridge = mkOption {
137137- type = types.nullOr types.string;
138138- default = null;
139139- example = "br0";
140140- description = ''
141141- Put the host-side of the veth-pair into the named bridge.
142142- Only one of hostAddress* or hostBridge can be given.
143143- '';
144144- };
145145-146146- hostAddress = mkOption {
147147- type = types.nullOr types.str;
148148- default = null;
149149- example = "10.231.136.1";
150150- description = ''
151151- The IPv4 address assigned to the host interface.
152152- (Not used when hostBridge is set.)
153153- '';
154154- };
155155-156156- hostAddress6 = mkOption {
157157- type = types.nullOr types.string;
158158- default = null;
159159- example = "fc00::1";
160160- description = ''
161161- The IPv6 address assigned to the host interface.
162162- (Not used when hostBridge is set.)
163163- '';
164164- };
165165-166166- localAddress = mkOption {
167167- type = types.nullOr types.str;
168168- default = null;
169169- example = "10.231.136.2";
170170- description = ''
171171- The IPv4 address assigned to <literal>eth0</literal>
172172- in the container.
173173- '';
174174- };
175175-176176- localAddress6 = mkOption {
177177- type = types.nullOr types.string;
178178- default = null;
179179- example = "fc00::2";
180180- description = ''
181181- The IPv6 address assigned to <literal>eth0</literal>
182182- in the container.
183183- '';
184184- };
185185-186370 interfaces = mkOption {
187371 type = types.listOf types.string;
188372 default = [];
189373 example = [ "eth1" "eth2" ];
190374 description = ''
191375 The list of interfaces to be moved into the container.
376376+ '';
377377+ };
378378+379379+ extraVeths = mkOption {
380380+ type = types.attrsOf types.optionSet;
381381+ default = {};
382382+ options = networkOptions;
383383+ description = ''
384384+ Extra veth-pairs to be created for the container
192385 '';
193386 };
194387···214407 '';
215408 };
216409217217- };
410410+ } // networkOptions;
218411219412 config = mkMerge
220413 [ (mkIf options.config.isDefined {
···272465 environment.INSTANCE = "%i";
273466 environment.root = "/var/lib/containers/%i";
274467275275- preStart =
276276- ''
277277- # Clean up existing machined registration and interfaces.
278278- machinectl terminate "$INSTANCE" 2> /dev/null || true
468468+ preStart = preStartScript {};
279469280280- if [ "$PRIVATE_NETWORK" = 1 ]; then
281281- ip link del dev "ve-$INSTANCE" 2> /dev/null || true
282282- ip link del dev "vb-$INSTANCE" 2> /dev/null || true
283283- fi
284284- '';
470470+ script = startScript {};
285471286286- script =
287287- ''
288288- mkdir -p -m 0755 "$root/etc" "$root/var/lib"
289289- mkdir -p -m 0700 "$root/var/lib/private" "$root/root" /run/containers
290290- if ! [ -e "$root/etc/os-release" ]; then
291291- touch "$root/etc/os-release"
292292- fi
293293-294294- if ! [ -e "$root/etc/machine-id" ]; then
295295- touch "$root/etc/machine-id"
296296- fi
297297-298298- mkdir -p -m 0755 \
299299- "/nix/var/nix/profiles/per-container/$INSTANCE" \
300300- "/nix/var/nix/gcroots/per-container/$INSTANCE"
301301-302302- cp --remove-destination /etc/resolv.conf "$root/etc/resolv.conf"
303303-304304- if [ "$PRIVATE_NETWORK" = 1 ]; then
305305- extraFlags+=" --network-veth"
306306- if [ -n "$HOST_BRIDGE" ]; then
307307- extraFlags+=" --network-bridge=$HOST_BRIDGE"
308308- fi
309309- fi
310310-311311- for iface in $INTERFACES; do
312312- extraFlags+=" --network-interface=$iface"
313313- done
314314-315315- for iface in $MACVLANS; do
316316- extraFlags+=" --network-macvlan=$iface"
317317- done
318318-319319- # If the host is 64-bit and the container is 32-bit, add a
320320- # --personality flag.
321321- ${optionalString (config.nixpkgs.system == "x86_64-linux") ''
322322- if [ "$(< ''${SYSTEM_PATH:-/nix/var/nix/profiles/per-container/$INSTANCE/system}/system)" = i686-linux ]; then
323323- extraFlags+=" --personality=x86"
324324- fi
325325- ''}
326326-327327- # Run systemd-nspawn without startup notification (we'll
328328- # wait for the container systemd to signal readiness).
329329- EXIT_ON_REBOOT=1 \
330330- exec ${config.systemd.package}/bin/systemd-nspawn \
331331- --keep-unit \
332332- -M "$INSTANCE" -D "$root" $extraFlags \
333333- $EXTRA_NSPAWN_FLAGS \
334334- --notify-ready=yes \
335335- --bind-ro=/nix/store \
336336- --bind-ro=/nix/var/nix/db \
337337- --bind-ro=/nix/var/nix/daemon-socket \
338338- --bind="/nix/var/nix/profiles/per-container/$INSTANCE:/nix/var/nix/profiles" \
339339- --bind="/nix/var/nix/gcroots/per-container/$INSTANCE:/nix/var/nix/gcroots" \
340340- --setenv PRIVATE_NETWORK="$PRIVATE_NETWORK" \
341341- --setenv HOST_BRIDGE="$HOST_BRIDGE" \
342342- --setenv HOST_ADDRESS="$HOST_ADDRESS" \
343343- --setenv LOCAL_ADDRESS="$LOCAL_ADDRESS" \
344344- --setenv HOST_ADDRESS6="$HOST_ADDRESS6" \
345345- --setenv LOCAL_ADDRESS6="$LOCAL_ADDRESS6" \
346346- --setenv PATH="$PATH" \
347347- ${containerInit} "''${SYSTEM_PATH:-/nix/var/nix/profiles/system}/init"
348348- '';
349349-350350- postStart =
351351- ''
352352- if [ "$PRIVATE_NETWORK" = 1 ]; then
353353- if [ -z "$HOST_BRIDGE" ]; then
354354- ifaceHost=ve-$INSTANCE
355355- ip link set dev $ifaceHost up
356356- if [ -n "$HOST_ADDRESS" ]; then
357357- ip addr add $HOST_ADDRESS dev $ifaceHost
358358- fi
359359- if [ -n "$HOST_ADDRESS6" ]; then
360360- ip -6 addr add $HOST_ADDRESS6 dev $ifaceHost
361361- fi
362362- if [ -n "$LOCAL_ADDRESS" ]; then
363363- ip route add $LOCAL_ADDRESS dev $ifaceHost
364364- fi
365365- if [ -n "$LOCAL_ADDRESS6" ]; then
366366- ip -6 route add $LOCAL_ADDRESS6 dev $ifaceHost
367367- fi
368368- fi
369369- fi
370370-371371- # Get the leader PID so that we can signal it in
372372- # preStop. We can't use machinectl there because D-Bus
373373- # might be shutting down. FIXME: in systemd 219 we can
374374- # just signal systemd-nspawn to do a clean shutdown.
375375- machinectl show "$INSTANCE" | sed 's/Leader=\(.*\)/\1/;t;d' > "/run/containers/$INSTANCE.pid"
376376- '';
472472+ postStart = postStartScript {};
377473378474 preStop =
379475 ''
···425521 [{ name = "container@"; value = unit; }]
426522 # declarative containers
427523 ++ (mapAttrsToList (name: cfg: nameValuePair "container@${name}" (
524524+ unit // {
525525+ preStart = preStartScript cfg;
526526+ script = startScript cfg;
527527+ postStart = postStartScript cfg;
528528+ } // (
428529 if cfg.autoStart then
429429- unit // {
530530+ {
430531 wantedBy = [ "multi-user.target" ];
431532 wants = [ "network.target" ];
432533 after = [ "network.target" ];
433534 restartTriggers = [ cfg.path ];
434535 reloadIfChanged = true;
435536 }
436436- else null
537537+ else {})
437538 )) config.containers)
438539 ));
439540···462563 LOCAL_ADDRESS6=${cfg.localAddress6}
463564 ''}
464565 ''}
465465- INTERFACES="${toString cfg.interfaces}"
466466- ${optionalString cfg.autoStart ''
467467- AUTO_START=1
468468- ''}
469469- EXTRA_NSPAWN_FLAGS="${mkBindFlags cfg.bindMounts}"
566566+ INTERFACES="${toString cfg.interfaces}"
567567+ ${optionalString cfg.autoStart ''
568568+ AUTO_START=1
569569+ ''}
570570+ EXTRA_NSPAWN_FLAGS="${mkBindFlags cfg.bindMounts}"
470571 '';
471572 }) config.containers;
472573
···76767777 # For some reason librdf_redland sometimes refers to rasqal.h instead
7878 # of rasqal/rasqal.h
7979- NIX_CFLAGS_COMPILE="-I${librdf_rasqal}/include/rasqal";
7979+ # curl upgrade to 7.50.0 (#17152) changes the libcurl headers slightly and
8080+ # therefore requires the -fpermissive flag until this package gets updated
8181+ NIX_CFLAGS_COMPILE="-I${librdf_rasqal}/include/rasqal -fpermissive";
80828183 # If we call 'configure', 'make' will then call configure again without parameters.
8284 # It's their system.
+3-1
pkgs/applications/office/libreoffice/still.nix
···76767777 # For some reason librdf_redland sometimes refers to rasqal.h instead
7878 # of rasqal/rasqal.h
7979- NIX_CFLAGS_COMPILE="-I${librdf_rasqal}/include/rasqal";
7979+ # curl upgrade to 7.50.0 (#17152) changes the libcurl headers slightly and
8080+ # therefore requires the -fpermissive flag until this package gets updated
8181+ NIX_CFLAGS_COMPILE="-I${librdf_rasqal}/include/rasqal -fpermissive";
80828183 # If we call 'configure', 'make' will then call configure again without parameters.
8284 # It's their system.
···11+diff --git a/packages/net/_test.pony b/packages/net/_test.pony
22+index d6c3e56..dc37dd9 100644
33+--- a/packages/net/_test.pony
44++++ b/packages/net/_test.pony
55+@@ -7,11 +7,6 @@ actor Main is TestList
66+ fun tag tests(test: PonyTest) =>
77+ test(_TestReadBuffer)
88+ test(_TestWriteBuffer)
99+- test(_TestBroadcast)
1010+- ifdef not windows then
1111+- test(_TestTCPExpect)
1212+- test(_TestTCPWritev)
1313+- end
1414+1515+ class iso _TestReadBuffer is UnitTest
1616+ """