···
1
-
{ pkgs, options, version, revision }:
1
+
{ pkgs, options, version, revision, extraSources ? [] }:
···
# Clean up declaration sites to not refer to the NixOS source tree.
optionsList' = flip map optionsList (opt: opt // {
20
-
declarations = map (fn: stripPrefix fn) opt.declarations;
20
+
declarations = map (fn: stripAnyPrefixes fn) opt.declarations;
// optionalAttrs (opt ? example) { example = substFunction opt.example; }
// optionalAttrs (opt ? default) { default = substFunction opt.default; }
// optionalAttrs (opt ? type) { type = substFunction opt.type; });
26
-
prefix = toString ../../..;
26
+
# We need to strip references to /nix/store/* from options,
27
+
# including any `extraSources` if some modules came from elsewhere,
28
+
# or else the build will fail.
30
+
# E.g. if some `options` came from modules in ${pkgs.customModules}/nix,
31
+
# you'd need to include `extraSources = [ "#{pkgs.customModules}" ]`
32
+
herePrefix = toString ../../..;
33
+
prefixesToStrip = [ herePrefix ] ++ extraSources;
29
-
if substring 0 (stringLength prefix) fn == prefix then
30
-
substring (stringLength prefix + 1) 1000 fn
35
+
stripAnyPrefixes = fn:
36
+
flip (flip fold fn) prefixesToStrip (fn: prefix:
37
+
if substring 0 (stringLength prefix) fn == prefix then
38
+
substring (stringLength prefix + 1) 1000 fn
# Convert the list of options into an XML file.
optionsXML = builtins.toFile "options.xml" (builtins.toXML optionsList');