Fil-C on Nix

Filnix wiki

mbrock/filnix

tests/port-names.nix

A bare port, (for pkgs.X [ … ]), is keyed by the pname of pkgs.X (ports/default.nix, makeOverlay), so it lands on pkgsFilc.<pname>. When that is not X, pkgsFilc.X may silently not carry the port. This check fails when the two attributes are different derivations, or when only one of them is marked broken. Aliases of one derivation (libkrb5 for krb5) pass, and so do explicitly named ports ({ bash = for pkgs.bash … }), which are keyed by their name.

The bare ports are found in the port lists' text: the (for pkgs.X spelling, outside comments.

λpkgs, pkgsFilc
let
13inherit pkgs
lib
14dsl=
import../ports/default.nix inherit lib pkgs;
used by key
22code=
file: lib.concatStringsSep"\n" lib.filterl: ¬lib.hasPrefix"#" lib.triml lib.splitString"\n" builtins.readFilefile
uses lib used by bare
29bare=
file: maplib.head lib.filterbuiltins.isList builtins.split"\\(for pkgs\\.([A-Za-z0-9_'-]+)[[:space:]]" codefile
uses code lib used by written
36written=
lib.filterx: pkgs ? ${x} lib.uniquelib.concatMapbare files
uses bare files lib used by results
38try=
λe
let
41r=
builtins.tryEvale
in
if r.success then r.value else null
used by broken drvPath
44drvPath=
n: trypkgsFilc.${n}.drvPath
uses try used by same
45broken=
n: trypkgsFilc.${n}.meta.broken or false
uses try used by bothBroken check
47check=
λx
let
50key=
dsl.forpkgs.${x} [ ].pname
uses dsl used by bothBroken same
52bothBroken=
uses broken key
in
55inherit
x key
56ok=
x ≡ key ∨ same ∧ bothBroken
57why=
→
"only one is marked broken (${x}: ${builtins.toJSONbrokenx}, ${key}: ${builtins.toJSONbrokenkey})"
else
"they are different derivations"
uses broken used by results
63results=
64failures=
lib.filterr: ¬r.ok results
uses lib results
65aliases=
lib.filterr: r.ok ∧ r.x ≢ r.key results
uses lib results
in
pkgs.runCommand"port-names-check" { }
failures ≡ [ ]
→
echo "${toStringlib.lengthwritten} bare ports land on their own attribute or on an alias of it:"
${lib.concatMapStringsr: "echo ' ${r.x} -> ${r.key}'\n" aliases}
touch $out
else
echo "Bare ports that land on another attribute than the one written:"
${lib.concatMapStringsr: "echo ' (for pkgs.${r.x} …) lands on pkgsFilc.${r.key}, and ${r.why}'\n" failures}
echo "Name the port as its attribute ({ ${lib.headfailures.x} = for pkgs.${lib.headfailures.x} [ … ]; }) or write the attribute it lands on."
exit 1