···12<itemizedlist>
1314 <listitem>
15- <para>You can now pin a specific version of NixOS in your <filename>configuration.nix</filename>
16- by setting:
17-18-<programlisting>
19-nixos.path = ./nixpkgs-unstable-2015-12-06/nixos;
20-</programlisting>
21-22- This will make NixOS re-evaluate your configuration with the modules of
23- the specified NixOS version at the given path. For more details, see
24- <xref linkend="module-misc-nixos" /></para>
25- </listitem>
26-27- <listitem>
28 <para>Firefox and similar browsers are now <emphasis>wrapped by default</emphasis>.
29 The package and attribute names are plain <literal>firefox</literal>
30 or <literal>midori</literal>, etc. Backward-compatibility attributes were set up,
···12<itemizedlist>
1314 <listitem>
000000000000015 <para>Firefox and similar browsers are now <emphasis>wrapped by default</emphasis>.
16 The package and attribute names are plain <literal>firefox</literal>
17 or <literal>midori</literal>, etc. Backward-compatibility attributes were set up,
-82
nixos/modules/misc/nixos.nix
···1-{ config, options, lib, ... }:
2-3-# This modules is used to inject a different NixOS version as well as its
4-# argument such that one can pin a specific version with the versionning
5-# system of the configuration.
6-let
7- nixosReentry = import config.nixos.path {
8- inherit (config.nixos) configuration extraModules;
9- inherit (config.nixpkgs) system;
10- reEnter = true;
11- };
12-in
13-14-with lib;
15-16-{
17- options = {
18- nixos.path = mkOption {
19- default = null;
20- example = literalExample "./nixpkgs-15.09/nixos";
21- type = types.nullOr types.path;
22- description = ''
23- This option give the ability to evaluate the current set of modules
24- with a different version of NixOS. This option can be used version
25- the version of NixOS with the configuration without relying on the
26- <literal>NIX_PATH</literal> environment variable.
27- '';
28- };
29-30- nixos.system = mkOption {
31- example = "i686-linux";
32- type = types.uniq types.str;
33- description = ''
34- Name of the system used to compile NixOS.
35- '';
36- };
37-38- nixos.extraModules = mkOption {
39- default = [];
40- example = literalExample "[ ./sshd-config.nix ]";
41- type = types.listOf (types.either (types.submodule ({...}:{options={};})) types.path);
42- description = ''
43- Define additional modules which would be loaded to evaluate the
44- configuration.
45- '';
46- };
47-48- nixos.configuration = mkOption {
49- type = types.unspecified;
50- internal = true;
51- description = ''
52- Option used by <filename>nixos/default.nix</filename> to re-inject
53- the same configuration module as the one used for the current
54- execution.
55- '';
56- };
57-58- nixos.reflect = mkOption {
59- default = { inherit config options; };
60- type = types.unspecified;
61- internal = true;
62- description = ''
63- Provides <literal>config</literal> and <literal>options</literal>
64- computed by the module system and given as argument to all
65- modules. These are used for introspection of options and
66- configuration by tools such as <literal>nixos-option</literal>.
67- '';
68- };
69- };
70-71- config = mkMerge [
72- (mkIf (config.nixos.path != null) (mkForce {
73- system.build.toplevel = nixosReentry.system;
74- system.build.vm = nixosReentry.vm;
75- nixos.reflect = { inherit (nixosReentry) config options; };
76- }))
77-78- { meta.maintainers = singleton lib.maintainers.pierron;
79- meta.doc = ./nixos.xml;
80- }
81- ];
82-}
···1-<chapter xmlns="http://docbook.org/ns/docbook"
2- xmlns:xlink="http://www.w3.org/1999/xlink"
3- xmlns:xi="http://www.w3.org/2001/XInclude"
4- version="5.0"
5- xml:id="module-misc-nixos">
6-7-<title>NixOS Reentry</title>
8-9-<!-- FIXME: render nicely -->
10-11-<!-- FIXME: source can be added automatically -->
12-<para><emphasis>Source:</emphasis> <filename>modules/misc/nixos.nix</filename></para>
13-14-<!-- FIXME: more stuff, like maintainer? -->
15-16-<para>NixOS reentry can be used for both pinning the evaluation to a
17-specific version of NixOS, and to dynamically add additional modules into
18-the Module evaluation.</para>
19-20-<section><title>NixOS Version Pinning</title>
21-22-<para>To pin a specific version of NixOS, you need a version that you can
23-either clone localy, or that you can fetch remotely.</para>
24-25-<para>If you already have a cloned version of NixOS in the directory
26-<filename>/etc/nixos/nixpkgs-16-03</filename>, then you can specify the
27-<option>nixos.path</option> with either the path or the relative path of
28-your NixOS clone. For example, you can add the following to your
29-<filename>/etc/nixos/configuration.nix</filename> file:
30-31-<programlisting>
32-nixos.path = ./nixpkgs-16-03/nixos;
33-</programlisting>
34-</para>
35-36-<para>Another option is to fetch a specific version of NixOS, with either
37-the <literal>fetchTarball</literal> builtin, or the
38-<literal>pkgs.fetchFromGitHub</literal> function and use the result as an
39-input.
40-41-<programlisting>
42-nixos.path = "${builtins.fetchTarball https://github.com/NixOS/nixpkgs/archive/1f27976e03c15183191d1b4aa1a40d1f14666cd2.tar.gz}/nixos";
43-</programlisting>
44-</para>
45-46-</section>
47-48-49-<section><title>Adding Module Dynamically</title>
50-51-<para>To add additional module, the recommended way is to use statically
52-known modules in the list of imported arguments as described in <xref
53-linkend="sec-modularity" />. Unfortunately, this recommended method has
54-limitation, such that the list of imported files cannot be selected based on
55-the content of the configuration.
56-57-Fortunately, NixOS reentry system can be used as an alternative to register
58-new imported modules based on the content of the configuration. To do so,
59-one should define both <option>nixos.path</option> and
60-<option>nixos.extraModules</option> options.
61-62-<programlisting>
63-nixos.path = <nixos>;
64-nixos.extraModules =
65- if config.networking.hostName == "server" then
66- [ ./server.nix ] else [ ./client.nix ];
67-</programlisting>
68-69-Also note, that the above can be reimplemented in a different way which is
70-not as expensive, by using <literal>mkIf</literal> at the top each
71-configuration if both modules are present on the file system (see <xref
72-linkend="sec-option-definitions" />) and by always inmporting both
73-modules.</para>
74-75-</section>
76-77-<section><title>Options</title>
78-79-<para>FIXME: auto-generated list of module options.</para>
80-81-</section>
82-83-84-</chapter>