Skip to content

Commit

Permalink
Don't look for NixOS options when module-list.nix or lib doesn't exist (
Browse files Browse the repository at this point in the history
  • Loading branch information
oxalica authored May 6, 2023
2 parents 21d0870 + c7ce789 commit 67bfe95
Showing 1 changed file with 7 additions and 6 deletions.
13 changes: 7 additions & 6 deletions crates/nix-interop/src/nixos_options.nix
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,12 @@
# - nixos/lib/make-options-doc/default.nix
nixpkgs:
let
lib = import (nixpkgs + "/lib");
libPath = nixpkgs + "/lib";
lib = import libPath;
modulePath = nixpkgs + "/nixos/modules";
moduleListPath = modulePath + "/module-list.nix";

inherit (builtins) isString filter mapAttrs isPath isFunction functionArgs;
inherit (builtins) isString filter mapAttrs isPath isFunction functionArgs pathExists;
inherit (lib) evalModules trivial optionals filterAttrs;
inherit (lib.options) unknownModule literalExpression;

Expand Down Expand Up @@ -34,9 +36,7 @@ let
pkgs = null;
};

modules =
(filter canCacheDocs
(import (modulePath + "/module-list.nix")));
modules = filter canCacheDocs (import moduleListPath);

# From `nixos/modules/misc/documentation.nix`.
canCacheDocs = m:
Expand Down Expand Up @@ -177,6 +177,7 @@ let
(mapAttrs (_: normalizeOptions) opts);

in
if builtins.compareVersions trivial.release "22.11" >= 0
if pathExists libPath && pathExists moduleListPath
&& builtins.compareVersions trivial.release "22.11" >= 0
then normalizeOptionSet eval.options
else { }

0 comments on commit 67bfe95

Please sign in to comment.