diff options
Diffstat (limited to 'nixos')
36 files changed, 791 insertions, 142 deletions
diff --git a/nixos/doc/manual/Makefile b/nixos/doc/manual/Makefile new file mode 100644 index 000000000000..b15fbaa270fc --- /dev/null +++ b/nixos/doc/manual/Makefile @@ -0,0 +1,8 @@ +debug: + nix-shell --packages xmloscopy \ + --run 'xmloscopy --docbook5 ./manual.xml ./manual-combined.xml' + +generated: ./options-to-docbook.xsl + nix-build ../../release.nix \ + --attr manualGeneratedSources.x86_64-linux \ + --out-link ./generated diff --git a/nixos/doc/manual/configuration/configuration.xml b/nixos/doc/manual/configuration/configuration.xml index 8677c13db40f..f092c7e207ff 100644 --- a/nixos/doc/manual/configuration/configuration.xml +++ b/nixos/doc/manual/configuration/configuration.xml @@ -25,9 +25,8 @@ effect after you run <command>nixos-rebuild</command>.</para> <xi:include href="networking.xml" /> <xi:include href="linux-kernel.xml" /> -<xi:include href="modules.xml" xpointer="xpointer(//section[@id='modules']/*)" /> +<xi:include href="../generated/modules.xml" xpointer="xpointer(//section[@id='modules']/*)" /> <!-- Apache; libvirtd virtualisation --> </part> - diff --git a/nixos/doc/manual/configuration/summary.xml b/nixos/doc/manual/configuration/summary.xml index be1f2263149e..38032c5d9dc3 100644 --- a/nixos/doc/manual/configuration/summary.xml +++ b/nixos/doc/manual/configuration/summary.xml @@ -53,7 +53,7 @@ manual</link> for the rest.</para> </row> <row> <entry><literal>{ x = 1; y = 2; }</literal></entry> - <entry>An set with attributes names <literal>x</literal> and <literal>y</literal></entry> + <entry>A set with attributes named <literal>x</literal> and <literal>y</literal></entry> </row> <row> <entry><literal>{ foo.bar = 1; }</literal></entry> diff --git a/nixos/doc/manual/default.nix b/nixos/doc/manual/default.nix index ac22712baf87..2c6309474b37 100644 --- a/nixos/doc/manual/default.nix +++ b/nixos/doc/manual/default.nix @@ -102,13 +102,18 @@ let </section> ''; + generatedSources = runCommand "generated-docbook" {} '' + mkdir $out + ln -s ${modulesDoc} $out/modules.xml + ln -s ${optionsDocBook} $out/options-db.xml + printf "%s" "${version}" > $out/version + ''; + copySources = '' cp -prd $sources/* . # */ + ln -s ${generatedSources} ./generated chmod -R u+w . - ln -s ${modulesDoc} configuration/modules.xml - ln -s ${optionsDocBook} options-db.xml - printf "%s" "${version}" > version ''; toc = builtins.toFile "toc.xml" @@ -224,6 +229,7 @@ let ''; in rec { + inherit generatedSources; # The NixOS options in JSON format. optionsJSON = runCommand "options-json" diff --git a/nixos/doc/manual/development/importing-modules.xml b/nixos/doc/manual/development/importing-modules.xml new file mode 100644 index 000000000000..ec1da09b9507 --- /dev/null +++ b/nixos/doc/manual/development/importing-modules.xml @@ -0,0 +1,59 @@ +<section xmlns="http://docbook.org/ns/docbook" + xmlns:xlink="http://www.w3.org/1999/xlink" + xmlns:xi="http://www.w3.org/2001/XInclude" + version="5.0" + xml:id="sec-importing-modules"> + +<title>Importing Modules</title> + +<para> + Sometimes NixOS modules need to be used in configuration but exist + outside of Nixpkgs. These modules can be imported: +</para> + +<programlisting> +{ config, lib, pkgs, ... }: + +{ + imports = + [ # Use a locally-available module definition in + # ./example-module/default.nix + ./example-module + ]; + + services.exampleModule.enable = true; +} +</programlisting> + +<para> + The environment variable <literal>NIXOS_EXTRA_MODULE_PATH</literal> is + an absolute path to a NixOS module that is included alongside the + Nixpkgs NixOS modules. Like any NixOS module, this module can import + additional modules: +</para> + +<programlisting> +# ./module-list/default.nix +[ + ./example-module1 + ./example-module2 +] +</programlisting> + +<programlisting> +# ./extra-module/default.nix +{ imports = import ./module-list.nix; } +</programlisting> + +<programlisting> +# NIXOS_EXTRA_MODULE_PATH=/absolute/path/to/extra-module +{ config, lib, pkgs, ... }: + +{ + # No `imports` needed + + services.exampleModule1.enable = true; +} +</programlisting> + +</section> diff --git a/nixos/doc/manual/development/writing-documentation.xml b/nixos/doc/manual/development/writing-documentation.xml index 59a287717acb..8b787fae1fe0 100644 --- a/nixos/doc/manual/development/writing-documentation.xml +++ b/nixos/doc/manual/development/writing-documentation.xml @@ -18,13 +18,25 @@ <para> The DocBook sources of the <xref linkend="book-nixos-manual"/> are in the <link xlink:href="https://github.com/NixOS/nixpkgs/tree/master/nixos/doc/manual"><filename>nixos/doc/manual</filename></link> - subdirectory of the Nixpkgs repository. If you make modifications to - the manual, it's important to build it before committing. You can do - that as follows: + subdirectory of the Nixpkgs repository. +</para> - <screen>nix-build nixos/release.nix -A manual.x86_64-linux</screen> +<para> + You can quickly validate your edits with <command>make</command>: </para> +<screen> + $ cd /path/to/nixpkgs/nixos/doc/manual + $ make +</screen> + +<para> + Once you are done making modifications to the manual, it's important + to build it before committing. You can do that as follows: +</para> + +<screen>nix-build nixos/release.nix -A manual.x86_64-linux</screen> + <para> When this command successfully finishes, it will tell you where the manual got generated. The HTML will be accessible through the diff --git a/nixos/doc/manual/development/writing-modules.xml b/nixos/doc/manual/development/writing-modules.xml index cb363b45675b..a49f99cb2669 100644 --- a/nixos/doc/manual/development/writing-modules.xml +++ b/nixos/doc/manual/development/writing-modules.xml @@ -180,6 +180,7 @@ in { <xi:include href="option-def.xml" /> <xi:include href="assertions.xml" /> <xi:include href="meta-attributes.xml" /> +<xi:include href="importing-modules.xml" /> <xi:include href="replace-modules.xml" /> </chapter> diff --git a/nixos/doc/manual/man-configuration.xml b/nixos/doc/manual/man-configuration.xml index 05531b3909a3..37ffb9d648a9 100644 --- a/nixos/doc/manual/man-configuration.xml +++ b/nixos/doc/manual/man-configuration.xml @@ -31,7 +31,8 @@ therein.</para> <para>You can use the following options in <filename>configuration.nix</filename>.</para> -<xi:include href="options-db.xml" /> +<xi:include href="./generated/options-db.xml" + xpointer="configuration-variable-list" /> </refsection> diff --git a/nixos/doc/manual/manual.xml b/nixos/doc/manual/manual.xml index 9aa332f026da..676924e5c8b2 100644 --- a/nixos/doc/manual/manual.xml +++ b/nixos/doc/manual/manual.xml @@ -6,7 +6,7 @@ <info> <title>NixOS Manual</title> - <subtitle>Version <xi:include href="version" parse="text" /></subtitle> + <subtitle>Version <xi:include href="./generated/version" parse="text" /></subtitle> </info> <preface> @@ -39,7 +39,8 @@ <appendix xml:id="ch-options"> <title>Configuration Options</title> - <xi:include href="options-db.xml" /> + <xi:include href="./generated/options-db.xml" + xpointer="configuration-variable-list" /> </appendix> <xi:include href="release-notes/release-notes.xml" /> diff --git a/nixos/doc/manual/options-to-docbook.xsl b/nixos/doc/manual/options-to-docbook.xsl index 7b45b233ab2a..43a69806a2b0 100644 --- a/nixos/doc/manual/options-to-docbook.xsl +++ b/nixos/doc/manual/options-to-docbook.xsl @@ -15,9 +15,9 @@ <xsl:template match="/expr/list"> - - <variablelist> - + <appendix> + <title>Configuration Options</title> + <variablelist xml:id="configuration-variable-list"> <xsl:for-each select="attrs"> <xsl:variable name="id" select="concat('opt-', str:replace(str:replace(str:replace(str:replace(attr[@name = 'name']/string/@value, '*', '_'), '<', '_'), '>', '_'), '?', '_'))" /> <varlistentry> @@ -100,7 +100,7 @@ </xsl:for-each> </variablelist> - + </appendix> </xsl:template> diff --git a/nixos/doc/manual/release-notes/rl-1809.xml b/nixos/doc/manual/release-notes/rl-1809.xml index 61f9ec8ba995..ce06a23beba0 100644 --- a/nixos/doc/manual/release-notes/rl-1809.xml +++ b/nixos/doc/manual/release-notes/rl-1809.xml @@ -58,11 +58,25 @@ following incompatible changes:</para> <itemizedlist> <listitem> <para> + <literal>lib.strict</literal> is removed. Use <literal>builtins.seq</literal> instead. + </para> + </listitem> + <listitem> + <para> The <literal>clementine</literal> package points now to the free derivation. <literal>clementineFree</literal> is removed now and <literal>clementineUnfree</literal> points to the package which is bundled with the unfree <literal>libspotify</literal> package. </para> </listitem> + <listitem> + <para> + The <literal>netcat</literal> package is now taken directly from OpenBSD's + <literal>libressl</literal>, instead of relying on Debian's fork. The new + version should be very close to the old version, but there are some minor + differences. Importantly, flags like -b, -q, -C, and -Z are no longer + accepted by the nc command. + </para> + </listitem> </itemizedlist> </section> @@ -77,6 +91,51 @@ following incompatible changes:</para> <itemizedlist> <listitem> <para> + <literal>lib.attrNamesToStr</literal> has been deprecated. Use + more specific concatenation (<literal>lib.concat(Map)StringsSep</literal>) + instead. + </para> + </listitem> + <listitem> + <para> + <literal>lib.addErrorContextToAttrs</literal> has been deprecated. Use + <literal>builtins.addErrorContext</literal> directly. + </para> + </listitem> + <listitem> + <para> + <literal>lib.showVal</literal> has been deprecated. Use + <literal>lib.traceSeqN</literal> instead. + </para> + </listitem> + <listitem> + <para> + <literal>lib.traceXMLVal</literal> has been deprecated. Use + <literal>lib.traceValFn builtins.toXml</literal> instead. + </para> + </listitem> + <listitem> + <para> + <literal>lib.traceXMLValMarked</literal> has been deprecated. Use + <literal>lib.traceValFn (x: str + builtins.toXML x)</literal> instead. + </para> + </listitem> + <listitem> + <para> + <literal>lib.traceValIfNot</literal> has been deprecated. Use + <literal>if/then/else</literal> and <literal>lib.traceValSeq</literal> + instead. + </para> + </listitem> + <listitem> + <para> + <literal>lib.traceCallXml</literal> has been deprecated. Please complain + if you use the function regularly. + </para> + <para> + The attribute <literal>lib.nixpkgsVersion</literal> has been deprecated in favor of + <literal>lib.version</literal>. Please refer to the discussion in + <link xlink:href="https://github.com/NixOS/nixpkgs/pull/39416#discussion_r183845745">NixOS/nixpkgs#39416</link> for further reference. </para> </listitem> </itemizedlist> diff --git a/nixos/lib/test-driver/Machine.pm b/nixos/lib/test-driver/Machine.pm index 7e269b43e70f..b18f48464cee 100644 --- a/nixos/lib/test-driver/Machine.pm +++ b/nixos/lib/test-driver/Machine.pm @@ -33,9 +33,20 @@ sub new { $startCommand = "qemu-kvm -m 384 " . "-net nic,model=virtio \$QEMU_OPTS "; - my $iface = $args->{hdaInterface} || "virtio"; - $startCommand .= "-drive file=" . Cwd::abs_path($args->{hda}) . ",if=$iface,werror=report " - if defined $args->{hda}; + + if (defined $args->{hda}) { + if ($args->{hdaInterface} eq "scsi") { + $startCommand .= "-drive id=hda,file=" + . Cwd::abs_path($args->{hda}) + . ",werror=report,if=none " + . "-device scsi-hd,drive=hda "; + } else { + $startCommand .= "-drive file=" . Cwd::abs_path($args->{hda}) + . ",if=" . $args->{hdaInterface} + . ",werror=report "; + } + } + $startCommand .= "-cdrom $args->{cdrom} " if defined $args->{cdrom}; $startCommand .= "-device piix3-usb-uhci -drive id=usbdisk,file=$args->{usb},if=none,readonly -device usb-storage,drive=usbdisk " diff --git a/nixos/maintainers/scripts/ec2/create-amis.sh b/nixos/maintainers/scripts/ec2/create-amis.sh index 347e6b9c6e0d..9461144fad5a 100755 --- a/nixos/maintainers/scripts/ec2/create-amis.sh +++ b/nixos/maintainers/scripts/ec2/create-amis.sh @@ -6,7 +6,7 @@ set -e set -o pipefail -version=$(nix-instantiate --eval --strict '<nixpkgs>' -A lib.nixpkgsVersion | sed s/'"'//g) +version=$(nix-instantiate --eval --strict '<nixpkgs>' -A lib.version | sed s/'"'//g) major=${version:0:5} echo "NixOS version is $version ($major)" diff --git a/nixos/modules/installer/cd-dvd/iso-image.nix b/nixos/modules/installer/cd-dvd/iso-image.nix index 83f8a2586bd3..08923970cd38 100644 --- a/nixos/modules/installer/cd-dvd/iso-image.nix +++ b/nixos/modules/installer/cd-dvd/iso-image.nix @@ -73,7 +73,8 @@ let APPEND ${toString config.boot.loader.grub.memtest86.params} ''; - isolinuxCfg = baseIsolinuxCfg + (optionalString config.boot.loader.grub.memtest86.enable isolinuxMemtest86Entry); + isolinuxCfg = concatStringsSep "\n" + ([ baseIsolinuxCfg ] ++ optional config.boot.loader.grub.memtest86.enable isolinuxMemtest86Entry); # The EFI boot image. efiDir = pkgs.runCommand "efi-directory" {} '' diff --git a/nixos/modules/installer/tools/nixos-generate-config.pl b/nixos/modules/installer/tools/nixos-generate-config.pl index 14c611e18bc3..74b61a64667e 100644 --- a/nixos/modules/installer/tools/nixos-generate-config.pl +++ b/nixos/modules/installer/tools/nixos-generate-config.pl @@ -577,8 +577,8 @@ $bootLoaderConfig # Set your time zone. # time.timeZone = "Europe/Amsterdam"; - # List packages installed in system profile. To search by name, run: - # \$ nix-env -qaP | grep wget + # List packages installed in system profile. To search, run: + # \$ nix search wget # environment.systemPackages = with pkgs; [ # wget vim # ]; diff --git a/nixos/modules/misc/nixpkgs.nix b/nixos/modules/misc/nixpkgs.nix index b8a55a24394e..8fbe218b232a 100644 --- a/nixos/modules/misc/nixpkgs.nix +++ b/nixos/modules/misc/nixpkgs.nix @@ -33,7 +33,11 @@ let configType = mkOptionType { name = "nixpkgs-config"; description = "nixpkgs config"; - check = traceValIfNot isConfig; + check = x: + let traceXIfNot = c: + if c x then true + else lib.traceSeqN 1 x false; + in traceXIfNot isConfig; merge = args: fold (def: mergeConfig def.value) {}; }; diff --git a/nixos/modules/misc/version.nix b/nixos/modules/misc/version.nix index b8f0a223c910..74c86443ab90 100644 --- a/nixos/modules/misc/version.nix +++ b/nixos/modules/misc/version.nix @@ -5,8 +5,6 @@ with lib; let cfg = config.system.nixos; - releaseFile = "${toString pkgs.path}/.version"; - suffixFile = "${toString pkgs.path}/.version-suffix"; revisionFile = "${toString pkgs.path}/.git-revision"; gitRepo = "${toString pkgs.path}/.git"; gitCommitId = lib.substring 0 7 (commitIdFromGitRepo gitRepo); @@ -25,14 +23,14 @@ in nixos.release = mkOption { readOnly = true; type = types.str; - default = fileContents releaseFile; + default = trivial.release; description = "The NixOS release (e.g. <literal>16.03</literal>)."; }; nixos.versionSuffix = mkOption { internal = true; type = types.str; - default = if pathExists suffixFile then fileContents suffixFile else "pre-git"; + default = trivial.versionSuffix; description = "The NixOS version suffix (e.g. <literal>1160.f2d4ee1</literal>)."; }; diff --git a/nixos/modules/module-list.nix b/nixos/modules/module-list.nix index 8ef76b9d81ed..b0889e62f7c5 100644 --- a/nixos/modules/module-list.nix +++ b/nixos/modules/module-list.nix @@ -250,6 +250,7 @@ ./services/hardware/illum.nix ./services/hardware/interception-tools.nix ./services/hardware/irqbalance.nix + ./services/hardware/lcd.nix ./services/hardware/nvidia-optimus.nix ./services/hardware/pcscd.nix ./services/hardware/pommed.nix diff --git a/nixos/modules/services/audio/alsa.nix b/nixos/modules/services/audio/alsa.nix index e3e8bb28c58b..376aad66e236 100644 --- a/nixos/modules/services/audio/alsa.nix +++ b/nixos/modules/services/audio/alsa.nix @@ -54,6 +54,11 @@ in description = '' Whether to enable volume and capture control with keyboard media keys. + You want to leave this disabled if you run a desktop environment + like KDE, Gnome, Xfce, etc, as those handle such things themselves. + You might want to enable this if you run a minimalistic desktop + environment or work from bare linux ttys/framebuffers. + Enabling this will turn on <option>services.actkbd</option>. ''; }; diff --git a/nixos/modules/services/continuous-integration/buildkite-agent.nix b/nixos/modules/services/continuous-integration/buildkite-agent.nix index 03af9a7859ec..d647b7b9fa49 100644 --- a/nixos/modules/services/continuous-integration/buildkite-agent.nix +++ b/nixos/modules/services/continuous-integration/buildkite-agent.nix @@ -17,7 +17,7 @@ let hooksDir = let mkHookEntry = name: value: '' - cat > $out/${name} <<EOF + cat > $out/${name} <<'EOF' #! ${pkgs.runtimeShell} set -e ${value} diff --git a/nixos/modules/services/hardware/lcd.nix b/nixos/modules/services/hardware/lcd.nix new file mode 100644 index 000000000000..d78d742cd318 --- /dev/null +++ b/nixos/modules/services/hardware/lcd.nix @@ -0,0 +1,172 @@ +{ config, lib, pkgs, ... }: + +let + cfg = config.services.hardware.lcd; + pkg = lib.getBin pkgs.lcdproc; + + serverCfg = pkgs.writeText "lcdd.conf" '' + [server] + DriverPath=${pkg}/lib/lcdproc/ + ReportToSyslog=false + Bind=${cfg.serverHost} + Port=${toString cfg.serverPort} + ${cfg.server.extraConfig} + ''; + + clientCfg = pkgs.writeText "lcdproc.conf" '' + [lcdproc] + Server=${cfg.serverHost} + Port=${toString cfg.serverPort} + ReportToSyslog=false + ${cfg.client.extraConfig} + ''; + + serviceCfg = { + DynamicUser = true; + Restart = "on-failure"; + Slice = "lcd.slice"; + }; + +in with lib; { + + meta.maintainers = with maintainers; [ peterhoeg ]; + + options = with types; { + services.hardware.lcd = { + serverHost = mkOption { + type = str; + default = "localhost"; + description = "Host on which LCDd is listening."; + }; + + serverPort = mkOption { + type = int; + default = 13666; + description = "Port on which LCDd is listening."; + }; + + server = { + enable = mkOption { + type = bool; + default = false; + description = "Enable the LCD panel server (LCDd)"; + }; + + openPorts = mkOption { + type = bool; + default = false; + description = "Open the ports in the firewall"; + }; + + usbPermissions = mkOption { + type = bool; + default = false; + description = '' + Set group-write permissions on a USB device. + </para> + <para> + A USB connected LCD panel will most likely require having its + permissions modified for lcdd to write to it. Enabling this option + sets group-write permissions on the device identified by + <option>services.hardware.lcd.usbVid</option> and + <option>services.hardware.lcd.usbPid</option>. In order to find the + values, you can run the <command>lsusb</command> command. Example + output: + </para> + <para> + <literal> + Bus 005 Device 002: ID 0403:c630 Future Technology Devices International, Ltd lcd2usb interface + </literal> + </para> + <para> + In this case the vendor id is 0403 and the product id is c630. + ''; + }; + + usbVid = mkOption { + type = str; + default = ""; + description = "The vendor ID of the USB device to claim."; + }; + + usbPid = mkOption { + type = str; + default = ""; + description = "The product ID of the USB device to claim."; + }; + + usbGroup = mkOption { + type = str; + default = "dialout"; + description = "The group to use for settings permissions. This group must exist or you will have to create it."; + }; + + extraConfig = mkOption { + type = lines; + default = ""; + description = "Additional configuration added verbatim to the server config."; + }; + }; + + client = { + enable = mkOption { + type = bool; + default = false; + description = "Enable the LCD panel client (LCDproc)"; + }; + + extraConfig = mkOption { + type = lines; + default = ""; + description = "Additional configuration added verbatim to the client config."; + }; + + restartForever = mkOption { + type = bool; + default = true; + description = "Try restarting the client forever."; + }; + }; + }; + }; + + config = mkIf (cfg.server.enab |