0
0
Fork 0
mirror of https://github.com/NixOS/nixpkgs.git synced 2025-07-13 21:50:33 +03:00

Merge pull request #98503 from jtojnar/doc-prompts

This commit is contained in:
Jan Tojnar 2020-09-24 22:48:38 +02:00 committed by GitHub
commit 6d518ddf77
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
34 changed files with 261 additions and 249 deletions

View file

@ -132,11 +132,11 @@ buildImage {
<para> <para>
By default <function>buildImage</function> will use a static date of one second past the UNIX Epoch. This allows <function>buildImage</function> to produce binary reproducible images. When listing images with <command>docker images</command>, the newly created images will be listed like this: By default <function>buildImage</function> will use a static date of one second past the UNIX Epoch. This allows <function>buildImage</function> to produce binary reproducible images. When listing images with <command>docker images</command>, the newly created images will be listed like this:
</para> </para>
<screen><![CDATA[ <screen>
$ docker images <prompt>$ </prompt>docker images
REPOSITORY TAG IMAGE ID CREATED SIZE REPOSITORY TAG IMAGE ID CREATED SIZE
hello latest 08c791c7846e 48 years ago 25.2MB hello latest 08c791c7846e 48 years ago 25.2MB
]]></screen> </screen>
<para> <para>
You can break binary reproducibility but have a sorted, meaningful <literal>CREATED</literal> column by setting <literal>created</literal> to <literal>now</literal>. You can break binary reproducibility but have a sorted, meaningful <literal>CREATED</literal> column by setting <literal>created</literal> to <literal>now</literal>.
</para> </para>
@ -152,11 +152,11 @@ pkgs.dockerTools.buildImage {
]]></programlisting> ]]></programlisting>
<para> <para>
and now the Docker CLI will display a reasonable date and sort the images as expected: and now the Docker CLI will display a reasonable date and sort the images as expected:
<screen><![CDATA[ <screen>
$ docker images <prompt>$ </prompt>docker images
REPOSITORY TAG IMAGE ID CREATED SIZE REPOSITORY TAG IMAGE ID CREATED SIZE
hello latest de2bf4786de6 About a minute ago 25.2MB hello latest de2bf4786de6 About a minute ago 25.2MB
]]></screen> </screen>
however, the produced images will not be binary reproducible. however, the produced images will not be binary reproducible.
</para> </para>
</example> </example>

View file

@ -38,8 +38,7 @@ buildContainer {
readonly = false; <co xml:id='ex-ociTools-buildContainer-3' /> readonly = false; <co xml:id='ex-ociTools-buildContainer-3' />
} }
</programlisting>
</programlisting>
<calloutlist> <calloutlist>
<callout arearefs='ex-ociTools-buildContainer-1'> <callout arearefs='ex-ociTools-buildContainer-1'>
<para> <para>

View file

@ -22,10 +22,10 @@
</para> </para>
<para> <para>
In order to set this up, you first have to <link xlink:href="https://its.uiowa.edu/support/article/102186">download the <literal>.cr</literal> file from the Netscaler Gateway</link>. After that you can configure the <command>selfservice</command> like this: In order to set this up, you first have to <link xlink:href="https://its.uiowa.edu/support/article/102186">download the <literal>.cr</literal> file from the Netscaler Gateway</link>. After that you can configure the <command>selfservice</command> like this:
<screen> <screen>
<prompt>$ </prompt>storebrowse -C ~/Downloads/receiverconfig.cr <prompt>$ </prompt>storebrowse -C ~/Downloads/receiverconfig.cr
<prompt>$ </prompt>selfservice <prompt>$ </prompt>selfservice
</screen> </screen>
</para> </para>
</section> </section>

View file

@ -18,10 +18,13 @@
includes all available plugins. To make use of this functionality, use an includes all available plugins. To make use of this functionality, use an
overlay or directly install an expression that overrides its configuration, overlay or directly install an expression that overrides its configuration,
such as such as
<programlisting>rxvt-unicode.override { configure = { availablePlugins, ... }: { <programlisting>
rxvt-unicode.override {
configure = { availablePlugins, ... }: {
plugins = with availablePlugins; [ perls resize-font vtwheel ]; plugins = with availablePlugins; [ perls resize-font vtwheel ];
} };
}</programlisting> }
</programlisting>
If the <literal>configure</literal> function returns an attrset without the If the <literal>configure</literal> function returns an attrset without the
<literal>plugins</literal> attribute, <literal>availablePlugins</literal> <literal>plugins</literal> attribute, <literal>availablePlugins</literal>
will be used automatically. will be used automatically.
@ -30,18 +33,22 @@
<para> <para>
In order to add plugins but also keep all default plugins installed, it is In order to add plugins but also keep all default plugins installed, it is
possible to use the following method: possible to use the following method:
<programlisting>rxvt-unicode.override { configure = { availablePlugins, ... }: { <programlisting>
plugins = (builtins.attrValues availablePlugins) ++ [ custom-plugin ]; rxvt-unicode.override {
}; configure = { availablePlugins, ... }: {
}</programlisting> plugins = (builtins.attrValues availablePlugins) ++ [ custom-plugin ];
};
}
</programlisting>
</para> </para>
<para> <para>
To get a list of all the plugins available, open the Nix REPL and run To get a list of all the plugins available, open the Nix REPL and run
<programlisting>$ nix repl <screen>
<prompt>$ </prompt>nix repl
:l &lt;nixpkgs&gt; :l &lt;nixpkgs&gt;
map (p: p.name) pkgs.rxvt-unicode.plugins map (p: p.name) pkgs.rxvt-unicode.plugins
</programlisting> </screen>
Alternatively, if your shell is bash or zsh and have completion enabled, Alternatively, if your shell is bash or zsh and have completion enabled,
simply type <literal>nixpkgs.rxvt-unicode.plugins.&lt;tab&gt;</literal>. simply type <literal>nixpkgs.rxvt-unicode.plugins.&lt;tab&gt;</literal>.
</para> </para>
@ -53,18 +60,24 @@ map (p: p.name) pkgs.rxvt-unicode.plugins
<literal>extraDeps</literal> can be used, for example, to provide <literal>extraDeps</literal> can be used, for example, to provide
<literal>xsel</literal> (a clipboard manager) to the clipboard plugin, <literal>xsel</literal> (a clipboard manager) to the clipboard plugin,
without installing it globally: without installing it globally:
<programlisting>rxvt-unicode.override { configure = { availablePlugins, ... }: { <programlisting>
pluginsDeps = [ xsel ]; rxvt-unicode.override {
} configure = { availablePlugins, ... }: {
}</programlisting> pluginsDeps = [ xsel ];
};
}
</programlisting>
<literal>perlDeps</literal> is a handy way to provide Perl packages to <literal>perlDeps</literal> is a handy way to provide Perl packages to
your custom plugins (in <literal>$HOME/.urxvt/ext</literal>). For example, your custom plugins (in <literal>$HOME/.urxvt/ext</literal>). For example,
if you need <literal>AnyEvent</literal> you can do: if you need <literal>AnyEvent</literal> you can do:
<programlisting>rxvt-unicode.override { configure = { availablePlugins, ... }: { <programlisting>
perlDeps = with perlPackages; [ AnyEvent ]; rxvt-unicode.override {
} configure = { availablePlugins, ... }: {
}</programlisting> perlDeps = with perlPackages; [ AnyEvent ];
};
}
</programlisting>
</para> </para>
</section> </section>
@ -90,7 +103,8 @@ map (p: p.name) pkgs.rxvt-unicode.plugins
<para> <para>
If the plugin is itself a perl package that needs to be imported from If the plugin is itself a perl package that needs to be imported from
other plugins or scripts, add the following passthrough: other plugins or scripts, add the following passthrough:
<programlisting>passthru.perlPackages = [ "self" ]; <programlisting>
passthru.perlPackages = [ "self" ];
</programlisting> </programlisting>
This will make the urxvt wrapper pick up the dependency and set up the perl This will make the urxvt wrapper pick up the dependency and set up the perl
path accordingly. path accordingly.

View file

