Fil-C on Nix

Filnix wiki

mbrock/filnix

nanofil/survey/default.nix

The nanofil package survey (docs/survey.md). nanofilize is a package adapter: drv built with nanofil as its C compiler, in the Fil-C staging package set (whose libraries, built by filcc, it links with), and nothing else compiling its C: cc.sh hands every C compile to nanofil-cc and refuses what it cannot, so a package builds with nanofil alone or fails. C++ still goes to filcc and is counted (cxx.sh). Its own checkPhase runs where the port's package runs one.

nix build -f nanofil/survey ref.zlib   # the filcc build
nix build -f nanofil/survey nf.zlib    # the same package by nanofil
nix eval --json -f nanofil/survey meta.zlib # versions, sources, deps

The build log ends with "nanofil-survey: N objects, M C++, K fallbacks" on success, and on failure also the first nanofil errors that configure, meson or cmake logged.

λrepo?, opt?
repodefault ../..

nanofil options for every compile, e.g. "-O" (−−argstropt − O).

optdefault ""
let
22flake=
builtins.getFlaketoStringrepo
23system=
"x86_64-linux"
used by filcc pkgsFilc
24pkgs=
importflake.inputs.nixpkgs inherit system;
uses flake used by cc lib names
25filcc=
flake.packages.${system}.filcc-staging
uses flake system used by cc
26pkgsFilc=
flake.legacyPackages.${system}.pkgsFilcStaging
uses flake system used by nf p present ref

Only bin/ and src/, so that the survey's own results and docs do not change the nanofil builds.

30nanofil-cc=
31inherit
pkgs filcc
32src=
lib.fileset.toSource
33root=
34fileset=
lib.fileset.unions../bin ../src
uses lib used by cc
40cc=
pkgs.runCommand"nanofil-survey-cc" { }
mkdir -p $out/bin
for f in cc cxx; do
substitute ${./.}/$f.sh $out/bin/$f --subst-var-by bash ${pkgs.bash}/bin/bash \
--subst-var-by nanofilcc ${nanofil-cc} --subst-var-by filcc ${filcc}
chmod +x $out/bin/$f
done
for n in clang gcc; do ln -s cc $out/bin/$n; done
for n in c++ clang++ g++; do ln -s cxx $out/bin/$n; done
50report=
nanofilSurveyReport() {
local log=$NIX_BUILD_TOP/nanofil.log
echo "nanofil-survey: $(grep -cv '^\(cxx\|fallback\) ' $log) objects," \
"$(grep -c '^cxx ' $log) C++, $(grep -c '^fallback ' $log) fallbacks"
}
used by nanofilize
57nanofilize=
λdrv
drv.overrideAttrs
λold
60postHook=
old.postHook or ""
+
export NANOFIL_LOG=$NIX_BUILD_TOP/nanofil.log
: >$NANOFIL_LOG${lib.optionalStringopt ≢ "" "\nexport NANOFIL_OPT=${lib.escapeShellArgopt}"}
export PATH=${cc}/bin:$PATH CC=${cc}/bin/cc CXX=${cc}/bin/c++
70exitHook=
old.exitHook or "" + "\nnanofilSurveyReport\n"
71failureHook=
old.failureHook or ""
+
nanofilSurveyReport
find $NIX_BUILD_TOP \( -name config.log -o -name meson-log.txt \
-o -name CMakeError.log -o -name CMakeConfigureLog.yaml \) 2>/dev/null |
while read -r f; do grep -m 3 '^nanofil: ' "$f" | sed "s|^|nanofil-survey-config: |"; done
uses cc lib report used by info nf
79names=
lib.filtern: n ≢ "<custom>"
lib.flatten
map
λi
i ? pname
→
if i.pname ≡ null then "<custom>" else i.pname
else
builtins.attrNamesi
91inherit
pkgs
92prev=
93final=
uses lib pkgs used by present
98present=
lib.filtern: pkgsFilc ? ${n} names
uses lib names pkgsFilc used by meta names nf ref

A package's own build dependencies' names, to set aside what needs LLVM, Rust or Go.

101depNames=
p: mapd: d.pname or builtins.parseDrvNamed.name or "".name lib.filterlib.isDerivation p.nativeBuildInputs or [ ] ++ p.buildInputs or [ ] ++ p.propagatedBuildInputs or [ ]
uses lib used by info
110try=
λx
let
113r=
builtins.tryEvalbuiltins.deepSeqx x
in
if r.success then r.value else null
used by info
116info=
λn
let
in
122version=
tryp.version or ""
123ref=
tryp.drvPath
125src=
trytoStringp.src or ""
126srcDrv=
tryp.src.drvPath or ""

Its checkPhase or installCheckPhase runs (tpm2-tss runs makecheck as its installCheck).

129doCheck=
tryp.doCheck or false ∨ p.doInstallCheck or false
uses depNames nanofilize try used by meta

Packages whose builds measure something other than C compilation, or regularly need more than the survey's 90-minute limit. The default survey sets them aside; campaignctlsubmit bench builds them, one at a time on swa, as a compiler-speed benchmark (docs/campaign-service.md).

136slow=
137emacs30=
"mostly Lisp byte-compilation; hits the 90-minute limit"
138libgcrypt=
"its tests time out in the plain survey"
in
142inherit
nanofilize cc slow
143names=
uses present
144meta=
lib.genAttrspresent info
145ref=
lib.genAttrspresent n: pkgsFilc.${n}