lol

Merge pull request #248701 from doronbehar/nixos/manpages

nixos/install-tools: Add manpages to packages instead of seperating them

authored by

Doron Behar and committed by
GitHub
62730f2c af13ed44

+128 -78
+82 -9
nixos/doc/manual/contributing-to-this-manual.chapter.md
··· 7 7 8 8 ```ShellSession 9 9 $ cd /path/to/nixpkgs 10 + $ $EDITOR doc/nixos/manual/... # edit the manual 10 11 $ nix-build nixos/release.nix -A manual.x86_64-linux 11 12 ``` 12 13 ··· 14 15 15 16 There's also [a convenient development daemon](https://nixos.org/manual/nixpkgs/unstable/#sec-contributing-devmode). 16 17 17 - **Contributing to the man pages** 18 + The above instructions don't deal with the appendix of available `configuration.nix` options, and the manual pages related to NixOS. These are built, and written in a different location and in a different format, as explained in the next sections. 19 + 20 + ## Contributing to the `configuration.nix` options documentation {#sec-contributing-options} 21 + 22 + The documentation for all the different `configuration.nix` options is automatically generated by reading the `description`s of all the NixOS options defined at `nixos/modules/`. If you want to improve such `description`, find it in the `nixos/modules/` directory, and edit it and open a pull request. 23 + 24 + To see how your changes render on the web, run again: 25 + 26 + ```ShellSession 27 + $ nix-build nixos/release.nix -A manual.x86_64-linux 28 + ``` 18 29 19 - The man pages are written in [DocBook] which is XML. 30 + And you'll see the changes to the appendix in the path `result/share/doc/nixos/options.html`. 20 31 21 - To see what your edits look like: 32 + You can also build only the `configuration.nix(5)` manual page, via: 22 33 23 34 ```ShellSession 24 35 $ cd /path/to/nixpkgs 25 - $ nix-build nixos/release.nix -A manpages.x86_64-linux 36 + $ nix-build nixos/release.nix -A nixos-configuration-reference-manpage.x86_64-linux 26 37 ``` 27 38 28 - You can then read the man page you edited by running 39 + And observe the result via: 29 40 30 41 ```ShellSession 31 - $ man --manpath=result/share/man nixos-rebuild # Replace nixos-rebuild with the command whose manual you edited 42 + $ man --local-file result/share/man/man5/configuration.nix.5 43 + ``` 44 + 45 + If you're on a different architecture that's supported by NixOS (check file `nixos/release.nix` on Nixpkgs' repository) then replace `x86_64-linux` with the architecture. `nix-build` will complain otherwise, but should also tell you which architecture you have + the supported ones. 46 + 47 + ## Contributing to `nixos-*` tools' manpages {#sec-contributing-nixos-tools} 48 + 49 + The manual pages for the tools available in the installation image can be found in Nixpkgs by running (e.g for `nixos-rebuild`): 50 + 51 + ```ShellSession 52 + $ git ls | grep nixos-rebuild.8 53 + ``` 54 + 55 + Man pages are written in [`mdoc(7)` format](https://mandoc.bsd.lv/man/mdoc.7.html) and should be portable between mandoc and groff for rendering (except for minor differences, notably different spacing rules.) 56 + 57 + For a preview, run `man --local-file path/to/file.8`. 58 + 59 + Being written in `mdoc`, these manpages use semantic markup. This following subsections provides a guideline on where to apply which semantic elements. 60 + 61 + ### Command lines and arguments {#ssec-contributing-nixos-tools-cli-and-args} 62 + 63 + In any manpage, commands, flags and arguments to the *current* executable should be marked according to their semantics. Commands, flags and arguments passed to *other* executables should not be marked like this and should instead be considered as code examples and marked with `Ql`. 64 + 65 + - Use `Fl` to mark flag arguments, `Ar` for their arguments. 66 + - Repeating arguments should be marked by adding an ellipsis (spelled with periods, `...`). 67 + - Use `Cm` to mark literal string arguments, e.g. the `boot` command argument passed to `nixos-rebuild`. 68 + - Optional flags or arguments should be marked with `Op`. This includes optional repeating arguments. 69 + - Required flags or arguments should not be marked. 70 + - Mutually exclusive groups of arguments should be enclosed in curly brackets, preferably created with `Bro`/`Brc` blocks. 71 + 72 + When an argument is used in an example it should be marked up with `Ar` again to differentiate it from a constant. For example, a command with a `--host name` option that calls ssh to retrieve the host's local time would signify this thusly: 73 + ``` 74 + This will run 75 + .Ic ssh Ar name Ic time 76 + to retrieve the remote time. 77 + ``` 78 + 79 + ### Paths, NixOS options, environment variables {#ssec-contributing-nixos-tools-options-and-environment} 80 + 81 + Constant paths should be marked with `Pa`, NixOS options with `Va`, and environment variables with `Ev`. 82 + 83 + Generated paths, e.g. `result/bin/run-hostname-vm` (where `hostname` is a variable or arguments) should be marked as `Ql` inline literals with their variable components marked appropriately. 84 + 85 + - When `hostname` refers to an argument, it becomes `.Ql result/bin/run- Ns Ar hostname Ns -vm` 86 + - When `hostname` refers to a variable, it becomes `.Ql result/bin/run- Ns Va hostname Ns -vm` 87 + 88 + ### Code examples and other commands {#ssec-contributing-nixos-tools-code-examples} 89 + 90 + In free text names and complete invocations of other commands (e.g. `ssh` or `tar -xvf src.tar`) should be marked with `Ic`, fragments of command lines should be marked with `Ql`. 91 + 92 + Larger code blocks or those that cannot be shown inline should use indented literal display block markup for their contents, i.e. 93 + 94 + ``` 95 + .Bd -literal -offset indent 96 + ... 97 + .Ed 32 98 ``` 33 99 34 - If you're on a different architecture that's supported by NixOS (check nixos/release.nix) then replace `x86_64-linux` with the architecture. 35 - `nix-build` will complain otherwise, but should also tell you which architecture you have + the supported ones. 100 + Contents of code blocks may be marked up further, e.g. if they refer to arguments that will be substituted into them: 36 101 37 - [DocBook]: https://en.wikipedia.org/wiki/DocBook 102 + ``` 103 + .Bd -literal -offset indent 104 + { 105 + config.networking.hostname = "\c 106 + .Ar hostname Ns \c 107 + "; 108 + } 109 + .Ed 110 + ```
+2 -4
nixos/doc/manual/default.nix
··· 184 184 ''; 185 185 186 186 187 - # Generate the NixOS manpages. 188 - manpages = runCommand "nixos-manpages" 187 + # Generate the `man configuration.nix` package 188 + nixos-configuration-reference-manpage = runCommand "nixos-configuration-reference-manpage" 189 189 { nativeBuildInputs = [ 190 190 buildPackages.installShellFiles 191 191 buildPackages.nixos-render-docs ··· 194 194 } 195 195 '' 196 196 # Generate manpages. 197 - mkdir -p $out/share/man/man8 198 - installManPage ${./manpages}/* 199 197 mkdir -p $out/share/man/man5 200 198 nixos-render-docs -j $NIX_BUILD_CORES options manpage \ 201 199 --revision ${lib.escapeShellArg revision} \
-57
nixos/doc/manual/manpages/README.md
··· 1 - # NixOS manpages 2 - 3 - This is the collection of NixOS manpages, excluding `configuration.nix(5)`. 4 - 5 - Man pages are written in [`mdoc(7)` format](https://mandoc.bsd.lv/man/mdoc.7.html) and should be portable between mandoc and groff for rendering (though minor differences may occur, mandoc and groff seem to have slightly different spacing rules.) 6 - 7 - For previewing edited files, you can just run `man -l path/to/file.8` and you will see it rendered. 8 - 9 - Being written in `mdoc` these manpages use semantic markup. This file provides a guideline on where to apply which of the semantic elements of `mdoc`. 10 - 11 - ### Command lines and arguments 12 - 13 - In any manpage, commands, flags and arguments to the *current* executable should be marked according to their semantics. Commands, flags and arguments passed to *other* executables should not be marked like this and should instead be considered as code examples and marked with `Ql`. 14 - 15 - - Use `Fl` to mark flag arguments, `Ar` for their arguments. 16 - - Repeating arguments should be marked by adding ellipses (`...`). 17 - - Use `Cm` to mark literal string arguments, e.g. the `boot` command argument passed to `nixos-rebuild`. 18 - - Optional flags or arguments should be marked with `Op`. This includes optional repeating arguments. 19 - - Required flags or arguments should not be marked. 20 - - Mutually exclusive groups of arguments should be enclosed in curly brackets, preferably created with `Bro`/`Brc` blocks. 21 - 22 - When an argument is used in an example it should be marked up with `Ar` again to differentiate it from a constant. For example, a command with a `--host name` flag that calls ssh to retrieve the host's local time would signify this thusly: 23 - ``` 24 - This will run 25 - .Ic ssh Ar name Ic time 26 - to retrieve the remote time. 27 - ``` 28 - 29 - ### Paths, NixOS options, environment variables 30 - 31 - Constant paths should be marked with `Pa`, NixOS options with `Va`, and environment variables with `Ev`. 32 - 33 - Generated paths, e.g. `result/bin/run-hostname-vm` (where `hostname` is a variable or arguments) should be marked as `Ql` inline literals with their variable components marked appropriately. 34 - 35 - - Taking `hostname` from an argument become `.Ql result/bin/run- Ns Ar hostname Ns -vm` 36 - - Taking `hostname` from a variable otherwise defined becomes `.Ql result/bin/run- Ns Va hostname Ns -vm` 37 - 38 - ### Code examples and other commands 39 - 40 - In free text names and complete invocations of other commands (e.g. `ssh` or `tar -xvf src.tar`) should be marked with `Ic`, fragments of command lines should be marked with `Ql`. 41 - 42 - Larger code blocks or those that cannot be shown inline should use indented literal display block markup for their contents, i.e. 43 - ``` 44 - .Bd -literal -offset indent 45 - ... 46 - .Ed 47 - ``` 48 - Contents of code blocks may be marked up further, e.g. if they refer to arguments that will be substituted into them: 49 - ``` 50 - .Bd -literal -offset indent 51 - { 52 - options.hostname = "\c 53 - .Ar hostname Ns \c 54 - "; 55 - } 56 - .Ed 57 - ```
nixos/doc/manual/manpages/nixos-build-vms.8 nixos/modules/installer/tools/manpages/nixos-build-vms.8
nixos/doc/manual/manpages/nixos-enter.8 nixos/modules/installer/tools/manpages/nixos-enter.8
nixos/doc/manual/manpages/nixos-generate-config.8 nixos/modules/installer/tools/manpages/nixos-generate-config.8
nixos/doc/manual/manpages/nixos-install.8 nixos/modules/installer/tools/manpages/nixos-install.8
nixos/doc/manual/manpages/nixos-option.8 pkgs/tools/nix/nixos-option/nixos-option.8
nixos/doc/manual/manpages/nixos-rebuild.8 pkgs/os-specific/linux/nixos-rebuild/nixos-rebuild.8
nixos/doc/manual/manpages/nixos-version.8 nixos/modules/installer/tools/manpages/nixos-version.8
+11
nixos/modules/installer/tools/tools.nix
··· 9 9 makeProg = args: pkgs.substituteAll (args // { 10 10 dir = "bin"; 11 11 isExecutable = true; 12 + nativeBuildInputs = [ 13 + pkgs.installShellFiles 14 + ]; 15 + postInstall = '' 16 + installManPage ${args.manPage} 17 + ''; 12 18 }); 13 19 14 20 nixos-build-vms = makeProg { 15 21 name = "nixos-build-vms"; 16 22 src = ./nixos-build-vms/nixos-build-vms.sh; 17 23 inherit (pkgs) runtimeShell; 24 + manPage = ./manpages/nixos-build-vms.8; 18 25 }; 19 26 20 27 nixos-install = makeProg { ··· 27 34 nixos-enter 28 35 pkgs.util-linuxMinimal 29 36 ]; 37 + manPage = ./manpages/nixos-install.8; 30 38 }; 31 39 32 40 nixos-rebuild = pkgs.nixos-rebuild.override { nix = config.nix.package.out; }; ··· 40 48 btrfs = "${pkgs.btrfs-progs}/bin/btrfs"; 41 49 inherit (config.system.nixos-generate-config) configuration desktopConfiguration; 42 50 xserverEnabled = config.services.xserver.enable; 51 + manPage = ./manpages/nixos-generate-config.8; 43 52 }; 44 53 45 54 inherit (pkgs) nixos-option; ··· 57 66 } // optionalAttrs (config.system.configurationRevision != null) { 58 67 configurationRevision = config.system.configurationRevision; 59 68 }); 69 + manPage = ./manpages/nixos-version.8; 60 70 }; 61 71 62 72 nixos-enter = makeProg { ··· 66 76 path = makeBinPath [ 67 77 pkgs.util-linuxMinimal 68 78 ]; 79 + manPage = ./manpages/nixos-enter.8; 69 80 }; 70 81 71 82 in
+1 -1
nixos/modules/misc/documentation.nix
··· 346 346 system.build.manual = manual; 347 347 348 348 environment.systemPackages = [] 349 - ++ optional cfg.man.enable manual.manpages 349 + ++ optional cfg.man.enable manual.nixos-configuration-reference-manpage 350 350 ++ optionals cfg.doc.enable [ manual.manualHTML nixos-help ]; 351 351 }) 352 352
+1 -1
nixos/release.nix
··· 143 143 manualHTML = buildFromConfig ({ ... }: { }) (config: config.system.build.manual.manualHTML); 144 144 manual = manualHTML; # TODO(@oxij): remove eventually 145 145 manualEpub = (buildFromConfig ({ ... }: { }) (config: config.system.build.manual.manualEpub)); 146 - manpages = buildFromConfig ({ ... }: { }) (config: config.system.build.manual.manpages); 146 + nixos-configuration-reference-manpage = buildFromConfig ({ ... }: { }) (config: config.system.build.manual.nixos-configuration-reference-manpage); 147 147 options = (buildFromConfig ({ ... }: { }) (config: config.system.build.manual.optionsJSON)).x86_64-linux; 148 148 149 149
+7
pkgs/os-specific/linux/nixos-rebuild/default.nix
··· 6 6 , nix 7 7 , lib 8 8 , nixosTests 9 + , installShellFiles 9 10 }: 10 11 let 11 12 fallback = import ./../../../../nixos/modules/installer/tools/nix-fallback-paths.nix; ··· 20 21 nix_i686_linux = fallback.i686-linux; 21 22 nix_aarch64_linux = fallback.aarch64-linux; 22 23 path = lib.makeBinPath [ coreutils gnused gnugrep ]; 24 + nativeBuildInputs = [ 25 + installShellFiles 26 + ]; 27 + postInstall = '' 28 + installManPage ${./nixos-rebuild.8} 29 + ''; 23 30 24 31 # run some a simple installer tests to make sure nixos-rebuild still works for them 25 32 passthru.tests = {
+1 -2
pkgs/tools/nix/nixos-install-tools/default.nix
··· 20 20 inherit (config.system.build) 21 21 nixos-install nixos-generate-config nixos-enter; 22 22 23 - # Required for --help. 24 - inherit (config.system.build.manual) manpages; 23 + inherit (config.system.build.manual) nixos-configuration-reference-manpage; 25 24 }; 26 25 27 26 extraOutputsToInstall = ["man"];
+23 -4
pkgs/tools/nix/nixos-option/default.nix
··· 1 - { lib, stdenv, boost, cmake, pkg-config, nix }: 1 + { lib 2 + , stdenv 3 + , boost 4 + , cmake 5 + , pkg-config 6 + , installShellFiles 7 + , nix 8 + }: 2 9 3 10 stdenv.mkDerivation { 4 11 name = "nixos-option"; 5 12 6 13 src = ./.; 14 + postInstall = '' 15 + installManPage ${./nixos-option.8} 16 + ''; 7 17 8 18 strictDeps = true; 9 - nativeBuildInputs = [ cmake pkg-config ]; 10 - buildInputs = [ boost nix ]; 11 - cmakeFlags = [ "-DNIX_DEV_INCLUDEPATH=${nix.dev}/include/nix" ]; 19 + nativeBuildInputs = [ 20 + cmake 21 + pkg-config 22 + installShellFiles 23 + ]; 24 + buildInputs = [ 25 + boost 26 + nix 27 + ]; 28 + cmakeFlags = [ 29 + "-DNIX_DEV_INCLUDEPATH=${nix.dev}/include/nix" 30 + ]; 12 31 13 32 meta = with lib; { 14 33 license = licenses.lgpl2Plus;