@ -209,12 +209,12 @@ Additional information.
</para> </para>
<programlisting> <programlisting>
(fetchpatch { (fetchpatch {
name = "CVE-2019-11068.patch"; name = "CVE-2019-11068.patch";
url = "https://gitlab.gnome.org/GNOME/libxslt/commit/e03553605b45c88f0b4b2980adfbbb8f6fca2fd6.patch"; url = "https://gitlab.gnome.org/GNOME/libxslt/commit/e03553605b45c88f0b4b2980adfbbb8f6fca2fd6.patch";
sha256 = "0pkpb4837km15zgg6h57bncp66d5lwrlvkr73h0lanywq7zrwhj8"; sha256 = "0pkpb4837km15zgg6h57bncp66d5lwrlvkr73h0lanywq7zrwhj8";
}) })
</programlisting> </programlisting>
<para> <para>
If a security fix applies to both master and a stable release then, similar to regular changes, they are preferably delivered via master first and cherry-picked to the release branch. If a security fix applies to both master and a stable release then, similar to regular changes, they are preferably delivered via master first and cherry-picked to the release branch.

View file

@ -72,9 +72,9 @@
To install any of those builders into your profile, refer to them by their attribute path <literal>beamPackages.rebar3</literal>: To install any of those builders into your profile, refer to them by their attribute path <literal>beamPackages.rebar3</literal>:
</para> </para>
<screen> <screen>
<prompt>$ </prompt>nix-env -f &quot;&lt;nixpkgs&gt;&quot; -iA beamPackages.rebar3 <prompt>$ </prompt>nix-env -f &quot;&lt;nixpkgs&gt;&quot; -iA beamPackages.rebar3
</screen> </screen>
</section> </section>
<section xml:id="packaging-beam-applications"> <section xml:id="packaging-beam-applications">

View file

