Skip to content

Commit f8bd05e

Browse files
committed
facter: remove debug options
we have now the "detected" namespace, so we no longer need these hacks
1 parent 48cadff commit f8bd05e

File tree

1 file changed

+0
-76
lines changed

1 file changed

+0
-76
lines changed

modules/nixos/facter.nix

Lines changed: 0 additions & 76 deletions
Original file line numberDiff line numberDiff line change
@@ -27,81 +27,5 @@
2727
default = null;
2828
description = "Path to a report generated by nixos-facter.";
2929
};
30-
31-
debug = {
32-
options = mkOption {
33-
type = types.raw;
34-
description = "All of the options affected by Facter modules";
35-
};
36-
config = mkOption {
37-
type = types.raw;
38-
description = "A breakdown of the NixOS config being applied by each Facter module.";
39-
};
40-
};
4130
};
42-
43-
config.facter.debug = {
44-
options =
45-
let
46-
# we want all options except our own, otherwise we get into recursive issues
47-
otherOptions = lib.filterAttrs (n: _: n != "facter") options;
48-
49-
# a filter for identifying options where a Facter module has affected the value
50-
touchedByFacter =
51-
{ definitionsWithLocations, ... }:
52-
let
53-
# some options fail when we try to evaluate them, so we wrap this in tryEval
54-
eval = builtins.tryEval (
55-
builtins.any (
56-
{
57-
file ? "",
58-
...
59-
}:
60-
# we only want options affected by our modules
61-
lib.hasPrefix "${modulePath}/modules/nixos" file
62-
) definitionsWithLocations
63-
);
64-
in
65-
eval.success && eval.value;
66-
in
67-
lib.fold (a: b: lib.recursiveUpdate a b) { } (
68-
map (value@{ loc, ... }: lib.setAttrByPath loc value) (
69-
# we collect the options first with simple option filter, and then we filter them some more, otherwise we get
70-
# a max-call depth exceeded error (dunno why)
71-
lib.filter touchedByFacter (lib.collect lib.isOption otherOptions)
72-
)
73-
);
74-
75-
config =
76-
# extract the config values for each option, broken down by facter module
77-
lib.mapAttrsRecursiveCond
78-
(
79-
{
80-
definitionsWithLocations ? null,
81-
...
82-
}:
83-
# keep recursing if we are not processing an option, otherwise apply the map function
84-
definitionsWithLocations == null
85-
)
86-
(
87-
_:
88-
{ definitionsWithLocations, ... }:
89-
builtins.listToAttrs (
90-
map
91-
(
92-
{ file, value }:
93-
{
94-
name = "<facter>${lib.removePrefix modulePath file}";
95-
inherit value;
96-
}
97-
)
98-
(
99-
# we only want facter modules
100-
lib.filter ({ file, ... }: lib.hasPrefix modulePath file) definitionsWithLocations
101-
)
102-
)
103-
)
104-
cfg.debug.options;
105-
};
106-
10731
}

0 commit comments

Comments
 (0)