Fil-C on Nix

Filnix wiki

mbrock/filnix

dterm-nix/options.nix

The options of filnix's modules as evaluation knows them, as JSON for dterm-nix's option index (dterm_nix.pl --options). For each option: where it is declared, its type, default, example and description, and the files that define it in an evaluated system. The options are the ones a module declares and the ones it sets, so the index follows the modules without being edited by hand.

Paths are relative: "lib/filc-system.nix" in filnix, "nixpkgs/…" in Nixpkgs.

λlib, evalNixos, filnix, pkgs, nixpkgsRoot, nixpkgsRev
let

Nixpkgs' eval-config.nix, applied to a system and modules.

The flake, whose exported modules are listed, and the build platform's package set that ports/overlay.nix is applied with.

21filnixRoot=
filnix.outPath

The exported modules: each with the file it is in and the machine it is evaluated in. The machine only supplies definitions; the options listed are the ones declared in the module's file and the ones its config sets. Both exported modules import the shared core, lib/filc-system.nix, which is listed on its own: module is the function in file whose config is walked, when it is not the exported module itself. A module the flake does not export (yet) is left out.

30here=
"dterm-nix/options.nix"
31nixosMachine=
32_file=
33filc.enable=
true
34boot.loader.grub.enable=
false
35fileSystems."/".device=
"none"
36system.stateVersion=
"26.05"
uses here used by modules
38finixMachine=
39_file=
40filc.enable=
true
uses here used by modules
42modules=
lib.filterm: lib.hasAttrByPathm.attr filnix
44attr=
"nixosModules" "default"
48name=
"filc-system"
49title=
"NixOS and finix: lib/filc-system.nix"
50kind=
"nixos"
51file=
"${filnixRoot}/lib/filc-system.nix"
52module=
import"${filnixRoot}/lib/filc-system.nix"
53inherit
filnix
54os=
"nixos"
57machineFile=
60attr=
"nixosModules" "default"
64kind=
"nixos"
65file=
"${filnixRoot}/nixos/default.nix"
67machineFile=
70attr=
"finixModules" "default"
74kind=
"finix"
75file=
"${filnixRoot}/finix/default.nix"
77machineFile=
81rel=
λfile
let
84f=
builtins.unsafeDiscardStringContexttoStringfile
85root=
toStringfilnixRoot + "/"
86np=
toStringnixpkgsRoot + "/"
in
lib.hasPrefixroot f
→
lib.removePrefixroot f
lib.hasPrefixnp f
→
"nixpkgs/" + lib.removePrefixnp f
else
95text=
λv
v ≡ null
→
null
builtins.isStringv
→
builtins.unsafeDiscardStringContextv
v ? _type ∧ v ? text
→
103kind=
v._type
104text=
builtins.unsafeDiscardStringContextv.text
else
builtins.unsafeDiscardStringContextlib.generators.toPretty{ } v
used by entry tried

What the option's documentation says, as the manual renders it.

110doc=
λopt
let
113entries=
lib.optionAttrSetToDocListx = opt;
used by e
114e=
lib.findFirste: e.loc ≡ opt.loc { } entries
uses entries used by tried
115tried=
builtins.tryEvalbuiltins.deepSeqtexte.default or null e
uses e text
in
if tried.success then tried.value else { }
used by d
119entry=
λgroup opt
let
122d=
uses doc

Only the default (mkOptionDefault, priority 1500) is not a definition.

124defs=
builtins.tryEval
opt.highestPrio or 100 ≥ 1500
→
[ ]
else
lib.uniquemapx: relx.file opt.definitionsWithLocations
uses rel
in
132inherit
group
133name=
lib.showOptionopt.loc
134loc=
mapbuiltins.unsafeDiscardStringContext opt.loc
135declarations=
map
λp
136file=
relp.file
137inherit p
line
opt.declarationPositions or [ ]
139type=
textd.type or null
140default=
textd.default or null
141example=
textd.example or null
142description=
textd.description or null
143readOnly=
d.readOnly or false
144definitions=
if defs.success then defs.value else [ ]
uses rel text used by evaluate setEntry
147options=
tree: lib.collectlib.isOption tree
used by declared

The options a module's config sets: its definitions walked through mkMerge, mkIf and the overrides, down to the first path that is an option.