@ -8,28 +8,28 @@
<para> <para>
When executing a Perl script, it is possible you get an error such as <literal>./myscript.pl: bad interpreter: /usr/bin/perl: no such file or directory</literal>. This happens when the script expects Perl to be installed at <filename>/usr/bin/perl</filename>, which is not the case when using Perl from nixpkgs. You can fix the script by changing the first line to: When executing a Perl script, it is possible you get an error such as <literal>./myscript.pl: bad interpreter: /usr/bin/perl: no such file or directory</literal>. This happens when the script expects Perl to be installed at <filename>/usr/bin/perl</filename>, which is not the case when using Perl from nixpkgs. You can fix the script by changing the first line to:
<programlisting> <programlisting>
#!/usr/bin/env perl #!/usr/bin/env perl
</programlisting> </programlisting>
to take the Perl installation from the <literal>PATH</literal> environment variable, or invoke Perl directly with: to take the Perl installation from the <literal>PATH</literal> environment variable, or invoke Perl directly with:
<screen> <screen>
<prompt>$ </prompt>perl ./myscript.pl <prompt>$ </prompt>perl ./myscript.pl
</screen> </screen>
</para> </para>
<para> <para>
When the script is using a Perl library that is not installed globally, you might get an error such as <literal>Can't locate DB_File.pm in @INC (you may need to install the DB_File module)</literal>. In that case, you can use <command>nix-shell</command> to start an ad-hoc shell with that library installed, for instance: When the script is using a Perl library that is not installed globally, you might get an error such as <literal>Can't locate DB_File.pm in @INC (you may need to install the DB_File module)</literal>. In that case, you can use <command>nix-shell</command> to start an ad-hoc shell with that library installed, for instance:
<screen> <screen>
<prompt>$ </prompt>nix-shell -p perl perlPackages.DBFile --run ./myscript.pl <prompt>$ </prompt>nix-shell -p perl perlPackages.DBFile --run ./myscript.pl
</screen> </screen>
</para> </para>
<para> <para>
If you are always using the script in places where <command>nix-shell</command> is available, you can embed the <command>nix-shell</command> invocation in the shebang like this: If you are always using the script in places where <command>nix-shell</command> is available, you can embed the <command>nix-shell</command> invocation in the shebang like this:
<programlisting> <programlisting>
#!/usr/bin/env nix-shell #!/usr/bin/env nix-shell
#! nix-shell -i perl -p perl perlPackages.DBFile #! nix-shell -i perl -p perl perlPackages.DBFile
</programlisting> </programlisting>
</para> </para>
</section> </section>
@ -44,30 +44,30 @@
<para> <para>
Perl packages from CPAN are defined in <link Perl packages from CPAN are defined in <link
xlink:href="https://github.com/NixOS/nixpkgs/blob/master/pkgs/top-level/perl-packages.nix"><filename>pkgs/top-level/perl-packages.nix</filename></link>, rather than <filename>pkgs/all-packages.nix</filename>. Most Perl packages are so straight-forward to build that they are defined here directly, rather than having a separate function for each package called from <filename>perl-packages.nix</filename>. However, more complicated packages should be put in a separate file, typically in <filename>pkgs/development/perl-modules</filename>. Here is an example of the former: xlink:href="https://github.com/NixOS/nixpkgs/blob/master/pkgs/top-level/perl-packages.nix"><filename>pkgs/top-level/perl-packages.nix</filename></link>, rather than <filename>pkgs/all-packages.nix</filename>. Most Perl packages are so straight-forward to build that they are defined here directly, rather than having a separate function for each package called from <filename>perl-packages.nix</filename>. However, more complicated packages should be put in a separate file, typically in <filename>pkgs/development/perl-modules</filename>. Here is an example of the former:
<programlisting> <programlisting>
ClassC3 = buildPerlPackage rec { ClassC3 = buildPerlPackage rec {
name = "Class-C3-0.21"; name = "Class-C3-0.21";
src = fetchurl { src = fetchurl {
url = "mirror://cpan/authors/id/F/FL/FLORA/${name}.tar.gz"; url = "mirror://cpan/authors/id/F/FL/FLORA/${name}.tar.gz";
sha256 = "1bl8z095y4js66pwxnm7s853pi9czala4sqc743fdlnk27kq94gz"; sha256 = "1bl8z095y4js66pwxnm7s853pi9czala4sqc743fdlnk27kq94gz";
}; };
}; };
</programlisting> </programlisting>
Note the use of <literal>mirror://cpan/</literal>, and the <literal>${name}</literal> in the URL definition to ensure that the name attribute is consistent with the source that were actually downloading. Perl packages are made available in <filename>all-packages.nix</filename> through the variable <varname>perlPackages</varname>. For instance, if you have a package that needs <varname>ClassC3</varname>, you would typically write Note the use of <literal>mirror://cpan/</literal>, and the <literal>${name}</literal> in the URL definition to ensure that the name attribute is consistent with the source that were actually downloading. Perl packages are made available in <filename>all-packages.nix</filename> through the variable <varname>perlPackages</varname>. For instance, if you have a package that needs <varname>ClassC3</varname>, you would typically write
<programlisting> <programlisting>
foo = import ../path/to/foo.nix { foo = import ../path/to/foo.nix {
inherit stdenv fetchurl ...; inherit stdenv fetchurl ...;
inherit (perlPackages) ClassC3; inherit (perlPackages) ClassC3;
}; };
</programlisting> </programlisting>
in <filename>all-packages.nix</filename>. You can test building a Perl package as follows: in <filename>all-packages.nix</filename>. You can test building a Perl package as follows:
<screen> <screen>
<prompt>$ </prompt>nix-build -A perlPackages.ClassC3 <prompt>$ </prompt>nix-build -A perlPackages.ClassC3
</screen> </screen>
<varname>buildPerlPackage</varname> adds <literal>perl-</literal> to the start of the name attribute, so the package above is actually called <literal>perl-Class-C3-0.21</literal>. So to install it, you can say: <varname>buildPerlPackage</varname> adds <literal>perl-</literal> to the start of the name attribute, so the package above is actually called <literal>perl-Class-C3-0.21</literal>. So to install it, you can say:
<screen> <screen>
<prompt>$ </prompt>nix-env -i perl-Class-C3 <prompt>$ </prompt>nix-env -i perl-Class-C3
</screen> </screen>
(Of course you can also install using the attribute name: <literal>nix-env -i -A perlPackages.ClassC3</literal>.) (Of course you can also install using the attribute name: <literal>nix-env -i -A perlPackages.ClassC3</literal>.)
</para> </para>
@ -94,61 +94,61 @@
<para> <para>
<varname>buildPerlPackage</varname> is built on top of <varname>stdenv</varname>, so everything can be customised in the usual way. For instance, the <literal>BerkeleyDB</literal> module has a <varname>preConfigure</varname> hook to generate a configuration file used by <filename>Makefile.PL</filename>: <varname>buildPerlPackage</varname> is built on top of <varname>stdenv</varname>, so everything can be customised in the usual way. For instance, the <literal>BerkeleyDB</literal> module has a <varname>preConfigure</varname> hook to generate a configuration file used by <filename>Makefile.PL</filename>:
<programlisting> <programlisting>
{ buildPerlPackage, fetchurl, db }: { buildPerlPackage, fetchurl, db }:
buildPerlPackage rec { buildPerlPackage rec {
name = "BerkeleyDB-0.36"; name = "BerkeleyDB-0.36";
src = fetchurl { src = fetchurl {
url = "mirror://cpan/authors/id/P/PM/PMQS/${name}.tar.gz"; url = "mirror://cpan/authors/id/P/PM/PMQS/${name}.tar.gz";
sha256 = "07xf50riarb60l1h6m2dqmql8q5dij619712fsgw7ach04d8g3z1"; sha256 = "07xf50riarb60l1h6m2dqmql8q5dij619712fsgw7ach04d8g3z1";
}; };
preConfigure = '' preConfigure = ''
echo "LIB = ${db.out}/lib" > config.in echo "LIB = ${db.out}/lib" > config.in
echo "INCLUDE = ${db.dev}/include" >> config.in echo "INCLUDE = ${db.dev}/include" >> config.in
''; '';
} }
</programlisting> </programlisting>
</para> </para>
<para> <para>
Dependencies on other Perl packages can be specified in the <varname>buildInputs</varname> and <varname>propagatedBuildInputs</varname> attributes. If something is exclusively a build-time dependency, use <varname>buildInputs</varname>; if its (also) a runtime dependency, use <varname>propagatedBuildInputs</varname>. For instance, this builds a Perl module that has runtime dependencies on a bunch of other modules: Dependencies on other Perl packages can be specified in the <varname>buildInputs</varname> and <varname>propagatedBuildInputs</varname> attributes. If something is exclusively a build-time dependency, use <varname>buildInputs</varname>; if its (also) a runtime dependency, use <varname>propagatedBuildInputs</varname>. For instance, this builds a Perl module that has runtime dependencies on a bunch of other modules:
<programlisting> <programlisting>
ClassC3Componentised = buildPerlPackage rec { ClassC3Componentised = buildPerlPackage rec {
name = "Class-C3-Componentised-1.0004"; name = "Class-C3-Componentised-1.0004";
src = fetchurl { src = fetchurl {
url = "mirror://cpan/authors/id/A/AS/ASH/${name}.tar.gz"; url = "mirror://cpan/authors/id/A/AS/ASH/${name}.tar.gz";
sha256 = "0xql73jkcdbq4q9m0b0rnca6nrlvf5hyzy8is0crdk65bynvs8q1"; sha256 = "0xql73jkcdbq4q9m0b0rnca6nrlvf5hyzy8is0crdk65bynvs8q1";
}; };
propagatedBuildInputs = [ propagatedBuildInputs = [
ClassC3 ClassInspector TestException MROCompat ClassC3 ClassInspector TestException MROCompat
]; ];
}; };
</programlisting> </programlisting>
</para> </para>
<para> <para>
On Darwin, if a script has too many <literal>-I<replaceable>dir</replaceable></literal> flags in its first line (its “shebang line”), it will not run. This can be worked around by calling the <literal>shortenPerlShebang</literal> function from the <literal>postInstall</literal> phase: On Darwin, if a script has too many <literal>-I<replaceable>dir</replaceable></literal> flags in its first line (its “shebang line”), it will not run. This can be worked around by calling the <literal>shortenPerlShebang</literal> function from the <literal>postInstall</literal> phase:
<programlisting> <programlisting>
{ stdenv, buildPerlPackage, fetchurl, shortenPerlShebang }: { stdenv, buildPerlPackage, fetchurl, shortenPerlShebang }:
ImageExifTool = buildPerlPackage { ImageExifTool = buildPerlPackage {
pname = "Image-ExifTool"; pname = "Image-ExifTool";
version = "11.50"; version = "11.50";
src = fetchurl { src = fetchurl {
url = "https://www.sno.phy.queensu.ca/~phil/exiftool/Image-ExifTool-11.50.tar.gz"; url = "https://www.sno.phy.queensu.ca/~phil/exiftool/Image-ExifTool-11.50.tar.gz";
sha256 = "0d8v48y94z8maxkmw1rv7v9m0jg2dc8xbp581njb6yhr7abwqdv3"; sha256 = "0d8v48y94z8maxkmw1rv7v9m0jg2dc8xbp581njb6yhr7abwqdv3";
}; };
buildInputs = stdenv.lib.optional stdenv.isDarwin shortenPerlShebang; buildInputs = stdenv.lib.optional stdenv.isDarwin shortenPerlShebang;
postInstall = stdenv.lib.optional stdenv.isDarwin '' postInstall = stdenv.lib.optional stdenv.isDarwin ''
shortenPerlShebang $out/bin/exiftool shortenPerlShebang $out/bin/exiftool
''; '';
}; };
</programlisting> </programlisting>
This will remove the <literal>-I</literal> flags from the shebang line, rewrite them in the <literal>use lib</literal> form, and put them on the next line instead. This function can be given any number of Perl scripts as arguments; it will modify them in-place. This will remove the <literal>-I</literal> flags from the shebang line, rewrite them in the <literal>use lib</literal> form, and put them on the next line instead. This function can be given any number of Perl scripts as arguments; it will modify them in-place.
</para> </para>
@ -159,27 +159,27 @@
Nix expressions for Perl packages can be generated (almost) automatically from CPAN. This is done by the program <command>nix-generate-from-cpan</command>, which can be installed as follows: Nix expressions for Perl packages can be generated (almost) automatically from CPAN. This is done by the program <command>nix-generate-from-cpan</command>, which can be installed as follows:
</para> </para>
<screen> <screen>
<prompt>$ </prompt>nix-env -i nix-generate-from-cpan <prompt>$ </prompt>nix-env -i nix-generate-from-cpan
</screen> </screen>
<para> <para>
This program takes a Perl module name, looks it up on CPAN, fetches and unpacks the corresponding package, and prints a Nix expression on standard output. For example: This program takes a Perl module name, looks it up on CPAN, fetches and unpacks the corresponding package, and prints a Nix expression on standard output. For example:
<screen> <screen>
<prompt>$ </prompt>nix-generate-from-cpan XML::Simple <prompt>$ </prompt>nix-generate-from-cpan XML::Simple
XMLSimple = buildPerlPackage rec { XMLSimple = buildPerlPackage rec {
name = "XML-Simple-2.22"; name = "XML-Simple-2.22";
src = fetchurl { src = fetchurl {
url = "mirror://cpan/authors/id/G/GR/GRANTM/${name}.tar.gz"; url = "mirror://cpan/authors/id/G/GR/GRANTM/${name}.tar.gz";
sha256 = "b9450ef22ea9644ae5d6ada086dc4300fa105be050a2030ebd4efd28c198eb49"; sha256 = "b9450ef22ea9644ae5d6ada086dc4300fa105be050a2030ebd4efd28c198eb49";
}; };
propagatedBuildInputs = [ XMLNamespaceSupport XMLSAX XMLSAXExpat ]; propagatedBuildInputs = [ XMLNamespaceSupport XMLSAX XMLSAXExpat ];
meta = { meta = {
description = "An API for simple XML files"; description = "An API for simple XML files";
license = with stdenv.lib.licenses; [ artistic1 gpl1Plus ]; license = with stdenv.lib.licenses; [ artistic1 gpl1Plus ];
}; };
}; };
</screen> </screen>
The output can be pasted into <filename>pkgs/top-level/perl-packages.nix</filename> or wherever else you need it. The output can be pasted into <filename>pkgs/top-level/perl-packages.nix</filename> or wherever else you need it.
</para> </para>
</section> </section>

