From bf2b75ca7ec6e69f85e7e05ec1bd85785163b5f4 Mon Sep 17 00:00:00 2001 From: Eelco Dolstra Date: Wed, 22 Aug 2012 15:21:10 -0400 Subject: [PATCH] Add hacky way to prevent Hydra from building/distributing unfree packages If the environment variable HYDRA_DISALLOW_UNFREE is set to "1", then evaluation of a package with license "unfree" will throw an error. Thus such packages or any packages that depend on them will fail to evaluate. --- pkgs/stdenv/generic/default.nix | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/pkgs/stdenv/generic/default.nix b/pkgs/stdenv/generic/default.nix index 3555ea980150..9197ff8314b4 100644 --- a/pkgs/stdenv/generic/default.nix +++ b/pkgs/stdenv/generic/default.nix @@ -10,6 +10,8 @@ let lib = import ../../lib; + disallowUnfree = builtins.getEnv "HYDRA_DISALLOW_UNFREE" == "1"; + stdenvGenerator = setupScript: rec { # The stdenv that we are producing. @@ -39,6 +41,9 @@ let # Add a utility function to produce derivations that use this # stdenv and its shell. mkDerivation = attrs: + if disallowUnfree && attrs.meta.license or "" == "unfree" then + throw "package ‘${attrs.name}’ has an unfree license, refusing to evaluate" + else (derivation ( (removeAttrs attrs ["meta" "passthru" "crossAttrs"]) // (let