git.iko.soy/typeable/nixpkgs
on master help sign in
nixpkgs docs: move fhs-environments to its own file
commit0856d5c4add0abe92c1a8d15f95003ce5a2b828d authorGraham Christensen <graham@grahamc.com> dateTue 2 Oct 2018, 14:08 (8 years ago) parent3ac79c8
2 files changed+145−141
doc/functions.xml+1−141 doc/functions/fhs-environments.xml+144
doc/functions.xml+1−141
@@ -11,147 +11,7 @@
1111 <xi:include href="functions/overrides.xml" />
1212 <xi:include href="functions/generators.xml" />
1313 <xi:include href="functions/debug.xml" />
14− <section xml:id="sec-fhs-environments">
15− <title>buildFHSUserEnv</title>
16−
17− <para>
18− <function>buildFHSUserEnv</function> provides a way to build and run
19− FHS-compatible lightweight sandboxes. It creates an isolated root with bound
20− <filename>/nix/store</filename>, so its footprint in terms of disk space
21− needed is quite small. This allows one to run software which is hard or
22− unfeasible to patch for NixOS -- 3rd-party source trees with FHS
23− assumptions, games distributed as tarballs, software with integrity checking
24− and/or external self-updated binaries. It uses Linux namespaces feature to
25− create temporary lightweight environments which are destroyed after all
26− child processes exit, without root user rights requirement. Accepted
27− arguments are:
28− </para>
29−
30− <variablelist>
31− <varlistentry>
32− <term>
33− <literal>name</literal>
34− </term>
35− <listitem>
36− <para>
37− Environment name.
38− </para>
39− </listitem>
40− </varlistentry>
41− <varlistentry>
42− <term>
43− <literal>targetPkgs</literal>
44− </term>
45− <listitem>
46− <para>
47− Packages to be installed for the main host's architecture (i.e. x86_64 on
48− x86_64 installations). Along with libraries binaries are also installed.
49− </para>
50− </listitem>
51− </varlistentry>
52− <varlistentry>
53− <term>
54− <literal>multiPkgs</literal>
55− </term>
56− <listitem>
57− <para>
58− Packages to be installed for all architectures supported by a host (i.e.
59− i686 and x86_64 on x86_64 installations). Only libraries are installed by
60− default.
61− </para>
62− </listitem>
63− </varlistentry>
64− <varlistentry>
65− <term>
66− <literal>extraBuildCommands</literal>
67− </term>
68− <listitem>
69− <para>
70− Additional commands to be executed for finalizing the directory
71− structure.
72− </para>
73− </listitem>
74− </varlistentry>
75− <varlistentry>
76− <term>
77− <literal>extraBuildCommandsMulti</literal>
78− </term>
79− <listitem>
80− <para>
81− Like <literal>extraBuildCommands</literal>, but executed only on multilib
82− architectures.
83− </para>
84− </listitem>
85− </varlistentry>
86− <varlistentry>
87− <term>
88− <literal>extraOutputsToInstall</literal>
89− </term>
90− <listitem>
91− <para>
92− Additional derivation outputs to be linked for both target and
93− multi-architecture packages.
94− </para>
95− </listitem>
96− </varlistentry>
97− <varlistentry>
98− <term>
99− <literal>extraInstallCommands</literal>
100− </term>
101− <listitem>
102− <para>
103− Additional commands to be executed for finalizing the derivation with
104− runner script.
105− </para>
106− </listitem>
107− </varlistentry>
108− <varlistentry>
109− <term>
110− <literal>runScript</literal>
111− </term>
112− <listitem>
113− <para>
114− A command that would be executed inside the sandbox and passed all the
115− command line arguments. It defaults to <literal>bash</literal>.
116− </para>
117− </listitem>
118− </varlistentry>
119− </variablelist>
120−
121− <para>
122− One can create a simple environment using a <literal>shell.nix</literal>
123− like that:
124− </para>
125−
126−<programlisting><![CDATA[
127−{ pkgs ? import <nixpkgs> {} }:
128−
129−(pkgs.buildFHSUserEnv {
130− name = "simple-x11-env";
131− targetPkgs = pkgs: (with pkgs;
132− [ udev
133− alsaLib
134− ]) ++ (with pkgs.xorg;
135− [ libX11
136− libXcursor
137− libXrandr
138− ]);
139− multiPkgs = pkgs: (with pkgs;
140− [ udev
141− alsaLib
142− ]);
143− runScript = "bash";
144−}).env
145−]]></programlisting>
146−
147− <para>
148− Running <literal>nix-shell</literal> would then drop you into a shell with
149− these libraries and binaries available. You can use this to run
150− closed-source applications which expect FHS structure without hassles:
151− simply change <literal>runScript</literal> to the application path, e.g.
152− <filename>./bin/start.sh</filename> -- relative paths are supported.
153− </para>
154− </section>
14+ <xi:include href="functions/fhs-environments.xml" />
15515 <xi:include href="shell.section.xml" />
15616 <section xml:id="sec-pkgs-dockerTools">
15717 <title>pkgs.dockerTools</title>
doc/functions/fhs-environments.xmlnew file+144
@@ -0,0 +1,144 @@
1+<section 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+ xml:id="sec-fhs-environments">
5+ <title>buildFHSUserEnv</title>
6+
7+ <para>
8+ <function>buildFHSUserEnv</function> provides a way to build and run
9+ FHS-compatible lightweight sandboxes. It creates an isolated root with bound
10+ <filename>/nix/store</filename>, so its footprint in terms of disk space
11+ needed is quite small. This allows one to run software which is hard or
12+ unfeasible to patch for NixOS -- 3rd-party source trees with FHS
13+ assumptions, games distributed as tarballs, software with integrity checking
14+ and/or external self-updated binaries. It uses Linux namespaces feature to
15+ create temporary lightweight environments which are destroyed after all
16+ child processes exit, without root user rights requirement. Accepted
17+ arguments are:
18+ </para>
19+
20+ <variablelist>
21+ <varlistentry>
22+ <term>
23+ <literal>name</literal>
24+ </term>
25+ <listitem>
26+ <para>
27+ Environment name.
28+ </para>
29+ </listitem>
30+ </varlistentry>
31+ <varlistentry>
32+ <term>
33+ <literal>targetPkgs</literal>
34+ </term>
35+ <listitem>
36+ <para>
37+ Packages to be installed for the main host's architecture (i.e. x86_64 on
38+ x86_64 installations). Along with libraries binaries are also installed.
39+ </para>
40+ </listitem>
41+ </varlistentry>
42+ <varlistentry>
43+ <term>
44+ <literal>multiPkgs</literal>
45+ </term>
46+ <listitem>
47+ <para>
48+ Packages to be installed for all architectures supported by a host (i.e.
49+ i686 and x86_64 on x86_64 installations). Only libraries are installed by
50+ default.
51+ </para>
52+ </listitem>
53+ </varlistentry>
54+ <varlistentry>
55+ <term>
56+ <literal>extraBuildCommands</literal>
57+ </term>
58+ <listitem>
59+ <para>
60+ Additional commands to be executed for finalizing the directory
61+ structure.
62+ </para>
63+ </listitem>
64+ </varlistentry>
65+ <varlistentry>
66+ <term>
67+ <literal>extraBuildCommandsMulti</literal>
68+ </term>
69+ <listitem>
70+ <para>
71+ Like <literal>extraBuildCommands</literal>, but executed only on multilib
72+ architectures.
73+ </para>
74+ </listitem>
75+ </varlistentry>
76+ <varlistentry>
77+ <term>
78+ <literal>extraOutputsToInstall</literal>
79+ </term>
80+ <listitem>
81+ <para>
82+ Additional derivation outputs to be linked for both target and
83+ multi-architecture packages.
84+ </para>
85+ </listitem>
86+ </varlistentry>
87+ <varlistentry>
88+ <term>
89+ <literal>extraInstallCommands</literal>
90+ </term>
91+ <listitem>
92+ <para>
93+ Additional commands to be executed for finalizing the derivation with
94+ runner script.
95+ </para>
96+ </listitem>
97+ </varlistentry>
98+ <varlistentry>
99+ <term>
100+ <literal>runScript</literal>
101+ </term>
102+ <listitem>
103+ <para>
104+ A command that would be executed inside the sandbox and passed all the
105+ command line arguments. It defaults to <literal>bash</literal>.
106+ </para>
107+ </listitem>
108+ </varlistentry>
109+ </variablelist>
110+
111+ <para>
112+ One can create a simple environment using a <literal>shell.nix</literal>
113+ like that:
114+ </para>
115+
116+<programlisting><![CDATA[
117+{ pkgs ? import <nixpkgs> {} }:
118+
119+(pkgs.buildFHSUserEnv {
120+ name = "simple-x11-env";
121+ targetPkgs = pkgs: (with pkgs;
122+ [ udev
123+ alsaLib
124+ ]) ++ (with pkgs.xorg;
125+ [ libX11
126+ libXcursor
127+ libXrandr
128+ ]);
129+ multiPkgs = pkgs: (with pkgs;
130+ [ udev
131+ alsaLib
132+ ]);
133+ runScript = "bash";
134+}).env
135+]]></programlisting>
136+
137+ <para>
138+ Running <literal>nix-shell</literal> would then drop you into a shell with
139+ these libraries and binaries available. You can use this to run
140+ closed-source applications which expect FHS structure without hassles:
141+ simply change <literal>runScript</literal> to the application path, e.g.
142+ <filename>./bin/start.sh</filename> -- relative paths are supported.
143+ </para>
144+ </section>