Merge pull request #5 from nix-community/only-build-free

Only build free packages
This commit is contained in:
Francesco Gazzetta 2019-03-23 19:27:03 +01:00 committed by GitHub
commit 1ab421bfa7
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 41 additions and 38 deletions

View file

@ -22,7 +22,7 @@ install:
- travis_retry nix-channel --update
script:
- outs=$(nix-build non-broken.nix) && echo Produced $outs
- outs=$(nix-build buildable.nix) && echo Produced $outs
- nix eval -f default.nix 'lib'
- nix eval -f default.nix 'modules'
- nix eval -f default.nix 'overlays'

28
buildable.nix Normal file
View file

@ -0,0 +1,28 @@
# This file filters out all the unbuildable packages from your package set.
# It's what gets built by CI, so if you correctly mark broken/unfree packages
# as such your CI will not try to build them and the buildable packages will
# be added to the cache.
{ pkgs ? import <nixpkgs> {} }:
let
filterSet =
(f: g: s: builtins.listToAttrs
(map
(n: { name = n; value = builtins.getAttr n s; })
(builtins.filter
(n: f n && g (builtins.getAttr n s))
(builtins.attrNames s)
)
)
);
isReserved = n: builtins.elem n ["lib" "overlays" "modules"];
isBroken = p: p.meta.broken or false;
isFree = p: p.meta.license.free or true;
in filterSet
(n: !(isReserved n)) # filter out non-packages
(p: (builtins.isAttrs p)
&& !(isBroken p)
&& isFree p
)
(import ./default.nix { inherit pkgs; })

View file

@ -1,27 +0,0 @@
# This file filters out all the broken packages from your package set.
# It's what gets built by CI, so if you correctly mark broken packages as
# broken your CI will not try to build them and the non-broken packages will
# be added to the cache.
{ pkgs ? import <nixpkgs> {} }:
let filterSet =
(f: g: s: builtins.listToAttrs
(map
(n: { name = n; value = builtins.getAttr n s; })
(builtins.filter
(n: f n && g (builtins.getAttr n s))
(builtins.attrNames s)
)
)
);
in filterSet
(n: !(n=="lib"||n=="overlays"||n=="modules")) # filter out non-packages
(p: (builtins.isAttrs p)
&& !(
(builtins.hasAttr "meta" p)
&& (builtins.hasAttr "broken" p.meta)
&& (p.meta.broken)
)
)
(import ./default.nix { inherit pkgs; })

View file

@ -4,18 +4,20 @@
self: super:
let filterSet =
(f: g: s: builtins.listToAttrs
(map
(n: { name = n; value = builtins.getAttr n s; })
(builtins.filter
(n: f n && g (builtins.getAttr n s))
(builtins.attrNames s)
)
let
filterSet =
(f: g: s: builtins.listToAttrs
(map
(n: { name = n; value = builtins.getAttr n s; })
(builtins.filter
(n: f n && g (builtins.getAttr n s))
(builtins.attrNames s)
)
);
)
);
isReserved = n: builtins.elem n ["lib" "overlays" "modules"];
in filterSet
(n: !(n=="lib"||n=="overlays"||n=="modules")) # filter out non-packages
(n: !(isReserved n)) # filter out non-packages
(p: true) # all packages are ok
(import ./default.nix { pkgs = super; })