1<refentry 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 <refmeta>
5 <refentrytitle><command>nixos-enter</command>
6 </refentrytitle><manvolnum>8</manvolnum>
7 <refmiscinfo class="source">NixOS</refmiscinfo>
8<!-- <refmiscinfo class="version"><xi:include href="version.txt" parse="text"/></refmiscinfo> -->
9 </refmeta>
10 <refnamediv>
11 <refname><command>nixos-enter</command>
12 </refname><refpurpose>run a command in a NixOS chroot environment</refpurpose>
13 </refnamediv>
14 <refsynopsisdiv>
15 <cmdsynopsis>
16 <command>nixos-enter</command>
17 <arg>
18 <arg choice='plain'>
19 <option>--root</option>
20 </arg>
21 <replaceable>root</replaceable>
22 </arg>
23
24 <arg>
25 <arg choice='plain'>
26 <option>--system</option>
27 </arg>
28 <replaceable>system</replaceable>
29 </arg>
30
31 <arg>
32 <arg choice='plain'>
33 <option>-c</option>
34 </arg>
35 <replaceable>shell-command</replaceable>
36 </arg>
37
38 <arg>
39 <arg choice='plain'>
40 <option>--help</option>
41 </arg>
42 </arg>
43
44 <arg>
45 <arg choice='plain'>
46 <option>--</option>
47 </arg>
48 <replaceable>arguments</replaceable>
49 </arg>
50 </cmdsynopsis>
51 </refsynopsisdiv>
52 <refsection>
53 <title>Description</title>
54 <para>
55 This command runs a command in a NixOS chroot environment, that is, in a
56 filesystem hierarchy previously prepared using
57 <command>nixos-install</command>.
58 </para>
59 </refsection>
60 <refsection>
61 <title>Options</title>
62 <para>
63 This command accepts the following options:
64 </para>
65 <variablelist>
66 <varlistentry>
67 <term>
68 <option>--root</option>
69 </term>
70 <listitem>
71 <para>
72 The path to the NixOS system you want to enter. It defaults to
73 <filename>/mnt</filename>.
74 </para>
75 </listitem>
76 </varlistentry>
77 <varlistentry>
78 <term>
79 <option>--system</option>
80 </term>
81 <listitem>
82 <para>
83 The NixOS system configuration to use. It defaults to
84 <filename>/nix/var/nix/profiles/system</filename>. You can enter a
85 previous NixOS configuration by specifying a path such as
86 <filename>/nix/var/nix/profiles/system-106-link</filename>.
87 </para>
88 </listitem>
89 </varlistentry>
90 <varlistentry>
91 <term>
92 <option>--command</option>
93 </term>
94 <term>
95 <option>-c</option>
96 </term>
97 <listitem>
98 <para>
99 The bash command to execute.
100 </para>
101 </listitem>
102 </varlistentry>
103 <varlistentry>
104 <term>
105 <option>--</option>
106 </term>
107 <listitem>
108 <para>
109 Interpret the remaining arguments as the program name and arguments to be
110 invoked. The program is not executed in a shell.
111 </para>
112 </listitem>
113 </varlistentry>
114 </variablelist>
115 </refsection>
116 <refsection>
117 <title>Examples</title>
118 <para>
119 Start an interactive shell in the NixOS installation in
120 <filename>/mnt</filename>:
121 </para>
122<screen>
123# nixos-enter /mnt
124</screen>
125 <para>
126 Run a shell command:
127 </para>
128<screen>
129# nixos-enter -c 'ls -l /; cat /proc/mounts'
130</screen>
131 <para>
132 Run a non-shell command:
133 </para>
134<screen>
135# nixos-enter -- cat /proc/mounts
136</screen>
137 </refsection>
138</refentry>