Find file
Fetching contributors…
Cannot retrieve contributors at this time
105 lines (81 sloc) 3.19 KB
[% WRAPPER title="NixOps" hideTitle=1 menu='nixops' %]
<div class="page-header">
<h2>The NixOS Cloud Deployment Tool</h2>
<a href="[%root%]nixos/screenshots/nixos-nixops-vbox.png"><img
class="inline screenshot"
alt="NixOps screenshot" /></a>
<p>NixOps is a tool for deploying sets of <a href="[%root%]">NixOS
Linux</a> machines, either to real hardware or to virtual machines. It
extends NixOS’s declarative approach to system configuration
management to networks and adds provisioning. For example, here is a
NixOps specification of a network consisting of two machines — one
running Apache httpd, the other serving a file system via NFS:</p>
webserver =
{ deployment.targetEnv = "virtualbox";
services.httpd.enable = true;
services.httpd.documentRoot = "/data";
fileSystems."/data" =
{ fsType = "nfs4";
device = "fileserver:/"; };
fileserver =
{ deployment.targetEnv = "virtualbox";
services.nfs.server.enable = true;
services.nfs.server.exports = "...";
<p>The values of the <tt>webserver</tt> and <tt>fileserver</tt>
attributes are regular NixOS system specifications, except for the
<tt>deployment.*</tt> options, which tell NixOps how each machine
should be instantiated (in this case, as VirtualBox virtual machines
running on your desktop). You can then run:</p>
<span class="muted">$</span> nixops create -d simple network.nix
<span class="muted">$</span> nixops deploy -d simple
<p>This will create the EC2 instances, and then build, upload and
activate the NixOS configurations you specified. To change something
to the configuration, you just edit the specification and run
<tt>nixops deploy</tt> again.</p>
<p>NixOps makes it easy to abstract over target environments, allowing
you to use the same “logical” specification for both testing and
production deployments. For instance, to deploy to Amazon EC2, you
would just change the <tt>deployment.*</tt> options to:</p>
deployment.targetEnv = "ec2";
deployment.region = "eu-west-1";
<p>NixOps currently supports provisioning the following resources:</p>
<li>Amazon EC2 instances and other resources (such as S3 buckets, EC2 key pairs, elastic IPs, etc.).</li>
<li>Google Cloud Engine instances and other resources (such as networks, firewalls, IPs, disks, etc.).</li>
<li>VirtualBox virtual machines.</li>
<li>Hetzner machines.</li>
<li>NixOS containers.</li>
<section><h2>Getting it</h2>
<p>If you already have Nix or NixOS installed, you can get NixOps by
<span class="muted">$</span> nix-env -i nixops
<p>You can also get the latest development version; see the <a
href="[%nixopsManual#chap-installation%]">manual</a> for details.</p>
<li>The <a href="[%nixopsManual%]">NixOps manual</a> tells you
everything you need to know about using NixOps.</li>
<li>There is <a
short paper</a> that gives an overview of NixOps (called
<em>Charon</em> back then).</li>
[% END %]