View file

@ -18,7 +18,7 @@ mkDerivation { <co xml:id='qt-default-nix-co-2' />
buildInputs = [ qtbase ]; <co xml:id='qt-default-nix-co-3' /> buildInputs = [ qtbase ]; <co xml:id='qt-default-nix-co-3' />
} }
</programlisting> </programlisting>
</example> </example>
<calloutlist> <calloutlist>

View file

@ -12,14 +12,14 @@
</para> </para>
<screen> <screen>
<![CDATA[$ cd pkgs/servers/monitoring <prompt>$ </prompt>cd pkgs/servers/monitoring
$ mkdir sensu <prompt>$ </prompt>mkdir sensu
$ cd sensu <prompt>$ </prompt>cd sensu
$ cat > Gemfile <prompt>$ </prompt>cat > Gemfile
source 'https://rubygems.org' source 'https://rubygems.org'
gem 'sensu' gem 'sensu'
$ $(nix-build '<nixpkgs>' -A bundix --no-out-link)/bin/bundix --magic <prompt>$ </prompt>$(nix-build '&lt;nixpkgs>' -A bundix --no-out-link)/bin/bundix --magic
$ cat > default.nix <prompt>$ </prompt>cat > default.nix
{ lib, bundlerEnv, ruby }: { lib, bundlerEnv, ruby }:
bundlerEnv rec { bundlerEnv rec {
@ -37,7 +37,7 @@ bundlerEnv rec {
maintainers = with maintainers; [ theuni ]; maintainers = with maintainers; [ theuni ];
platforms = platforms.unix; platforms = platforms.unix;
}; };
}]]> }
</screen> </screen>
<para> <para>
@ -49,17 +49,16 @@ bundlerEnv rec {
</para> </para>
<screen> <screen>
<![CDATA[$ cd pkgs/servers/monitoring/sensu <prompt>$ </prompt>cd pkgs/servers/monitoring/sensu
$ nix-shell -p bundler --run 'bundle lock --update' <prompt>$ </prompt>nix-shell -p bundler --run 'bundle lock --update'
$ nix-shell -p bundix --run 'bundix' <prompt>$ </prompt>nix-shell -p bundix --run 'bundix'
]]>
</screen> </screen>
<para> <para>
For tools written in Ruby - i.e. where the desire is to install a package and then execute e.g. <command>rake</command> at the command line, there is an alternative builder called <literal>bundlerApp</literal>. Set up the <filename>gemset.nix</filename> the same way, and then, for example: For tools written in Ruby - i.e. where the desire is to install a package and then execute e.g. <command>rake</command> at the command line, there is an alternative builder called <literal>bundlerApp</literal>. Set up the <filename>gemset.nix</filename> the same way, and then, for example:
</para> </para>
<screen> <programlisting>
<![CDATA[{ lib, bundlerApp }: <![CDATA[{ lib, bundlerApp }:
bundlerApp { bundlerApp {
@ -75,7 +74,7 @@ bundlerApp {
platforms = platforms.unix; platforms = platforms.unix;
}; };
}]]> }]]>
</screen> </programlisting>
<para> <para>
The chief advantage of <literal>bundlerApp</literal> over <literal>bundlerEnv</literal> is the executables introduced in the environment are precisely those selected in the <literal>exes</literal> list, as opposed to <literal>bundlerEnv</literal> which adds all the executables made available by gems in the gemset, which can mean e.g. <command>rspec</command> or <command>rake</command> in unpredictable versions available from various packages. The chief advantage of <literal>bundlerApp</literal> over <literal>bundlerEnv</literal> is the executables introduced in the environment are precisely those selected in the <literal>exes</literal> list, as opposed to <literal>bundlerEnv</literal> which adds all the executables made available by gems in the gemset, which can mean e.g. <command>rspec</command> or <command>rake</command> in unpredictable versions available from various packages.

View file

@ -44,11 +44,11 @@ texlive.combine {
<listitem> <listitem>
<para> <para>
You can list packages e.g. by <command>nix repl</command>. You can list packages e.g. by <command>nix repl</command>.
<programlisting><![CDATA[ <programlisting>
$ nix repl <prompt>$ </prompt>nix repl
nix-repl> :l <nixpkgs> <prompt>nix-repl> </prompt>:l &lt;nixpkgs>
nix-repl> texlive.collection-<TAB> <prompt>nix-repl> </prompt>texlive.collection-<keycap function="tab" />
]]></programlisting> </programlisting>
</para> </para>
</listitem> </listitem>
<listitem> <listitem>

View file

@ -67,7 +67,7 @@
<para> <para>
<command>nix-env</command> silenty disregards the outputs selected by the user, and instead installs the outputs from <varname>meta.outputsToInstall</varname>. For example, <command>nix-env</command> silenty disregards the outputs selected by the user, and instead installs the outputs from <varname>meta.outputsToInstall</varname>. For example,
</para> </para>
<programlisting>$ nix-env -iA nixpkgs.coreutils.info</programlisting> <screen><prompt>$ </prompt>nix-env -iA nixpkgs.coreutils.info</screen>
<para> <para>
installs the <literal>"out"</literal> output (<varname>coreutils.meta.outputsToInstall</varname> is <literal>[ "out" ]</literal>) instead of the requested <literal>"info"</literal>. installs the <literal>"out"</literal> output (<varname>coreutils.meta.outputsToInstall</varname> is <literal>[ "out" ]</literal>) instead of the requested <literal>"info"</literal>.
</para> </para>

View file

@ -66,7 +66,7 @@
<listitem> <listitem>
<para> <para>
For allowing the build of a broken package once, you can use an environment variable for a single invocation of the nix tools: For allowing the build of a broken package once, you can use an environment variable for a single invocation of the nix tools:
<programlisting>$ export NIXPKGS_ALLOW_BROKEN=1</programlisting> <screen><prompt>$ </prompt>export NIXPKGS_ALLOW_BROKEN=1</screen>
</para> </para>
</listitem> </listitem>
<listitem> <listitem>
@ -92,7 +92,7 @@
<listitem> <listitem>
<para> <para>
For allowing the build of an unsupported package once, you can use an environment variable for a single invocation of the nix tools: For allowing the build of an unsupported package once, you can use an environment variable for a single invocation of the nix tools:
<programlisting>$ export NIXPKGS_ALLOW_UNSUPPORTED_SYSTEM=1</programlisting> <screen><prompt>$ </prompt>export NIXPKGS_ALLOW_UNSUPPORTED_SYSTEM=1</screen>
</para> </para>
</listitem> </listitem>
<listitem> <listitem>
@ -122,7 +122,7 @@
<listitem> <listitem>
<para> <para>
To temporarily allow all unfree packages, you can use an environment variable for a single invocation of the nix tools: To temporarily allow all unfree packages, you can use an environment variable for a single invocation of the nix tools:
<programlisting>$ export NIXPKGS_ALLOW_UNFREE=1</programlisting> <screen><prompt>$ </prompt>export NIXPKGS_ALLOW_UNFREE=1</screen>
</para> </para>
</listitem> </listitem>
<listitem> <listitem>
@ -187,7 +187,7 @@
<listitem> <listitem>
<para> <para>
To temporarily allow all insecure packages, you can use an environment variable for a single invocation of the nix tools: To temporarily allow all insecure packages, you can use an environment variable for a single invocation of the nix tools:
<programlisting>$ export NIXPKGS_ALLOW_INSECURE=1</programlisting> <screen><prompt>$ </prompt>export NIXPKGS_ALLOW_INSECURE=1</screen>
</para> </para>
</listitem> </listitem>
<listitem> <listitem>

View file

@ -240,7 +240,7 @@ self: super:
lapackProvider = self.mkl; lapackProvider = self.mkl;
} }
} }
</programlisting> </programlisting>
<para> <para>
This overlay uses Intels MKL library for both BLAS and LAPACK This overlay uses Intels MKL library for both BLAS and LAPACK
interfaces. Note that the same can be accomplished at runtime interfaces. Note that the same can be accomplished at runtime
@ -248,9 +248,9 @@ self: super:
<literal>libblas.so.3</literal> and <literal>libblas.so.3</literal> and
<literal>liblapack.so.3</literal>. For instance: <literal>liblapack.so.3</literal>. For instance:
</para> </para>
<programlisting> <screen>
$ LD_LIBRARY_PATH=$(nix-build -A mkl)/lib:$LD_LIBRARY_PATH nix-shell -p octave --run octave <prompt>$ </prompt>LD_LIBRARY_PATH=$(nix-build -A mkl)/lib:$LD_LIBRARY_PATH nix-shell -p octave --run octave
</programlisting> </screen>
<para> <para>
Intel MKL requires an <literal>openmp</literal> implementation Intel MKL requires an <literal>openmp</literal> implementation
when running with multiple processors. By default, when running with multiple processors. By default,
@ -288,7 +288,7 @@ assert (!blas.isILP64) &amp;&amp; (!lapack.isILP64);
stdenv.mkDerivation { stdenv.mkDerivation {
... ...
} }
</programlisting> </programlisting>
</section> </section>
</section> </section>
</chapter> </chapter>

