[Nix-dev] How to build all of nixpkgs?
Bjørn Forsman
bjorn.forsman at gmail.com
Sun May 28 20:42:05 CEST 2017
On 23 May 2017 at 23:31, Bjørn Forsman <bjorn.forsman at gmail.com> wrote:
> Another bit of important information is that the release.nix files map
> over pkgs with builtins.tryEval (with the packagePlatforms function)
> to filter out unsupported packages (among other things). With that
> knowledge I should be able to create my own "release.nix" file that
> builds the world.
I finally have something that seems to be working:
----8<----
let
pkgs = import <nixpkgs> {
# ensure we don't get an impure config
config = { allowUnfree = false; allowBroken = false; };
};
lib = pkgs.lib;
canEval = val: (builtins.tryEval val).success;
canEvalStrict = val: (builtins.tryEval (builtins.deepSeq val val)).success;
# myfilter arguments
recurseYes = true;
recurseNo = false;
# Filter out all packages that don't evaluate or have unsupported platform.
# Attributes of unsupported packages will be set to an empty attrset.
myfilter = platform: recurse:
lib.mapAttrs
(n: v:
let
res = builtins.tryEval (
#builtins.trace ''name=${n}, type=${builtins.typeOf v}${if
v ? name then ", v.name=" + v.name else ""}''
(
# for recurseForDerivations and recurseForRelease (bool)
if builtins.typeOf v == "bool" then
v
else if !canEval v then
{}
else if lib.isDerivation v && canEval v.drvPath &&
builtins.elem platform (v.meta.platforms or []) then
v
else if recurse && (v.recurseForDerivations or false ||
v.recurseForRelease or false) then
myfilter platform recurse v
else
{}
)
);
in
if res.success then res.value else {}
);
in
{
# error: Package
‘Agda-Sheaves-8a06162a8f0f7df308458db91d720cf8f7345d69’ in [...] is
marked as broken, refusing to evaluate.
inherit pkgs;
# This shouldn't stop due to eval errors, but expect plenty of build
# failures. Better run with "--keep-going" if you want to build as much as
# possible.
filtered = myfilter "x86_64-linux" recurseYes pkgs;
}
---->8----
Knowing builtins.tryEval wasn't enough, because there are some errors
that are not caught by it. I particularly struggled when applying
recursion to my filter and hit a "error: value is a set while a
Boolean was expected", with no location info or trace back. Luckily
there is builtins.trace.
Best regards,
Bjørn Forsman
More information about the nix-dev
mailing list