152setPaths=
λallOptions prefix v
let
155here=
lib.attrByPathprefix null allOptions
156t=
v._type or null
in
prefix ≢ [ ] ∧ lib.isOptionhere
→
t ≡ "merge"
→
lib.concatMapsetPathsallOptions prefix v.contents
t ≡ "if" ∨ t ≡ "override" ∨ t ≡ "order"
→
lib.isAttrsv ∧ ¬lib.isDerivationv ∧ t ≡ null
→
lib.concatListslib.mapAttrsToListn: setPathsallOptions prefix ++ n v
else
[ ]
used by setPaths'

Which attributes of the Fil-C package set that ports/overlay.nix makes (a port or one of its overrides) are a derivation: those of the same name and derivation, among the names that begin with its first word (bash for bash-interactive, php for php-with-extensions).

175pkgsFilc=
filnix.legacyPackages.${pkgs.stdenv.hostPlatform.system}.pkgsFilc
used by c overlayNames r
176overlayNames=
builtins.attrNamesimport"${filnixRoot}/ports/overlay.nix" pkgs pkgsFilc pkgsFilc
179builtBy=
λv
let
182word=
lib.headlib.splitString"-" v.pname or builtins.parseDrvNamev.name.name
185same=
λn
let
188r=
builtins.tryEval
let
in
lib.isDerivationc ∧ c.name ≡ v.name ∧ c.drvPath ≡ v.drvPath
in
r.success ∧ r.value
in
lib.filtersame lib.filterlib.hasPrefixword overlayNames
uses overlayNames used by attrs

The value of a set option in the evaluated machine, when it is a package or a list of them: the derivation's name and pname, and the overlay's attributes that build it.

202pkgValue=
λv
lib.isDerivationv
→
let
206attrs=
uses builtBy used by plain
207pname=
v.pname or null
used by r

Neither a port nor an override builds it: it is the package set's attribute of that pname, as Nixpkgs builds it, with Fil-C.

210plain=
let
212r=
builtins.tryEvalpname ≢ null ∧ ¬lib.elempname overlayNames ∧ pkgsFilc ? ${pname} ∧ pkgsFilc.${pname}.drvPath ≡ v.drvPath
in
attrs ≡ [ ] ∧ r.success ∧ r.value
uses attrs
in
222inherit v
name
223inherit
pname attrs plain
else
null
used by x
227value=
λv
let
230r=
builtins.tryEval
let
232x=
lib.isDerivationv
→
builtins.isListv ∧ v ≢ [ ] ∧ lib.alllib.isDerivation v
→
else
null
uses pkgValue
in
builtins.deepSeqx x
in
if r.success then r.value else null
used by setEntry

A module is a function of filnix, so its file is stated: without it its definitions would be attributed to the flake.

247evaluate=
λm
let
250exported=
lib.getAttrFromPathm.attr filnix
used by inMachine module
251module=
m.module or exported
uses exported used by applied
252inMachine=
254_file=
m.file
255imports=
m.machine
uses exported used by eval
259eval=
m.kind ≡ "nixos"
→
else
lib.evalModulesmodules = inMachine ++ _module.check = false;;
266declared=
lib.filtero: lib.anyp: relp.file ≡ relm.file o.declarationPositions or [ ] optionseval.options
uses eval options rel used by setPaths'
269applied=
eval._module.args
//
272inherit eval
config options
273inherit
lib
uses eval module used by setPaths'
276setPaths'=
lib.filterp: ¬lib.anyo: o.loc ≡ p declared lib.uniquesetPathseval.options [ ] applied.config or { }

The value in the machine; of a list, the module's own elements.

280setEntry=
λp
let
283opt=
lib.getAttrFromPathp eval.options
uses eval used by own
284v=
lib.attrByPathp null eval.config
uses eval
285own=
builtins.tryEvallib.concatMapd: lib.toListd.value lib.filterd: reld.file ≡ relm.file opt.definitionsWithLocations
uses opt rel
in
entry"set" opt // value = valueif builtins.isListv then if own.success then own.value else null else v;
uses entry value
in
299inherit m
kind
300name=
m.name or lib.concatStringsSep"." m.attr
301title=
m.title or null
302file=
relm.file
303machine=
relm.machineFile
304options=
mapentry"declared" declared ++ mapsetEntry setPaths'
uses entry rel used by modules
in
308inherit
nixpkgsRev overlayNames