View file

@ -14,18 +14,18 @@
<para> <para>
You create a container with identifier <literal>foo</literal> as follows: You create a container with identifier <literal>foo</literal> as follows:
<screen> <screen>
# nixos-container create foo <prompt># </prompt>nixos-container create <replaceable>foo</replaceable>
</screen> </screen>
This creates the containers root directory in This creates the containers root directory in
<filename>/var/lib/containers/foo</filename> and a small configuration file <filename>/var/lib/containers/<replaceable>foo</replaceable></filename> and a small configuration file
in <filename>/etc/containers/foo.conf</filename>. It also builds the in <filename>/etc/containers/<replaceable>foo</replaceable>.conf</filename>. It also builds the
containers initial system configuration and stores it in containers initial system configuration and stores it in
<filename>/nix/var/nix/profiles/per-container/foo/system</filename>. You can <filename>/nix/var/nix/profiles/per-container/<replaceable>foo</replaceable>/system</filename>. You can
modify the initial configuration of the container on the command line. For modify the initial configuration of the container on the command line. For
instance, to create a container that has <command>sshd</command> running, instance, to create a container that has <command>sshd</command> running,
with the given public key for <literal>root</literal>: with the given public key for <literal>root</literal>:
<screen> <screen>
# nixos-container create foo --config ' <prompt># </prompt>nixos-container create <replaceable>foo</replaceable> --config '
<xref linkend="opt-services.openssh.enable"/> = true; <xref linkend="opt-services.openssh.enable"/> = true;
<link linkend="opt-users.users._name_.openssh.authorizedKeys.keys">users.users.root.openssh.authorizedKeys.keys</link> = ["ssh-dss AAAAB3N…"]; <link linkend="opt-users.users._name_.openssh.authorizedKeys.keys">users.users.root.openssh.authorizedKeys.keys</link> = ["ssh-dss AAAAB3N…"];
' '
@ -34,7 +34,7 @@
as container IP. This behavior can be altered by setting <literal>--host-address</literal> and as container IP. This behavior can be altered by setting <literal>--host-address</literal> and
<literal>--local-address</literal>: <literal>--local-address</literal>:
<screen> <screen>
# nixos-container create test --config-file test-container.nix \ <prompt># </prompt>nixos-container create test --config-file test-container.nix \
--local-address 10.235.1.2 --host-address 10.235.1.1 --local-address 10.235.1.2 --host-address 10.235.1.1
</screen> </screen>
</para> </para>
@ -42,7 +42,7 @@
<para> <para>
Creating a container does not start it. To start the container, run: Creating a container does not start it. To start the container, run:
<screen> <screen>
# nixos-container start foo <prompt># </prompt>nixos-container start <replaceable>foo</replaceable>
</screen> </screen>
This command will return as soon as the container has booted and has reached This command will return as soon as the container has booted and has reached
<literal>multi-user.target</literal>. On the host, the container runs within <literal>multi-user.target</literal>. On the host, the container runs within
@ -51,7 +51,7 @@
Thus, if something went wrong, you can get status info using Thus, if something went wrong, you can get status info using
<command>systemctl</command>: <command>systemctl</command>:
<screen> <screen>
# systemctl status container@foo <prompt># </prompt>systemctl status container@<replaceable>foo</replaceable>
</screen> </screen>
</para> </para>
@ -59,22 +59,22 @@
If the container has started successfully, you can log in as root using the If the container has started successfully, you can log in as root using the
<command>root-login</command> operation: <command>root-login</command> operation:
<screen> <screen>
# nixos-container root-login foo <prompt># </prompt>nixos-container root-login <replaceable>foo</replaceable>
[root@foo:~]# <prompt>[root@foo:~]#</prompt>
</screen> </screen>
Note that only root on the host can do this (since there is no Note that only root on the host can do this (since there is no
authentication). You can also get a regular login prompt using the authentication). You can also get a regular login prompt using the
<command>login</command> operation, which is available to all users on the <command>login</command> operation, which is available to all users on the
host: host:
<screen> <screen>
# nixos-container login foo <prompt># </prompt>nixos-container login <replaceable>foo</replaceable>
foo login: alice foo login: alice
Password: *** Password: ***
</screen> </screen>
With <command>nixos-container run</command>, you can execute arbitrary With <command>nixos-container run</command>, you can execute arbitrary
commands in the container: commands in the container:
<screen> <screen>
# nixos-container run foo -- uname -a <prompt># </prompt>nixos-container run <replaceable>foo</replaceable> -- uname -a
Linux foo 3.4.82 #1-NixOS SMP Thu Mar 20 14:44:05 UTC 2014 x86_64 GNU/Linux Linux foo 3.4.82 #1-NixOS SMP Thu Mar 20 14:44:05 UTC 2014 x86_64 GNU/Linux
</screen> </screen>
</para> </para>
@ -85,18 +85,18 @@ Linux foo 3.4.82 #1-NixOS SMP Thu Mar 20 14:44:05 UTC 2014 x86_64 GNU/Linux
<literal>/var/lib/container/<replaceable>name</replaceable>/etc/nixos/configuration.nix</literal>, <literal>/var/lib/container/<replaceable>name</replaceable>/etc/nixos/configuration.nix</literal>,
and run and run
<screen> <screen>
# nixos-container update foo <prompt># </prompt>nixos-container update <replaceable>foo</replaceable>
</screen> </screen>
This will build and activate the new configuration. You can also specify a This will build and activate the new configuration. You can also specify a
new configuration on the command line: new configuration on the command line:
<screen> <screen>
# nixos-container update foo --config ' <prompt># </prompt>nixos-container update <replaceable>foo</replaceable> --config '
<xref linkend="opt-services.httpd.enable"/> = true; <xref linkend="opt-services.httpd.enable"/> = true;
<xref linkend="opt-services.httpd.adminAddr"/> = "foo@example.org"; <xref linkend="opt-services.httpd.adminAddr"/> = "foo@example.org";
<xref linkend="opt-networking.firewall.allowedTCPPorts"/> = [ 80 ]; <xref linkend="opt-networking.firewall.allowedTCPPorts"/> = [ 80 ];
' '
# curl http://$(nixos-container show-ip foo)/ <prompt># </prompt>curl http://$(nixos-container show-ip <replaceable>foo</replaceable>)/
&lt;!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">… &lt;!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">…
</screen> </screen>
However, note that this will overwrite the containers However, note that this will overwrite the containers
@ -117,7 +117,7 @@ Linux foo 3.4.82 #1-NixOS SMP Thu Mar 20 14:44:05 UTC 2014 x86_64 GNU/Linux
by using <command>systemctl</command> on the containers service unit. To by using <command>systemctl</command> on the containers service unit. To
destroy a container, including its file system, do destroy a container, including its file system, do
<screen> <screen>
# nixos-container destroy foo <prompt># </prompt>nixos-container destroy <replaceable>foo</replaceable>
</screen> </screen>
</para> </para>
</section> </section>

View file

