summary refs log tree commit diff
path: root/nixos/lib/eval-cacheable-options.nix
blob: d26967ebe09b8fcc8ad06a60071eceaf384d0733 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
{ libPath
, pkgsLibPath
, nixosPath
, modules
, stateVersion
, release
}:

let
  lib = import libPath;
  modulesPath = "${nixosPath}/modules";
  # dummy pkgs set that contains no packages, only `pkgs.lib` from the full set.
  # not having `pkgs.lib` causes all users of `pkgs.formats` to fail.
  pkgs = import pkgsLibPath {
    inherit lib;
    pkgs = null;
  };
  utils = import "${nixosPath}/lib/utils.nix" {
    inherit config lib;
    pkgs = null;
  };
  # this is used both as a module and as specialArgs.
  # as a module it sets the _module special values, as specialArgs it makes `config`
  # unusable. this causes documentation attributes depending on `config` to fail.
  config = {
    _module.check = false;
    _module.args = {};
    system.stateVersion = stateVersion;
  };
  eval = lib.evalModules {
    modules = (map (m: "${modulesPath}/${m}") modules) ++ [
      config
    ];
    specialArgs = {
      inherit config pkgs utils;
      class = "nixos";
    };
  };
  docs = import "${nixosPath}/doc/manual" {
    pkgs = pkgs // {
      inherit lib;
      # duplicate of the declaration in all-packages.nix
      buildPackages.nixosOptionsDoc = attrs:
        (import "${nixosPath}/lib/make-options-doc")
          ({ inherit pkgs lib; } // attrs);
    };
    config = config.config;
    options = eval.options;
    version = release;
    revision = "release-${release}";
    prefix = modulesPath;
  };
in
  docs.optionsNix