···1212<itemizedlist>
13131414 <listitem>
1515- <para>You can now pin a specific version of NixOS in your <filename>configuration.nix</filename>
1616- by setting:
1717-1818-<programlisting>
1919-nixos.path = ./nixpkgs-unstable-2015-12-06/nixos;
2020-</programlisting>
2121-2222- This will make NixOS re-evaluate your configuration with the modules of
2323- the specified NixOS version at the given path. For more details, see
2424- <xref linkend="module-misc-nixos" /></para>
2525- </listitem>
2626-2727- <listitem>
2815 <para>Firefox and similar browsers are now <emphasis>wrapped by default</emphasis>.
2916 The package and attribute names are plain <literal>firefox</literal>
3017 or <literal>midori</literal>, etc. Backward-compatibility attributes were set up,
-82
nixos/modules/misc/nixos.nix
···11-{ config, options, lib, ... }:
22-33-# This modules is used to inject a different NixOS version as well as its
44-# argument such that one can pin a specific version with the versionning
55-# system of the configuration.
66-let
77- nixosReentry = import config.nixos.path {
88- inherit (config.nixos) configuration extraModules;
99- inherit (config.nixpkgs) system;
1010- reEnter = true;
1111- };
1212-in
1313-1414-with lib;
1515-1616-{
1717- options = {
1818- nixos.path = mkOption {
1919- default = null;
2020- example = literalExample "./nixpkgs-15.09/nixos";
2121- type = types.nullOr types.path;
2222- description = ''
2323- This option give the ability to evaluate the current set of modules
2424- with a different version of NixOS. This option can be used version
2525- the version of NixOS with the configuration without relying on the
2626- <literal>NIX_PATH</literal> environment variable.
2727- '';
2828- };
2929-3030- nixos.system = mkOption {
3131- example = "i686-linux";
3232- type = types.uniq types.str;
3333- description = ''
3434- Name of the system used to compile NixOS.
3535- '';
3636- };
3737-3838- nixos.extraModules = mkOption {
3939- default = [];
4040- example = literalExample "[ ./sshd-config.nix ]";
4141- type = types.listOf (types.either (types.submodule ({...}:{options={};})) types.path);
4242- description = ''
4343- Define additional modules which would be loaded to evaluate the
4444- configuration.
4545- '';
4646- };
4747-4848- nixos.configuration = mkOption {
4949- type = types.unspecified;
5050- internal = true;
5151- description = ''
5252- Option used by <filename>nixos/default.nix</filename> to re-inject
5353- the same configuration module as the one used for the current
5454- execution.
5555- '';
5656- };
5757-5858- nixos.reflect = mkOption {
5959- default = { inherit config options; };
6060- type = types.unspecified;
6161- internal = true;
6262- description = ''
6363- Provides <literal>config</literal> and <literal>options</literal>
6464- computed by the module system and given as argument to all
6565- modules. These are used for introspection of options and
6666- configuration by tools such as <literal>nixos-option</literal>.
6767- '';
6868- };
6969- };
7070-7171- config = mkMerge [
7272- (mkIf (config.nixos.path != null) (mkForce {
7373- system.build.toplevel = nixosReentry.system;
7474- system.build.vm = nixosReentry.vm;
7575- nixos.reflect = { inherit (nixosReentry) config options; };
7676- }))
7777-7878- { meta.maintainers = singleton lib.maintainers.pierron;
7979- meta.doc = ./nixos.xml;
8080- }
8181- ];
8282-}
-84
nixos/modules/misc/nixos.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-misc-nixos">
66-77-<title>NixOS Reentry</title>
88-99-<!-- FIXME: render nicely -->
1010-1111-<!-- FIXME: source can be added automatically -->
1212-<para><emphasis>Source:</emphasis> <filename>modules/misc/nixos.nix</filename></para>
1313-1414-<!-- FIXME: more stuff, like maintainer? -->
1515-1616-<para>NixOS reentry can be used for both pinning the evaluation to a
1717-specific version of NixOS, and to dynamically add additional modules into
1818-the Module evaluation.</para>
1919-2020-<section><title>NixOS Version Pinning</title>
2121-2222-<para>To pin a specific version of NixOS, you need a version that you can
2323-either clone localy, or that you can fetch remotely.</para>
2424-2525-<para>If you already have a cloned version of NixOS in the directory
2626-<filename>/etc/nixos/nixpkgs-16-03</filename>, then you can specify the
2727-<option>nixos.path</option> with either the path or the relative path of
2828-your NixOS clone. For example, you can add the following to your
2929-<filename>/etc/nixos/configuration.nix</filename> file:
3030-3131-<programlisting>
3232-nixos.path = ./nixpkgs-16-03/nixos;
3333-</programlisting>
3434-</para>
3535-3636-<para>Another option is to fetch a specific version of NixOS, with either
3737-the <literal>fetchTarball</literal> builtin, or the
3838-<literal>pkgs.fetchFromGitHub</literal> function and use the result as an
3939-input.
4040-4141-<programlisting>
4242-nixos.path = "${builtins.fetchTarball https://github.com/NixOS/nixpkgs/archive/1f27976e03c15183191d1b4aa1a40d1f14666cd2.tar.gz}/nixos";
4343-</programlisting>
4444-</para>
4545-4646-</section>
4747-4848-4949-<section><title>Adding Module Dynamically</title>
5050-5151-<para>To add additional module, the recommended way is to use statically
5252-known modules in the list of imported arguments as described in <xref
5353-linkend="sec-modularity" />. Unfortunately, this recommended method has
5454-limitation, such that the list of imported files cannot be selected based on
5555-the content of the configuration.
5656-5757-Fortunately, NixOS reentry system can be used as an alternative to register
5858-new imported modules based on the content of the configuration. To do so,
5959-one should define both <option>nixos.path</option> and
6060-<option>nixos.extraModules</option> options.
6161-6262-<programlisting>
6363-nixos.path = <nixos>;
6464-nixos.extraModules =
6565- if config.networking.hostName == "server" then
6666- [ ./server.nix ] else [ ./client.nix ];
6767-</programlisting>
6868-6969-Also note, that the above can be reimplemented in a different way which is
7070-not as expensive, by using <literal>mkIf</literal> at the top each
7171-configuration if both modules are present on the file system (see <xref
7272-linkend="sec-option-definitions" />) and by always inmporting both
7373-modules.</para>
7474-7575-</section>
7676-7777-<section><title>Options</title>
7878-7979-<para>FIXME: auto-generated list of module options.</para>
8080-8181-</section>
8282-8383-8484-</chapter>