@ -8,7 +8,7 @@
<para> <para>
You can enter rescue mode by running: You can enter rescue mode by running:
<screen> <screen>
# systemctl rescue</screen> <prompt># </prompt>systemctl rescue</screen>
This will eventually give you a single-user root shell. Systemd will stop This will eventually give you a single-user root shell. Systemd will stop
(almost) all system services. To get out of maintenance mode, just exit from (almost) all system services. To get out of maintenance mode, just exit from
the rescue shell. the rescue shell.

View file

@ -16,12 +16,12 @@
disable the use of the binary cache by adding <option>--option disable the use of the binary cache by adding <option>--option
use-binary-caches false</option>, e.g. use-binary-caches false</option>, e.g.
<screen> <screen>
# nixos-rebuild switch --option use-binary-caches false <prompt># </prompt>nixos-rebuild switch --option use-binary-caches false
</screen> </screen>
If you have an alternative binary cache at your disposal, you can use it If you have an alternative binary cache at your disposal, you can use it
instead: instead:
<screen> <screen>
# nixos-rebuild switch --option binary-caches http://my-cache.example.org/ <prompt># </prompt>nixos-rebuild switch --option binary-caches <replaceable>http://my-cache.example.org/</replaceable>
</screen> </screen>
</para> </para>
</section> </section>

View file

@ -7,20 +7,20 @@
<para> <para>
The system can be shut down (and automatically powered off) by doing: The system can be shut down (and automatically powered off) by doing:
<screen> <screen>
# shutdown <prompt># </prompt>shutdown
</screen> </screen>
This is equivalent to running <command>systemctl poweroff</command>. This is equivalent to running <command>systemctl poweroff</command>.
</para> </para>
<para> <para>
To reboot the system, run To reboot the system, run
<screen> <screen>
# reboot <prompt># </prompt>reboot
</screen> </screen>
which is equivalent to <command>systemctl reboot</command>. Alternatively, which is equivalent to <command>systemctl reboot</command>. Alternatively,
you can quickly reboot the system using <literal>kexec</literal>, which you can quickly reboot the system using <literal>kexec</literal>, which
bypasses the BIOS by directly loading the new kernel into memory: bypasses the BIOS by directly loading the new kernel into memory:
<screen> <screen>
# systemctl kexec <prompt># </prompt>systemctl kexec
</screen> </screen>
</para> </para>
<para> <para>

View file

@ -20,16 +20,16 @@
has booted, you can make the selected configuration the default for has booted, you can make the selected configuration the default for
subsequent boots: subsequent boots:
<screen> <screen>
# /run/current-system/bin/switch-to-configuration boot</screen> <prompt># </prompt>/run/current-system/bin/switch-to-configuration boot</screen>
</para> </para>
<para> <para>
Second, you can switch to the previous configuration in a running system: Second, you can switch to the previous configuration in a running system:
<screen> <screen>
# nixos-rebuild switch --rollback</screen> <prompt># </prompt>nixos-rebuild switch --rollback</screen>
This is equivalent to running: This is equivalent to running:
<screen> <screen>
# /nix/var/nix/profiles/system-<replaceable>N</replaceable>-link/bin/switch-to-configuration switch</screen> <prompt># </prompt>/nix/var/nix/profiles/system-<replaceable>N</replaceable>-link/bin/switch-to-configuration switch</screen>
where <replaceable>N</replaceable> is the number of the NixOS system where <replaceable>N</replaceable> is the number of the NixOS system
configuration. To get a list of the available configurations, do: configuration. To get a list of the available configurations, do:
<screen> <screen>

View file

@ -58,9 +58,9 @@ Jan 07 15:55:57 hagbard systemd[1]: Started PostgreSQL Server.
<para> <para>
Units can be stopped, started or restarted: Units can be stopped, started or restarted:
<screen> <screen>
# systemctl stop postgresql.service <prompt># </prompt>systemctl stop postgresql.service
# systemctl start postgresql.service <prompt># </prompt>systemctl start postgresql.service
# systemctl restart postgresql.service <prompt># </prompt>systemctl restart postgresql.service
</screen> </screen>
These operations are synchronous: they wait until the service has finished These operations are synchronous: they wait until the service has finished
starting or stopping (or has failed). Starting a unit will cause the starting or stopping (or has failed). Starting a unit will cause the

View file

@ -39,7 +39,7 @@ c3 - root (0)
can terminate a session in a way that ensures that all the sessions can terminate a session in a way that ensures that all the sessions
processes are gone: processes are gone:
<screen> <screen>
# loginctl terminate-session c3 <prompt># </prompt>loginctl terminate-session c3
</screen> </screen>
</para> </para>
</chapter> </chapter>

View file

@ -25,7 +25,7 @@ xlink:href="https://nixos.org/nixpkgs/manual">Nixpkgs
and you run <command>nixos-rebuild</command>, specifying your own Nixpkgs and you run <command>nixos-rebuild</command>, specifying your own Nixpkgs
tree: tree:
<screen> <screen>
# nixos-rebuild switch -I nixpkgs=/path/to/my/nixpkgs</screen> <prompt># </prompt>nixos-rebuild switch -I nixpkgs=/path/to/my/nixpkgs</screen>
</para> </para>
<para> <para>

View file

@ -126,13 +126,13 @@ nixpkgs.config.packageOverrides = pkgs:
<literal>mellanox</literal> drivers. <literal>mellanox</literal> drivers.
</para> </para>
<screen><![CDATA[ <screen>
$ nix-build '<nixpkgs>' -A linuxPackages.kernel.dev <prompt>$ </prompt>nix-build '&lt;nixpkgs>' -A linuxPackages.kernel.dev
$ nix-shell '<nixpkgs>' -A linuxPackages.kernel <prompt>$ </prompt>nix-shell '&lt;nixpkgs>' -A linuxPackages.kernel
$ unpackPhase <prompt>$ </prompt>unpackPhase
$ cd linux-* <prompt>$ </prompt>cd linux-*
$ make -C $dev/lib/modules/*/build M=$(pwd)/drivers/net/ethernet/mellanox modules <prompt>$ </prompt>make -C $dev/lib/modules/*/build M=$(pwd)/drivers/net/ethernet/mellanox modules
# insmod ./drivers/net/ethernet/mellanox/mlx5/core/mlx5_core.ko <prompt># </prompt>insmod ./drivers/net/ethernet/mellanox/mlx5/core/mlx5_core.ko
]]></screen> </screen>
</section> </section>
</chapter> </chapter>

View file

