about summary refs log tree commit diff
path: root/nixos/modules/misc/nixos.xml
diff options
context:
space:
mode:
authorNicolas B. Pierron <nicolas.b.pierron@gmail.com>2015-11-20 20:11:21 +0000
committerNicolas B. Pierron <nicolas.b.pierron@gmail.com>2015-11-20 20:11:21 +0000
commit4e61fc89d261eb4815186b451e43a5925a4eb2a1 (patch)
tree18a0003e7d917216a91d5f1e544c5f11f029b4de /nixos/modules/misc/nixos.xml
parenteae62caf916bae65c40a69f88a088d540c6c7765 (diff)
parenta5992ad61b314104aff7e28a41ce101a1b0e7c35 (diff)
downloadnixlib-4e61fc89d261eb4815186b451e43a5925a4eb2a1.tar
nixlib-4e61fc89d261eb4815186b451e43a5925a4eb2a1.tar.gz
nixlib-4e61fc89d261eb4815186b451e43a5925a4eb2a1.tar.bz2
nixlib-4e61fc89d261eb4815186b451e43a5925a4eb2a1.tar.lz
nixlib-4e61fc89d261eb4815186b451e43a5925a4eb2a1.tar.xz
nixlib-4e61fc89d261eb4815186b451e43a5925a4eb2a1.tar.zst
nixlib-4e61fc89d261eb4815186b451e43a5925a4eb2a1.zip
Merge pull request #11106 from nbp/nixos-reentry
Add a way to pin a NixOS version within the module system.
Diffstat (limited to 'nixos/modules/misc/nixos.xml')
-rw-r--r--nixos/modules/misc/nixos.xml84
1 files changed, 84 insertions, 0 deletions
diff --git a/nixos/modules/misc/nixos.xml b/nixos/modules/misc/nixos.xml
new file mode 100644
index 000000000000..f8d3b4bc6e33
--- /dev/null
+++ b/nixos/modules/misc/nixos.xml
@@ -0,0 +1,84 @@
+<chapter xmlns="http://docbook.org/ns/docbook"
+         xmlns:xlink="http://www.w3.org/1999/xlink"
+         xmlns:xi="http://www.w3.org/2001/XInclude"
+         version="5.0"
+         xml:id="module-misc-nixos">
+
+<title>NixOS Reentry</title>
+
+<!-- FIXME: render nicely -->
+
+<!-- FIXME: source can be added automatically -->
+<para><emphasis>Source:</emphasis> <filename>modules/misc/nixos.nix</filename></para>
+
+<!-- FIXME: more stuff, like maintainer? -->
+
+<para>NixOS reentry can be used for both pinning the evaluation to a
+specific version of NixOS, and to dynamically add additional modules into
+the Module evaluation.</para>
+
+<section><title>NixOS Version Pinning</title>
+
+<para>To pin a specific version of NixOS, you need a version that you can
+either clone localy, or that you can fetch remotely.</para>
+
+<para>If you already have a cloned version of NixOS in the directory
+<filename>/etc/nixos/nixpkgs-16-03</filename>, then you can specify the
+<option>nixos.path</option> with either the path or the relative path of
+your NixOS clone. For example, you can add the following to your
+<filename>/etc/nixos/configuration.nix</filename> file:
+
+<programlisting>
+nixos.path = ./nixpkgs-16-03/nixos;
+</programlisting>
+</para>
+
+<para>Another option is to fetch a specific version of NixOS, with either
+the <literal>fetchTarball</literal> builtin, or the
+<literal>pkgs.fetchFromGithub</literal> function and use the result as an
+input.
+
+<programlisting>
+nixos.path = "${builtins.fetchTarball https://github.com/NixOS/nixpkgs/archive/1f27976e03c15183191d1b4aa1a40d1f14666cd2.tar.gz}/nixos";
+</programlisting>
+</para>
+
+</section>
+
+
+<section><title>Adding Module Dynamically</title>
+
+<para>To add additional module, the recommended way is to use statically
+known modules in the list of imported arguments as described in <xref
+linkend="sec-modularity" />.  Unfortunately, this recommended method has
+limitation, such that the list of imported files cannot be selected based on
+the content of the configuration.
+
+Fortunately, NixOS reentry system can be used as an alternative to register
+new imported modules based on the content of the configuration. To do so,
+one should define both <option>nixos.path</option> and
+<option>nixos.extraModules</option> options.
+
+<programlisting>
+nixos.path = &lt;nixos&gt;;
+nixos.extraModules =
+  if config.networking.hostName == "server" then
+    [ ./server.nix ] else [ ./client.nix ];
+</programlisting>
+
+Also note, that the above can be reimplemented in a different way which is
+not as expensive, by using <literal>mkIf</literal> at the top each
+configuration if both modules are present on the file system (see <xref
+linkend="sec-option-definitions" />) and by always inmporting both
+modules.</para>
+
+</section>
+
+<section><title>Options</title>
+
+<para>FIXME: auto-generated list of module options.</para>
+
+</section>
+
+
+</chapter>