fork/home-manager
git clone https://git.julia.blue/fork/home-manager
c707d4f5
master
1{ pkgs 2 3# Note, this should be "the standard library" + HM extensions. 4, lib ? import ../modules/lib/stdlib-extended.nix pkgs . lib 5 6, release , isReleaseBranch } : 7 8let 9 10nmdSrc = fetchTarball { 11url = 12"https://git.sr.ht/~rycee/nmd/archive/824a380546b5d0d0eb701ff8cd5dbafb360750ff.tar.gz" ; 13sha256 = "0vvj40k6bw8ssra8wil9rqbsznmfy1kwy7cihvm13rajwdg9ycgg" ; 14}; 15 16nmd = import nmdSrc { 17inherit lib ; 18# The DocBook output of `nixos-render-docs` doesn't have the change 19# `nmd` uses to work around the broken stylesheets in 20# `docbook-xsl-ns`, so we restore the patched version here. 21pkgs = pkgs // { 22docbook-xsl-ns = 23pkgs . docbook-xsl-ns . override { withManOptDedupPatch = true ; }; 24}; 25}; 26 27# Make sure the used package is scrubbed to avoid actually 28# instantiating derivations. 29scrubbedPkgsModule = { 30imports = [{ 31_module . args = { 32pkgs = lib . mkForce ( nmd . scrubDerivations "pkgs" pkgs ); 33pkgs_i686 = lib . mkForce { }; 34}; 35}]; 36}; 37 38dontCheckDefinitions = { _module . check = false ; }; 39 40gitHubDeclaration = user :repo :subpath : 41let urlRef = if isReleaseBranch then "release- ${ release } " else "master" ; 42in { 43url = "https://github.com/ ${ user } / ${ repo } /blob/ ${ urlRef } / ${ subpath } " ; 44name = "< ${ repo } / ${ subpath } >" ; 45}; 46 47hmPath = toString ./.. ; 48 49buildOptionsDocs = args @{ modules , includeModuleSystemOptions ? true , ...} : 50let options = ( lib . evalModules { inherit modules ; }). options ; 51in pkgs . buildPackages . nixosOptionsDoc ({ 52options = if includeModuleSystemOptions then 53options 54else 55builtins . removeAttrs options [ "_module" ]; 56transformOptions = opt : 57opt // { 58# Clean up declaration sites to not refer to the Home Manager 59# source tree. 60declarations = map ( decl : 61if lib . hasPrefix hmPath ( toString decl ) then 62gitHubDeclaration "nix-community" "home-manager" 63( lib . removePrefix "/" ( lib . removePrefix hmPath ( toString decl ))) 64else if decl == "lib/modules.nix" then 65# TODO: handle this in a better way (may require upstream 66# changes to nixpkgs) 67gitHubDeclaration "NixOS" "nixpkgs" decl 68else 69decl ) opt . declarations ; 70}; 71} // builtins . removeAttrs args [ "modules" "includeModuleSystemOptions" ]); 72 73hmOptionsDocs = buildOptionsDocs { 74modules = import ../modules/modules.nix { 75inherit lib pkgs ; 76check = false ; 77} ++ [ scrubbedPkgsModule ]; 78variablelistId = "home-manager-options" ; 79}; 80 81nixosOptionsDocs = buildOptionsDocs { 82modules = [ ../nixos scrubbedPkgsModule dontCheckDefinitions ]; 83includeModuleSystemOptions = false ; 84variablelistId = "nixos-options" ; 85optionIdPrefix = "nixos-opt-" ; 86}; 87 88nixDarwinOptionsDocs = buildOptionsDocs { 89modules = [ ../nix-darwin scrubbedPkgsModule dontCheckDefinitions ]; 90includeModuleSystemOptions = false ; 91variablelistId = "nix-darwin-options" ; 92optionIdPrefix = "nix-darwin-opt-" ; 93}; 94 95docs = nmd . buildDocBookDocs { 96pathName = "home-manager" ; 97projectName = "Home Manager" ; 98modulesDocs = [{ 99docBook = pkgs . linkFarm "hm-module-docs-for-nmd" { 100"nmd-result/home-manager-options.xml" = hmOptionsDocs . optionsDocBook ; 101"nmd-result/nix-darwin-options.xml" = 102nixDarwinOptionsDocs . optionsDocBook ; 103"nmd-result/nixos-options.xml" = nixosOptionsDocs . optionsDocBook ; 104}; 105}]; 106documentsDirectory = ./. ; 107documentType = "book" ; 108chunkToc = '' 109<toc> 110<d:tocentry xmlns:d="http://docbook.org/ns/docbook" linkend="book-home-manager-manual"><?dbhtml filename="index.html"?> 111<d:tocentry linkend="ch-options"><?dbhtml filename="options.html"?></d:tocentry> 112<d:tocentry linkend="ch-nixos-options"><?dbhtml filename="nixos-options.html"?></d:tocentry> 113<d:tocentry linkend="ch-nix-darwin-options"><?dbhtml filename="nix-darwin-options.html"?></d:tocentry> 114<d:tocentry linkend="ch-tools"><?dbhtml filename="tools.html"?></d:tocentry> 115<d:tocentry linkend="ch-release-notes"><?dbhtml filename="release-notes.html"?></d:tocentry> 116</d:tocentry> 117</toc> 118'' ; 119}; 120 121in { 122inherit nmdSrc ; 123 124options = { 125# TODO: Use `hmOptionsDocs.optionsJSON` directly once upstream 126# `nixosOptionsDoc` is more customizable. 127json = pkgs . runCommand "options.json" { 128meta . description = "List of Home Manager options in JSON format" ; 129} '' 130mkdir -p $ out /{share/doc,nix-support} 131cp -a ${ hmOptionsDocs . optionsJSON } /share/doc/nixos $ out /share/doc/home-manager 132substitute \ 133${ hmOptionsDocs . optionsJSON } /nix-support/hydra-build-products \ 134$ out /nix-support/hydra-build-products \ 135--replace \ 136' ${ hmOptionsDocs . optionsJSON } /share/doc/nixos ' \ 137"$out/share/doc/home-manager" 138'' ; 139}; 140 141manPages = docs . manPages ; 142 143manual = { inherit ( docs ) html htmlOpenTool ; }; 144 145# Unstable, mainly for CI. 146jsonModuleMaintainers = pkgs . writeText "hm-module-maintainers.json" ( let 147result = lib . evalModules { 148modules = import ../modules/modules.nix { 149inherit lib pkgs ; 150check = false ; 151} ++ [ scrubbedPkgsModule ]; 152}; 153in builtins . toJSON result . config . meta . maintainers ); 154}