@ -11,7 +11,7 @@
you create an encrypted Ext4 file system on the device you create an encrypted Ext4 file system on the device
<filename>/dev/disk/by-uuid/3f6b0024-3a44-4fde-a43a-767b872abe5d</filename>: <filename>/dev/disk/by-uuid/3f6b0024-3a44-4fde-a43a-767b872abe5d</filename>:
<screen> <screen>
# cryptsetup luksFormat /dev/disk/by-uuid/3f6b0024-3a44-4fde-a43a-767b872abe5d <prompt># </prompt>cryptsetup luksFormat <replaceable>/dev/disk/by-uuid/3f6b0024-3a44-4fde-a43a-767b872abe5d</replaceable>
WARNING! WARNING!
======== ========
@ -21,17 +21,17 @@ Are you sure? (Type uppercase yes): YES
Enter LUKS passphrase: *** Enter LUKS passphrase: ***
Verify passphrase: *** Verify passphrase: ***
# cryptsetup luksOpen /dev/disk/by-uuid/3f6b0024-3a44-4fde-a43a-767b872abe5d crypted <prompt># </prompt>cryptsetup luksOpen <replaceable>/dev/disk/by-uuid/3f6b0024-3a44-4fde-a43a-767b872abe5d</replaceable> <replaceable>crypted</replaceable>
Enter passphrase for /dev/disk/by-uuid/3f6b0024-3a44-4fde-a43a-767b872abe5d: *** Enter passphrase for /dev/disk/by-uuid/3f6b0024-3a44-4fde-a43a-767b872abe5d: ***
# mkfs.ext4 /dev/mapper/crypted <prompt># </prompt>mkfs.ext4 /dev/mapper/<replaceable>crypted</replaceable>
</screen> </screen>
To ensure that this file system is automatically mounted at boot time as To ensure that this file system is automatically mounted at boot time as
<filename>/</filename>, add the following to <filename>/</filename>, add the following to
<filename>configuration.nix</filename>: <filename>configuration.nix</filename>:
<programlisting> <programlisting>
<link linkend="opt-boot.initrd.luks.devices._name_.device">boot.initrd.luks.devices.crypted.device</link> = "/dev/disk/by-uuid/3f6b0024-3a44-4fde-a43a-767b872abe5d"; <link linkend="opt-boot.initrd.luks.devices._name_.device">boot.initrd.luks.devices.crypted.device</link> = "<replaceable>/dev/disk/by-uuid/3f6b0024-3a44-4fde-a43a-767b872abe5d</replaceable>";
<xref linkend="opt-fileSystems"/>."/".device = "/dev/mapper/crypted"; <xref linkend="opt-fileSystems"/>."/".device = "/dev/mapper/<replaceable>crypted</replaceable>";
</programlisting> </programlisting>
Should grub be used as bootloader, and <filename>/boot</filename> is located Should grub be used as bootloader, and <filename>/boot</filename> is located
on an encrypted partition, it is necessary to add the following grub option: on an encrypted partition, it is necessary to add the following grub option:
@ -45,11 +45,11 @@ Enter passphrase for /dev/disk/by-uuid/3f6b0024-3a44-4fde-a43a-767b872abe5d: ***
and add it as a new key to our existing device <filename>/dev/sda2</filename>: and add it as a new key to our existing device <filename>/dev/sda2</filename>:
<screen> <screen>
# export FIDO2_LABEL="/dev/sda2 @ $HOSTNAME" <prompt># </prompt>export FIDO2_LABEL="<replaceable>/dev/sda2</replaceable> @ $HOSTNAME"
# fido2luks credential "$FIDO2_LABEL" <prompt># </prompt>fido2luks credential "$FIDO2_LABEL"
f1d00200108b9d6e849a8b388da457688e3dd653b4e53770012d8f28e5d3b269865038c346802f36f3da7278b13ad6a3bb6a1452e24ebeeaa24ba40eef559b1b287d2a2f80b7 f1d00200108b9d6e849a8b388da457688e3dd653b4e53770012d8f28e5d3b269865038c346802f36f3da7278b13ad6a3bb6a1452e24ebeeaa24ba40eef559b1b287d2a2f80b7
# fido2luks -i add-key /dev/sda2 f1d00200108b9d6e849a8b388da457688e3dd653b4e53770012d8f28e5d3b269865038c346802f36f3da7278b13ad6a3bb6a1452e24ebeeaa24ba40eef559b1b287d2a2f80b7 <prompt># </prompt>fido2luks -i add-key <replaceable>/dev/sda2</replaceable> <replaceable>f1d00200108b9d6e849a8b388da457688e3dd653b4e53770012d8f28e5d3b269865038c346802f36f3da7278b13ad6a3bb6a1452e24ebeeaa24ba40eef559b1b287d2a2f80b7</replaceable>
Password: Password:
Password (again): Password (again):
Old password: Old password:
@ -60,13 +60,13 @@ Added to key to device /dev/sda2, slot: 2
To ensure that this file system is decrypted using the FIDO2 compatible key, add the following to <filename>configuration.nix</filename>: To ensure that this file system is decrypted using the FIDO2 compatible key, add the following to <filename>configuration.nix</filename>:
<programlisting> <programlisting>
<link linkend="opt-boot.initrd.luks.fido2Support">boot.initrd.luks.fido2Support</link> = true; <link linkend="opt-boot.initrd.luks.fido2Support">boot.initrd.luks.fido2Support</link> = true;
<link linkend="opt-boot.initrd.luks.devices._name_.fido2.credential">boot.initrd.luks.devices."/dev/sda2".fido2.credential</link> = "f1d00200108b9d6e849a8b388da457688e3dd653b4e53770012d8f28e5d3b269865038c346802f36f3da7278b13ad6a3bb6a1452e24ebeeaa24ba40eef559b1b287d2a2f80b7"; <link linkend="opt-boot.initrd.luks.devices._name_.fido2.credential">boot.initrd.luks.devices."<replaceable>/dev/sda2</replaceable>".fido2.credential</link> = "<replaceable>f1d00200108b9d6e849a8b388da457688e3dd653b4e53770012d8f28e5d3b269865038c346802f36f3da7278b13ad6a3bb6a1452e24ebeeaa24ba40eef559b1b287d2a2f80b7</replaceable>";
</programlisting> </programlisting>
You can also use the FIDO2 passwordless setup, but for security reasons, you might want to enable it only when your device is PIN protected, such as <link xlink:href="https://trezor.io/">Trezor</link>. You can also use the FIDO2 passwordless setup, but for security reasons, you might want to enable it only when your device is PIN protected, such as <link xlink:href="https://trezor.io/">Trezor</link>.
<programlisting> <programlisting>
<link linkend="opt-boot.initrd.luks.devices._name_.fido2.passwordLess">boot.initrd.luks.devices."/dev/sda2".fido2.passwordLess</link> = true; <link linkend="opt-boot.initrd.luks.devices._name_.fido2.passwordLess">boot.initrd.luks.devices."<replaceable>/dev/sda2</replaceable>".fido2.passwordLess</link> = true;
</programlisting> </programlisting>
</para> </para>
</section> </section>

View file

@ -62,24 +62,24 @@ uid = 1000;
<command>useradd</command>, <command>groupmod</command> and so on. For <command>useradd</command>, <command>groupmod</command> and so on. For
instance, to create a user account named <literal>alice</literal>: instance, to create a user account named <literal>alice</literal>:
<screen> <screen>
# useradd -m alice</screen> <prompt># </prompt>useradd -m <replaceable>alice</replaceable></screen>
To make all nix tools available to this new user use `su - USER` which opens To make all nix tools available to this new user use `su - USER` which opens
a login shell (==shell that loads the profile) for given user. This will a login shell (==shell that loads the profile) for given user. This will
create the ~/.nix-defexpr symlink. So run: create the ~/.nix-defexpr symlink. So run:
<screen> <screen>
# su - alice -c "true"</screen> <prompt># </prompt>su - <replaceable>alice</replaceable> -c "true"</screen>
The flag <option>-m</option> causes the creation of a home directory for the The flag <option>-m</option> causes the creation of a home directory for the
new user, which is generally what you want. The user does not have an initial new user, which is generally what you want. The user does not have an initial
password and therefore cannot log in. A password can be set using the password and therefore cannot log in. A password can be set using the
<command>passwd</command> utility: <command>passwd</command> utility:
<screen> <screen>
# passwd alice <prompt># </prompt>passwd <replaceable>alice</replaceable>
Enter new UNIX password: *** Enter new UNIX password: ***
Retype new UNIX password: *** Retype new UNIX password: ***
</screen> </screen>
A user can be deleted using <command>userdel</command>: A user can be deleted using <command>userdel</command>:
<screen> <screen>
# userdel -r alice</screen> <prompt># </prompt>userdel -r <replaceable>alice</replaceable></screen>
The flag <option>-r</option> deletes the users home directory. Accounts The flag <option>-r</option> deletes the users home directory. Accounts
can be modified using <command>usermod</command>. Unix groups can be managed can be modified using <command>usermod</command>. Unix groups can be managed
using <command>groupadd</command>, <command>groupmod</command> and using <command>groupadd</command>, <command>groupmod</command> and

View file

@ -58,7 +58,7 @@
</programlisting> </programlisting>
The X server can then be started manually: The X server can then be started manually:
<screen> <screen>
# systemctl start display-manager.service <prompt># </prompt>systemctl start display-manager.service
</screen> </screen>
</para> </para>
<para> <para>

View file

@ -57,7 +57,7 @@
linkend="ch-configuration"/>. Changes to a module documentation linkend="ch-configuration"/>. Changes to a module documentation
have to be checked to not break building the NixOS manual: have to be checked to not break building the NixOS manual:
</para> </para>
<programlisting>$ nix-build nixos/release.nix -A manual</programlisting> <screen><prompt>$ </prompt>nix-build nixos/release.nix -A manual</screen>
</callout> </callout>
</calloutlist> </calloutlist>
</section> </section>

View file

