diff options
author | github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> | 2020-12-03 06:15:27 +0000 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-12-03 06:15:27 +0000 |
commit | 6f36a7f7c3405a7becdd6c8904afc8d8ae5035fb (patch) | |
tree | 12b31a5ac0404943a375ebe832a9c616e1c26772 /doc | |
parent | 58274c4f8d1deda9891c370273735987584c1615 (diff) | |
parent | 3a2e9d2ac7e826eacc1dd99f07f9b06242b04e14 (diff) |
Merge master into staging-next
Diffstat (limited to 'doc')
-rw-r--r-- | doc/builders/packages/index.xml | 4 | ||||
-rw-r--r-- | doc/builders/packages/linux.section.md | 41 | ||||
-rw-r--r-- | doc/builders/packages/linux.xml | 85 | ||||
-rw-r--r-- | doc/builders/packages/nginx.section.md | 11 | ||||
-rw-r--r-- | doc/builders/packages/nginx.xml | 25 | ||||
-rw-r--r-- | doc/languages-frameworks/index.xml | 2 | ||||
-rw-r--r-- | doc/languages-frameworks/texlive.section.md | 128 | ||||
-rw-r--r-- | doc/languages-frameworks/texlive.xml | 152 |
8 files changed, 183 insertions, 265 deletions
diff --git a/doc/builders/packages/index.xml b/doc/builders/packages/index.xml index ba59ceb016b6..baf9b8db01be 100644 --- a/doc/builders/packages/index.xml +++ b/doc/builders/packages/index.xml @@ -12,9 +12,9 @@ <xi:include href="emacs.section.xml" /> <xi:include href="ibus.xml" /> <xi:include href="kakoune.section.xml" /> - <xi:include href="linux.xml" /> + <xi:include href="linux.section.xml" /> <xi:include href="locales.xml" /> - <xi:include href="nginx.xml" /> + <xi:include href="nginx.section.xml" /> <xi:include href="opengl.section.xml" /> <xi:include href="shell-helpers.xml" /> <xi:include href="steam.xml" /> diff --git a/doc/builders/packages/linux.section.md b/doc/builders/packages/linux.section.md new file mode 100644 index 000000000000..1b8d6eda749d --- /dev/null +++ b/doc/builders/packages/linux.section.md @@ -0,0 +1,41 @@ +# Linux kernel {#sec-linux-kernel} + +The Nix expressions to build the Linux kernel are in [`pkgs/os-specific/linux/kernel`](https://github.com/NixOS/nixpkgs/blob/master/pkgs/os-specific/linux/kernel). + +The function that builds the kernel has an argument `kernelPatches` which should be a list of `{name, patch, extraConfig}` attribute sets, where `name` is the name of the patch (which is included in the kernel’s `meta.description` attribute), `patch` is the patch itself (possibly compressed), and `extraConfig` (optional) is a string specifying extra options to be concatenated to the kernel configuration file (`.config`). + +The kernel derivation exports an attribute `features` specifying whether optional functionality is or isn’t enabled. This is used in NixOS to implement kernel-specific behaviour. For instance, if the kernel has the `iwlwifi` feature (i.e. has built-in support for Intel wireless chipsets), then NixOS doesn’t have to build the external `iwlwifi` package: + +```nix +modulesTree = [kernel] + ++ pkgs.lib.optional (!kernel.features ? iwlwifi) kernelPackages.iwlwifi + ++ ...; +``` + +How to add a new (major) version of the Linux kernel to Nixpkgs: + +1. Copy the old Nix expression (e.g. `linux-2.6.21.nix`) to the new one (e.g. `linux-2.6.22.nix`) and update it. + +2. Add the new kernel to `all-packages.nix` (e.g., create an attribute `kernel_2_6_22`). + +3. Now we’re going to update the kernel configuration. First unpack the kernel. Then for each supported platform (`i686`, `x86_64`, `uml`) do the following: + + 1. Make an copy from the old config (e.g. `config-2.6.21-i686-smp`) to the new one (e.g. `config-2.6.22-i686-smp`). + + 2. Copy the config file for this platform (e.g. `config-2.6.22-i686-smp`) to `.config` in the kernel source tree. + + 3. Run `make oldconfig ARCH={i386,x86_64,um}` and answer all questions. (For the uml configuration, also add `SHELL=bash`.) Make sure to keep the configuration consistent between platforms (i.e. don’t enable some feature on `i686` and disable it on `x86_64`). + + 4. If needed you can also run `make menuconfig`: + + ```ShellSession + $ nix-env -i ncurses + $ export NIX_CFLAGS_LINK=-lncurses + $ make menuconfig ARCH=arch + ``` + + 5. Copy `.config` over the new config file (e.g. `config-2.6.22-i686-smp`). + +4. Test building the kernel: `nix-build -A kernel_2_6_22`. If it compiles, ship it! For extra credit, try booting NixOS with it. + +5. It may be that the new kernel requires updating the external kernel modules and kernel-dependent packages listed in the `linuxPackagesFor` function in `all-packages.nix` (such as the NVIDIA drivers, AUFS, etc.). If the updated packages aren’t backwards compatible with older kernels, you may need to keep the older versions around. diff --git a/doc/builders/packages/linux.xml b/doc/builders/packages/linux.xml deleted file mode 100644 index 72d0e21493b3..000000000000 --- a/doc/builders/packages/linux.xml +++ /dev/null @@ -1,85 +0,0 @@ -<section xmlns="http://docbook.org/ns/docbook" - xmlns:xlink="http://www.w3.org/1999/xlink" - xml:id="sec-linux-kernel"> - <title>Linux kernel</title> - - <para> - The Nix expressions to build the Linux kernel are in <link -xlink:href="https://github.com/NixOS/nixpkgs/blob/master/pkgs/os-specific/linux/kernel"><filename>pkgs/os-specific/linux/kernel</filename></link>. - </para> - - <para> - The function that builds the kernel has an argument <varname>kernelPatches</varname> which should be a list of <literal>{name, patch, extraConfig}</literal> attribute sets, where <varname>name</varname> is the name of the patch (which is included in the kernel’s <varname>meta.description</varname> attribute), <varname>patch</varname> is the patch itself (possibly compressed), and <varname>extraConfig</varname> (optional) is a string specifying extra options to be concatenated to the kernel configuration file (<filename>.config</filename>). - </para> - - <para> - The kernel derivation exports an attribute <varname>features</varname> specifying whether optional functionality is or isn’t enabled. This is used in NixOS to implement kernel-specific behaviour. For instance, if the kernel has the <varname>iwlwifi</varname> feature (i.e. has built-in support for Intel wireless chipsets), then NixOS doesn’t have to build the external <varname>iwlwifi</varname> package: -<programlisting> -modulesTree = [kernel] - ++ pkgs.lib.optional (!kernel.features ? iwlwifi) kernelPackages.iwlwifi - ++ ...; -</programlisting> - </para> - - <para> - How to add a new (major) version of the Linux kernel to Nixpkgs: - <orderedlist> - <listitem> - <para> - Copy the old Nix expression (e.g. <filename>linux-2.6.21.nix</filename>) to the new one (e.g. <filename>linux-2.6.22.nix</filename>) and update it. - </para> - </listitem> - <listitem> - <para> - Add the new kernel to <filename>all-packages.nix</filename> (e.g., create an attribute <varname>kernel_2_6_22</varname>). - </para> - </listitem> - <listitem> - <para> - Now we’re going to update the kernel configuration. First unpack the kernel. Then for each supported platform (<literal>i686</literal>, <literal>x86_64</literal>, <literal>uml</literal>) do the following: - <orderedlist> - <listitem> - <para> - Make an copy from the old config (e.g. <filename>config-2.6.21-i686-smp</filename>) to the new one (e.g. <filename>config-2.6.22-i686-smp</filename>). - </para> - </listitem> - <listitem> - <para> - Copy the config file for this platform (e.g. <filename>config-2.6.22-i686-smp</filename>) to <filename>.config</filename> in the kernel source tree. - </para> - </listitem> - <listitem> - <para> - Run <literal>make oldconfig ARCH=<replaceable>{i386,x86_64,um}</replaceable></literal> and answer all questions. (For the uml configuration, also add <literal>SHELL=bash</literal>.) Make sure to keep the configuration consistent between platforms (i.e. don’t enable some feature on <literal>i686</literal> and disable it on <literal>x86_64</literal>). - </para> - </listitem> - <listitem> - <para> - If needed you can also run <literal>make menuconfig</literal>: -<screen> -<prompt>$ </prompt>nix-env -i ncurses -<prompt>$ </prompt>export NIX_CFLAGS_LINK=-lncurses -<prompt>$ </prompt>make menuconfig ARCH=<replaceable>arch</replaceable></screen> - </para> - </listitem> - <listitem> - <para> - Copy <filename>.config</filename> over the new config file (e.g. <filename>config-2.6.22-i686-smp</filename>). - </para> - </listitem> - </orderedlist> - </para> - </listitem> - <listitem> - <para> - Test building the kernel: <literal>nix-build -A kernel_2_6_22</literal>. If it compiles, ship it! For extra credit, try booting NixOS with it. - </para> - </listitem> - <listitem> - <para> - It may be that the new kernel requires updating the external kernel modules and kernel-dependent packages listed in the <varname>linuxPackagesFor</varname> function in <filename>all-packages.nix</filename> (such as the NVIDIA drivers, AUFS, etc.). If the updated packages aren’t backwards compatible with older kernels, you may need to keep the older versions around. - </para> - </listitem> - </orderedlist> - </para> -</section> diff --git a/doc/builders/packages/nginx.section.md b/doc/builders/packages/nginx.section.md new file mode 100644 index 000000000000..154c21f9b369 --- /dev/null +++ b/doc/builders/packages/nginx.section.md @@ -0,0 +1,11 @@ +# Nginx {#sec-nginx} + +[Nginx](https://nginx.org) is a reverse proxy and lightweight webserver. + +## ETags on static files served from the Nix store {#sec-nginx-etag} + +HTTP has a couple different mechanisms for caching to prevent clients from having to download the same content repeatedly if a resource has not changed since the last time it was requested. When nginx is used as a server for static files, it implements the caching mechanism based on the [`Last-Modified`](https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Last-Modified) response header automatically; unfortunately, it works by using filesystem timestamps to determine the value of the `Last-Modified` header. This doesn't give the desired behavior when the file is in the Nix store, because all file timestamps are set to 0 (for reasons related to build reproducibility). + +Fortunately, HTTP supports an alternative (and more effective) caching mechanism: the [`ETag`](https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/ETag) response header. The value of the `ETag` header specifies some identifier for the particular content that the server is sending (e.g. a hash). When a client makes a second request for the same resource, it sends that value back in an `If-None-Match` header. If the ETag value is unchanged, then the server does not need to resend the content. + +As of NixOS 19.09, the nginx package in Nixpkgs is patched such that when nginx serves a file out of `/nix/store`, the hash in the store path is used as the `ETag` header in the HTTP response, thus providing proper caching functionality. This happens automatically; you do not need to do modify any configuration to get this behavior. diff --git a/doc/builders/packages/nginx.xml b/doc/builders/packages/nginx.xml deleted file mode 100644 index 65854ba02366..000000000000 --- a/doc/builders/packages/nginx.xml +++ /dev/null @@ -1,25 +0,0 @@ -<section xmlns="http://docbook.org/ns/docbook" - xmlns:xlink="http://www.w3.org/1999/xlink" - xml:id="sec-nginx"> - <title>Nginx</title> - - <para> - <link xlink:href="https://nginx.org/">Nginx</link> is a reverse proxy and lightweight webserver. - </para> - - <section xml:id="sec-nginx-etag"> - <title>ETags on static files served from the Nix store</title> - - <para> - HTTP has a couple different mechanisms for caching to prevent clients from having to download the same content repeatedly if a resource has not changed since the last time it was requested. When nginx is used as a server for static files, it implements the caching mechanism based on the <link xlink:href="https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Last-Modified"><literal>Last-Modified</literal></link> response header automatically; unfortunately, it works by using filesystem timestamps to determine the value of the <literal>Last-Modified</literal> header. This doesn't give the desired behavior when the file is in the Nix store, because all file timestamps are set to 0 (for reasons related to build reproducibility). - </para> - - <para> - Fortunately, HTTP supports an alternative (and more effective) caching mechanism: the <link xlink:href="https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/ETag"><literal>ETag</literal></link> response header. The value of the <literal>ETag</literal> header specifies some identifier for the particular content that the server is sending (e.g. a hash). When a client makes a second request for the same resource, it sends that value back in an <literal>If-None-Match</literal> header. If the ETag value is unchanged, then the server does not need to resend the content. - </para> - - <para> - As of NixOS 19.09, the nginx package in Nixpkgs is patched such that when nginx serves a file out of <filename>/nix/store</filename>, the hash in the store path is used as the <literal>ETag</literal> header in the HTTP response, thus providing proper caching functionality. This happens automatically; you do not need to do modify any configuration to get this behavior. - </para> - </section> -</section> diff --git a/doc/languages-frameworks/index.xml b/doc/languages-frameworks/index.xml index c302b67cfd54..5046ce00b9a9 100644 --- a/doc/languages-frameworks/index.xml +++ b/doc/languages-frameworks/index.xml @@ -29,7 +29,7 @@ <xi:include href="r.section.xml" /> <xi:include href="ruby.section.xml" /> <xi:include href="rust.section.xml" /> - <xi:include href="texlive.xml" /> + <xi:include href="texlive.section.xml" /> <xi:include href="titanium.section.xml" /> <xi:include href="vim.section.xml" /> </chapter> diff --git a/doc/languages-frameworks/texlive.section.md b/doc/languages-frameworks/texlive.section.md new file mode 100644 index 000000000000..9584c56bb52f --- /dev/null +++ b/doc/languages-frameworks/texlive.section.md @@ -0,0 +1,128 @@ + +# TeX Live {#sec-language-texlive} + +Since release 15.09 there is a new TeX Live packaging that lives entirely under attribute `texlive`. + +## User's guide {#sec-language-texlive-user-guide} + +- For basic usage just pull `texlive.combined.scheme-basic` for an environment with basic LaTeX support. +- It typically won't work to use separately installed packages together. Instead, you can build a custom set of packages like this: + + ```nix + texlive.combine { + inherit (texlive) scheme-small collection-langkorean algorithms cm-super; + } + ``` + +- There are all the schemes, collections and a few thousand packages, as defined upstream (perhaps with tiny differences). +- By default you only get executables and files needed during runtime, and a little documentation for the core packages. To change that, you need to add `pkgFilter` function to `combine`. + + ```nix + texlive.combine { + # inherit (texlive) whatever-you-want; + pkgFilter = pkg: + pkg.tlType == "run" || pkg.tlType == "bin" || pkg.pname == "cm-super"; + # elem tlType [ "run" "bin" "doc" "source" ] + # there are also other attributes: version, name + } + ``` + +- You can list packages e.g. by `nix repl`. + + ```ShellSession + $ nix repl + nix-repl> :l <nixpkgs> + nix-repl> texlive.collection-[TAB] + ``` + +- Note that the wrapper assumes that the result has a chance to be useful. For example, the core executables should be present, as well as some core data files. The supported way of ensuring this is by including some scheme, for example `scheme-basic`, into the combination. + +## Custom packages {#sec-language-texlive-custom-packages} + + +You may find that you need to use an external TeX package. A derivation for such package has to provide contents of the "texmf" directory in its output and provide the `tlType` attribute. Here is a (very verbose) example: + +```nix +with import <nixpkgs> {}; + +let + foiltex_run = stdenvNoCC.mkDerivation { + pname = "latex-foiltex"; + version = "2.1.4b"; + passthru.tlType = "run"; + + srcs = [ + (fetchurl { + url = "http://mirrors.ctan.org/macros/latex/contrib/foiltex/foiltex.dtx"; + sha256 = "07frz0krpz7kkcwlayrwrj2a2pixmv0icbngyw92srp9fp23cqpz"; + }) + (fetchurl { + url = "http://mirrors.ctan.org/macros/latex/contrib/foiltex/foiltex.ins"; + sha256 = "09wkyidxk3n3zvqxfs61wlypmbhi1pxmjdi1kns9n2ky8ykbff99"; + }) + ]; + + unpackPhase = '' + runHook preUnpack + + for _src in $srcs; do + cp "$_src" $(stripHash "$_src") + done + + runHook postUnpack + ''; + + nativeBuildInputs = [ texlive.combined.scheme-small ]; + + dontConfigure = true; + + buildPhase = '' + runHook preBuild + + # Generate the style files + latex foiltex.ins + + runHook postBuild + ''; + + installPhase = '' + runHook preInstall + + path="$out/tex/latex/foiltex" + mkdir -p "$path" + cp *.{cls,def,clo} "$path/" + + runHook postInstall + ''; + + meta = with lib; { + description = "A LaTeX2e class for overhead transparencies"; + license = licenses.unfreeRedistributable; + maintainers = with maintainers; [ veprbl ]; + platforms = platforms.all; + }; + }; + foiltex = { pkgs = [ foiltex_run ]; }; + + latex_with_foiltex = texlive.combine { + inherit (texlive) scheme-small; + inherit foiltex; + }; +in + runCommand "test.pdf" { + nativeBuildInputs = [ latex_with_foiltex ]; + } '' +cat >test.tex <<EOF +\documentclass{foils} + +\title{Presentation title} +\date{} + +\begin{document} +\maketitle +\end{document} +EOF + pdflatex test.tex + cp test.pdf $out +'' +``` diff --git a/doc/languages-frameworks/texlive.xml b/doc/languages-frameworks/texlive.xml deleted file mode 100644 index 141c46e5a623..000000000000 --- a/doc/languages-frameworks/texlive.xml +++ /dev/null @@ -1,152 +0,0 @@ -<section xmlns="http://docbook.org/ns/docbook" - xmlns:xlink="http://www.w3.org/1999/xlink" - xml:id="sec-language-texlive"> - <title>TeX Live</title> - - <para> - Since release 15.09 there is a new TeX Live packaging that lives entirely under attribute <varname>texlive</varname>. - </para> - - <section xml:id="sec-language-texlive-users-guide"> - <title>User's guide</title> - - <itemizedlist> - <listitem> - <para> - For basic usage just pull <varname>texlive.combined.scheme-basic</varname> for an environment with basic LaTeX support. - </para> - </listitem> - <listitem> - <para> - It typically won't work to use separately installed packages together. Instead, you can build a custom set of packages like this: -<programlisting> -texlive.combine { - inherit (texlive) scheme-small collection-langkorean algorithms cm-super; -} -</programlisting> - There are all the schemes, collections and a few thousand packages, as defined upstream (perhaps with tiny differences). - </para> - </listitem> - <listitem> - <para> - By default you only get executables and files needed during runtime, and a little documentation for the core packages. To change that, you need to add <varname>pkgFilter</varname> function to <varname>combine</varname>. -<programlisting> -texlive.combine { - # inherit (texlive) whatever-you-want; - pkgFilter = pkg: - pkg.tlType == "run" || pkg.tlType == "bin" || pkg.pname == "cm-super"; - # elem tlType [ "run" "bin" "doc" "source" ] - # there are also other attributes: version, name -} -</programlisting> - </para> - </listitem> - <listitem> - <para> - You can list packages e.g. by <command>nix repl</command>. -<programlisting> -<prompt>$ </prompt>nix repl -<prompt>nix-repl> </prompt>:l <nixpkgs> -<prompt>nix-repl> </prompt>texlive.collection-<keycap function="tab" /> -</programlisting> - </para> - </listitem> - <listitem> - <para> - Note that the wrapper assumes that the result has a chance to be useful. For example, the core executables should be present, as well as some core data files. The supported way of ensuring this is by including some scheme, for example <varname>scheme-basic</varname>, into the combination. - </para> - </listitem> - </itemizedlist> - </section> - - <section xml:id="sec-language-texlive-custom-packages"> - <title>Custom packages</title> - <para> - You may find that you need to use an external TeX package. A derivation for such package has to provide contents of the "texmf" directory in its output and provide the <varname>tlType</varname> attribute. Here is a (very verbose) example: -<programlisting><![CDATA[ -with import <nixpkgs> {}; - -let - foiltex_run = stdenvNoCC.mkDerivation { - pname = "latex-foiltex"; - version = "2.1.4b"; - passthru.tlType = "run"; - - srcs = [ - (fetchurl { - url = "http://mirrors.ctan.org/macros/latex/contrib/foiltex/foiltex.dtx"; - sha256 = "07frz0krpz7kkcwlayrwrj2a2pixmv0icbngyw92srp9fp23cqpz"; - }) - (fetchurl { - url = "http://mirrors.ctan.org/macros/latex/contrib/foiltex/foiltex.ins"; - sha256 = "09wkyidxk3n3zvqxfs61wlypmbhi1pxmjdi1kns9n2ky8ykbff99"; - }) - ]; - - unpackPhase = '' - runHook preUnpack - - for _src in $srcs; do - cp "$_src" $(stripHash "$_src") - done - - runHook postUnpack - ''; - - nativeBuildInputs = [ texlive.combined.scheme-small ]; - - dontConfigure = true; - - buildPhase = '' - runHook preBuild - - # Generate the style files - latex foiltex.ins - - runHook postBuild - ''; - - installPhase = '' - runHook preInstall - - path="$out/tex/latex/foiltex" - mkdir -p "$path" - cp *.{cls,def,clo} "$path/" - - runHook postInstall - ''; - - meta = with lib; { - description = "A LaTeX2e class for overhead transparencies"; - license = licenses.unfreeRedistributable; - maintainers = with maintainers; [ veprbl ]; - platforms = platforms.all; - }; - }; - foiltex = { pkgs = [ foiltex_run ]; }; - - latex_with_foiltex = texlive.combine { - inherit (texlive) scheme-small; - inherit foiltex; - }; -in - runCommand "test.pdf" { - nativeBuildInputs = [ latex_with_foiltex ]; - } '' -cat >test.tex <<EOF -\documentclass{foils} - -\title{Presentation title} -\date{} - -\begin{document} -\maketitle -\end{document} -EOF - pdflatex test.tex - cp test.pdf $out -'' -]]></programlisting> - </para> - </section> -</section> |