diff options
author | Nicolas Pierron <nicolas.b.pierron@gmail.com> | 2009-11-22 17:04:33 +0000 |
---|---|---|
committer | Nicolas Pierron <nicolas.b.pierron@gmail.com> | 2009-11-22 17:04:33 +0000 |
commit | b29073af25cb0ff2d8d9a0aa1f958316904d3dc9 (patch) | |
tree | ae365353773fc2a675be8abc2b283b4f8a6278f7 /pkgs/stdenv/adapters.nix | |
parent | 11c3e927383344bda85d04dd18ad2dc774ea8b04 (diff) | |
download | nixpkgs-b29073af25cb0ff2d8d9a0aa1f958316904d3dc9.tar nixpkgs-b29073af25cb0ff2d8d9a0aa1f958316904d3dc9.tar.gz nixpkgs-b29073af25cb0ff2d8d9a0aa1f958316904d3dc9.tar.bz2 nixpkgs-b29073af25cb0ff2d8d9a0aa1f958316904d3dc9.tar.lz nixpkgs-b29073af25cb0ff2d8d9a0aa1f958316904d3dc9.tar.xz nixpkgs-b29073af25cb0ff2d8d9a0aa1f958316904d3dc9.tar.zst nixpkgs-b29073af25cb0ff2d8d9a0aa1f958316904d3dc9.zip |
* Add an adapter which abort an install if the installed package depends
on a derivation with a meta.license attribute which does not satisfy the license predicate. With this adapter you can abort any install which depends on software which are not free by default. You can try it with MPlayer, because MPlayer depends of win32codecs flagged as "unfree". svn path=/nixpkgs/trunk/; revision=18530
Diffstat (limited to 'pkgs/stdenv/adapters.nix')
-rw-r--r-- | pkgs/stdenv/adapters.nix | 40 |
1 files changed, 40 insertions, 0 deletions
diff --git a/pkgs/stdenv/adapters.nix b/pkgs/stdenv/adapters.nix index 410cc16838d..88193714f61 100644 --- a/pkgs/stdenv/adapters.nix +++ b/pkgs/stdenv/adapters.nix @@ -227,4 +227,44 @@ rec { drvPath = printDrvPath pkg.drvPath; }; }; + + /* Abort if the license predicate is not verified for a derivation + declared with mkDerivation. + + One possible predicate to avoid all non-free packages can be achieved + with the following function: + + isFree = license: with builtins; + if isNull license then true + else if isList license then lib.all isFree license + else license != "non-free" && license != "unfree"; + + This adapter can be defined on the defaultStdenv definition. You can + use it by patching the all-packages.nix file or by using the override + feature of ~/.nixpkgs/config.nix . + */ + validateLicenses = licensePred: stdenv: stdenv // + { mkDerivation = args: + let + pkg = stdenv.mkDerivation args; + license = + if pkg ? meta && pkg.meta ? license then + pkg.meta.license + else + null; + + validate = arg: + if licensePred license then arg + else abort " + Error while building ${builtins.unsafeDiscardStringContext pkg.drvPath}: + The license predicate is not verified. + + bad license: ${builtins.exprToString license} + "; + + in pkg // { + outPath = validate pkg.outPath; + drvPath = validate pkg.drvPath; + }; + }; } |