@ -24,8 +24,8 @@
</para> </para>
<screen> <screen>
$ cd /path/to/nixpkgs/nixos/doc/manual <prompt>$ </prompt>cd /path/to/nixpkgs/nixos/doc/manual
$ make <prompt>$ </prompt>make
</screen> </screen>
<para> <para>

View file

@ -27,13 +27,13 @@ networking.proxy.noProxy = &quot;127.0.0.1,localhost,internal.domain&quot;;
Setup the proxy environment variables in the shell where you are running Setup the proxy environment variables in the shell where you are running
<literal>nixos-install</literal>. <literal>nixos-install</literal>.
</para> </para>
<programlisting> <screen>
# proxy_url=&quot;http://user:password@proxy:port/&quot; <prompt># </prompt>proxy_url=&quot;http://user:password@proxy:port/&quot;
# export http_proxy=&quot;$proxy_url&quot; <prompt># </prompt>export http_proxy=&quot;$proxy_url&quot;
# export HTTP_PROXY=&quot;$proxy_url&quot; <prompt># </prompt>export HTTP_PROXY=&quot;$proxy_url&quot;
# export https_proxy=&quot;$proxy_url&quot; <prompt># </prompt>export https_proxy=&quot;$proxy_url&quot;
# export HTTPS_PROXY=&quot;$proxy_url&quot; <prompt># </prompt>export HTTPS_PROXY=&quot;$proxy_url&quot;
</programlisting> </screen>
</listitem> </listitem>
</orderedlist> </orderedlist>

View file

@ -325,14 +325,14 @@ sudo /nix/var/nix/profiles/system/bin/switch-to-configuration boot
to boot on a USB rescue disk and do something along these lines: to boot on a USB rescue disk and do something along these lines:
</para> </para>
<screen> <screen>
# mkdir root <prompt># </prompt>mkdir root
# mount /dev/sdaX root <prompt># </prompt>mount /dev/sdaX root
# mkdir root/nixos-root <prompt># </prompt>mkdir root/nixos-root
# mv -v root/* root/nixos-root/ <prompt># </prompt>mv -v root/* root/nixos-root/
# mv -v root/nixos-root/old-root/* root/ <prompt># </prompt>mv -v root/nixos-root/old-root/* root/
# mv -v root/boot.bak root/boot # We had renamed this by hand earlier <prompt># </prompt>mv -v root/boot.bak root/boot # We had renamed this by hand earlier
# umount root <prompt># </prompt>umount root
# reboot</screen> <prompt># </prompt>reboot</screen>
<para> <para>
This may work as is or you might also need to reinstall the boot loader This may work as is or you might also need to reinstall the boot loader
</para> </para>

View file

@ -67,32 +67,32 @@
<literal>nixos-20.03</literal> channel. To see which NixOS channel youre <literal>nixos-20.03</literal> channel. To see which NixOS channel youre
subscribed to, run the following as root: subscribed to, run the following as root:
<screen> <screen>
# nix-channel --list | grep nixos <prompt># </prompt>nix-channel --list | grep nixos
nixos https://nixos.org/channels/nixos-unstable nixos https://nixos.org/channels/nixos-unstable
</screen> </screen>
To switch to a different NixOS channel, do To switch to a different NixOS channel, do
<screen> <screen>
# nix-channel --add https://nixos.org/channels/<replaceable>channel-name</replaceable> nixos <prompt># </prompt>nix-channel --add https://nixos.org/channels/<replaceable>channel-name</replaceable> nixos
</screen> </screen>
(Be sure to include the <literal>nixos</literal> parameter at the end.) For (Be sure to include the <literal>nixos</literal> parameter at the end.) For
instance, to use the NixOS 20.03 stable channel: instance, to use the NixOS 20.03 stable channel:
<screen> <screen>
# nix-channel --add https://nixos.org/channels/nixos-20.03 nixos <prompt># </prompt>nix-channel --add https://nixos.org/channels/nixos-20.03 nixos
</screen> </screen>
If you have a server, you may want to use the “small” channel instead: If you have a server, you may want to use the “small” channel instead:
<screen> <screen>
# nix-channel --add https://nixos.org/channels/nixos-20.03-small nixos <prompt># </prompt>nix-channel --add https://nixos.org/channels/nixos-20.03-small nixos
</screen> </screen>
And if you want to live on the bleeding edge: And if you want to live on the bleeding edge:
<screen> <screen>
# nix-channel --add https://nixos.org/channels/nixos-unstable nixos <prompt># </prompt>nix-channel --add https://nixos.org/channels/nixos-unstable nixos
</screen> </screen>
</para> </para>
<para> <para>
You can then upgrade NixOS to the latest version in your chosen channel by You can then upgrade NixOS to the latest version in your chosen channel by
running running
<screen> <screen>
# nixos-rebuild switch --upgrade <prompt># </prompt>nixos-rebuild switch --upgrade
</screen> </screen>
which is equivalent to the more verbose <literal>nix-channel --update nixos; which is equivalent to the more verbose <literal>nix-channel --update nixos;
nixos-rebuild switch</literal>. nixos-rebuild switch</literal>.

View file

@ -136,13 +136,13 @@
<filename>/mnt</filename>: <filename>/mnt</filename>:
</para> </para>
<screen> <screen>
# nixos-enter --root /mnt <prompt># </prompt>nixos-enter --root /mnt
</screen> </screen>
<para> <para>
Run a shell command: Run a shell command:
</para> </para>
<screen> <screen>
# nixos-enter -c 'ls -l /; cat /proc/mounts' <prompt># </prompt>nixos-enter -c 'ls -l /; cat /proc/mounts'
</screen> </screen>
<para> <para>
Run a non-shell command: Run a non-shell command:

View file

@ -33,7 +33,7 @@
<para> <para>
This command shows the version of the currently active NixOS configuration. This command shows the version of the currently active NixOS configuration.
For example: For example:
<screen>$ nixos-version <screen><prompt>$ </prompt>nixos-version
16.03.1011.6317da4 (Emu) 16.03.1011.6317da4 (Emu)
</screen> </screen>
The version consists of the following elements: The version consists of the following elements:
@ -111,7 +111,7 @@
<para> <para>
Show the full SHA1 hash of the Git commit from which this configuration Show the full SHA1 hash of the Git commit from which this configuration
was built, e.g. was built, e.g.
<screen>$ nixos-version --hash <screen><prompt>$ </prompt>nixos-version --hash
6317da40006f6bc2480c6781999c52d88dde2acf 6317da40006f6bc2480c6781999c52d88dde2acf
</screen> </screen>
</para> </para>

View file

@ -69,10 +69,10 @@
access this single repository. You need the output of the generate pub file. access this single repository. You need the output of the generate pub file.
</para> </para>
<para> <para>
<programlisting> <screen>
# sudo ssh-keygen -N '' -t ed25519 -f /run/keys/id_ed25519_my_borg_repo <prompt># </prompt>sudo ssh-keygen -N '' -t ed25519 -f /run/keys/id_ed25519_my_borg_repo
# cat /run/keys/id_ed25519_my_borg_repo <prompt># </prompt>cat /run/keys/id_ed25519_my_borg_repo
ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAID78zmOyA+5uPG4Ot0hfAy+sLDPU1L4AiIoRYEIVbbQ/ root@nixos</programlisting> ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAID78zmOyA+5uPG4Ot0hfAy+sLDPU1L4AiIoRYEIVbbQ/ root@nixos</screen>
</para> </para>
<para> <para>
Add the following snippet to your NixOS configuration: Add the following snippet to your NixOS configuration:

View file

@ -159,9 +159,9 @@ in
To switch to a specialised configuration To switch to a specialised configuration
(e.g. <literal>fewJobsManyCores</literal>) at runtime, run: (e.g. <literal>fewJobsManyCores</literal>) at runtime, run:
<programlisting> <screen>
# sudo /run/current-system/specialisation/fewJobsManyCores/bin/switch-to-configuration test <prompt># </prompt>sudo /run/current-system/specialisation/fewJobsManyCores/bin/switch-to-configuration test
</programlisting> </screen>
''; '';
type = types.attrsOf (types.submodule ( type = types.attrsOf (types.submodule (
{ ... }: { { ... }: {