1
0
Fork 0

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

Only build free packages
main
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 - travis_retry nix-channel --update
script: 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 'lib'
- nix eval -f default.nix 'modules' - nix eval -f default.nix 'modules'
- nix eval -f default.nix 'overlays' - nix eval -f default.nix 'overlays'

28
buildable.nix 100644
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,7 +4,8 @@
self: super: self: super:
let filterSet = let
filterSet =
(f: g: s: builtins.listToAttrs (f: g: s: builtins.listToAttrs
(map (map
(n: { name = n; value = builtins.getAttr n s; }) (n: { name = n; value = builtins.getAttr n s; })
@ -14,8 +15,9 @@ let filterSet =
) )
) )
); );
isReserved = n: builtins.elem n ["lib" "overlays" "modules"];
in filterSet 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 (p: true) # all packages are ok
(import ./default.nix { pkgs = super; }) (import ./default.nix { pkgs = super; })