{"action":"created","comment":{"url":"https://api.github.com/repos/NixOS/nixpkgs/pulls/comments/23526212","id":23526212,"diff_hunk":"@@ -64,9 +73,57 @@ let\n             { allow${unfreeOrBroken} = true; }\n           to ~/.nixpkgs/config.nix.\n         '';\n+\n+      # Check whether unfree packages are allowed and if not, whether the\n+      # package has an unfree license and is not explicitely allowed by the\n+      # `allowUNfreePredicate` function.\n+      hasDeniedUnfreeLicense = attrs:\n+        !allowUnfree &&\n+        isUnfree (lib.lists.toList attrs.meta.license or []) &&\n+        !allowUnfreePredicate attrs;\n+\n+      # Check whether two sets are mutual exclusive\n+      mutualExclusive = a: b:\n+        (builtins.length a) == 0 ||\n+        (!(builtins.elem (builtins.head a) b) &&\n+         mutualExclusive (builtins.tail a) b);\n+\n+      # Check whether an package has the license set\n+      licenseCheckable = attr:\n+        builtins.hasAttr \"meta\" attrs && builtins.hasAttr \"license\" attrs.meta;\n+\n+      # Check whether the license of the package is whitelisted.\n+      # If the package has no license, print a warning about this and allow the\n+      # package (return that it is actually whitelisted)\n+      hasWhitelistedLicense = attrs:\n+        if licenseCheckable attrs then\n+          builtins.elem attrs.meta.license whitelistedLicenses\n+        else\n+          #builtins.trace \"Has no license: ${attrs.name}, allowing installation\"\n+                         true;\n+\n+      # Check whether the license of the package is blacklisted.\n+      # If the package has no license, print a warning about this and allow the\n+      # package (return that it is actually not blacklisted)\n+      hasBlacklistedLicense = attrs:\n+        if licenseCheckable attrs then\n+          builtins.elem attrs.meta.license blacklistedLicenses\n+        else\n+          #builtins.trace \"Has no license: ${attrs.name}, allowing installation\"\n+                         false;\n+\n     in\n-    if !allowUnfree && isUnfree (lib.lists.toList attrs.meta.license or []) && !allowUnfreePredicate attrs then\n-      throwEvalHelp \"Unfree\" \"has an unfree license\"\n+    if !(mutualExclusive whitelistedLicenses blacklistedLicenses) then\n+      throw ''\n+          Package blacklist (${blacklistedLicenses}) and whitelist\n+          (${whitelistedLicenses}) are not mutual exclusive.","path":"pkgs/stdenv/generic/default.nix","position":74,"original_position":74,"commit_id":"aca361fa4960b51e5bcdf13fc826ebdbcb534302","original_commit_id":"aca361fa4960b51e5bcdf13fc826ebdbcb534302","user":{"login":"edolstra","id":1148549,"avatar_url":"https://avatars.githubusercontent.com/u/1148549?v=3","gravatar_id":"","url":"https://api.github.com/users/edolstra","html_url":"https://github.com/edolstra","followers_url":"https://api.github.com/users/edolstra/followers","following_url":"https://api.github.com/users/edolstra/following{/other_user}","gists_url":"https://api.github.com/users/edolstra/gists{/gist_id}","starred_url":"https://api.github.com/users/edolstra/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/edolstra/subscriptions","organizations_url":"https://api.github.com/users/edolstra/orgs","repos_url":"https://api.github.com/users/edolstra/repos","events_url":"https://api.github.com/users/edolstra/events{/privacy}","received_events_url":"https://api.github.com/users/edolstra/received_events","type":"User","site_admin":false},"body":"Should be \"mutually exclusive\".","created_at":"2015-01-26T12:18:12Z","updated_at":"2015-01-26T12:18:12Z","html_url":"https://github.com/NixOS/nixpkgs/pull/5892#discussion_r23526212","pull_request_url":"https://api.github.com/repos/NixOS/nixpkgs/pulls/5892","_links":{"self":{"href":"https://api.github.com/repos/NixOS/nixpkgs/pulls/comments/23526212"},"html":{"href":"https://github.com/NixOS/nixpkgs/pull/5892#discussion_r23526212"},"pull_request":{"href":"https://api.github.com/repos/NixOS/nixpkgs/pulls/5892"}}},"pull_request":{"url":"https://api.github.com/repos/NixOS/nixpkgs/pulls/5892","id":27793085,"html_url":"https://github.com/NixOS/nixpkgs/pull/5892","diff_url":"https://github.com/NixOS/nixpkgs/pull/5892.diff","patch_url":"https://github.com/NixOS/nixpkgs/pull/5892.patch","issue_url":"https://api.github.com/repos/NixOS/nixpkgs/issues/5892","number":5892,"state":"closed","locked":false,"title":"[WIP] Add (optional) license white/blacklisting","user":{"login":"matthiasbeyer","id":427866,"avatar_url":"https://avatars.githubusercontent.com/u/427866?v=3","gravatar_id":"","url":"https://api.github.com/users/matthiasbeyer","html_url":"https://github.com/matthiasbeyer","followers_url":"https://api.github.com/users/matthiasbeyer/followers","following_url":"https://api.github.com/users/matthiasbeyer/following{/other_user}","gists_url":"https://api.github.com/users/matthiasbeyer/gists{/gist_id}","starred_url":"https://api.github.com/users/matthiasbeyer/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/matthiasbeyer/subscriptions","organizations_url":"https://api.github.com/users/matthiasbeyer/orgs","repos_url":"https://api.github.com/users/matthiasbeyer/repos","events_url":"https://api.github.com/users/matthiasbeyer/events{/privacy}","received_events_url":"https://api.github.com/users/matthiasbeyer/received_events","type":"User","site_admin":false},"body":"[WIP]\r\n\r\nThis adds optional white- or blacklisting for licenses from the users configuration as I proposed [on the ML](http://lists.science.uu.nl/pipermail/nix-dev/2015-January/015763.html).\r\n\r\nPlease tell me what you guys think about this.\r\n\r\n---\r\n\r\n(I hope the `[ci skip]` thing worked here... as this is wip)","created_at":"2015-01-21T20:44:02Z","updated_at":"2015-01-26T12:18:12Z","closed_at":"2015-01-24T19:06:32Z","merged_at":"2015-01-24T19:06:32Z","merge_commit_sha":"529e1b22bbb815376b2cc290ade637821c0012cc","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/NixOS/nixpkgs/pulls/5892/commits","review_comments_url":"https://api.github.com/repos/NixOS/nixpkgs/pulls/5892/comments","review_comment_url":"https://api.github.com/repos/NixOS/nixpkgs/pulls/comments/{number}","comments_url":"https://api.github.com/repos/NixOS/nixpkgs/issues/5892/comments","statuses_url":"https://api.github.com/repos/NixOS/nixpkgs/statuses/aca361fa4960b51e5bcdf13fc826ebdbcb534302","head":{"label":"matthiasbeyer:add-license_selection","ref":"add-license_selection","sha":"aca361fa4960b51e5bcdf13fc826ebdbcb534302","user":{"login":"matthiasbeyer","id":427866,"avatar_url":"https://avatars.githubusercontent.com/u/427866?v=3","gravatar_id":"","url":"https://api.github.com/users/matthiasbeyer","html_url":"https://github.com/matthiasbeyer","followers_url":"https://api.github.com/users/matthiasbeyer/followers","following_url":"https://api.github.com/users/matthiasbeyer/following{/other_user}","gists_url":"https://api.github.com/users/matthiasbeyer/gists{/gist_id}","starred_url":"https://api.github.com/users/matthiasbeyer/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/matthiasbeyer/subscriptions","organizations_url":"https://api.github.com/users/matthiasbeyer/orgs","repos_url":"https://api.github.com/users/matthiasbeyer/repos","events_url":"https://api.github.com/users/matthiasbeyer/events{/privacy}","received_events_url":"https://api.github.com/users/matthiasbeyer/received_events","type":"User","site_admin":false},"repo":{"id":23671310,"name":"nixpkgs","full_name":"matthiasbeyer/nixpkgs","owner":{"login":"matthiasbeyer","id":427866,"avatar_url":"https://avatars.githubusercontent.com/u/427866?v=3","gravatar_id":"","url":"https://api.github.com/users/matthiasbeyer","html_url":"https://github.com/matthiasbeyer","followers_url":"https://api.github.com/users/matthiasbeyer/followers","following_url":"https://api.github.com/users/matthiasbeyer/following{/other_user}","gists_url":"https://api.github.com/users/matthiasbeyer/gists{/gist_id}","starred_url":"https://api.github.com/users/matthiasbeyer/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/matthiasbeyer/subscriptions","organizations_url":"https://api.github.com/users/matthiasbeyer/orgs","repos_url":"https://api.github.com/users/matthiasbeyer/repos","events_url":"https://api.github.com/users/matthiasbeyer/events{/privacy}","received_events_url":"https://api.github.com/users/matthiasbeyer/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/matthiasbeyer/nixpkgs","description":"Nix Packages collection","fork":true,"url":"https://api.github.com/repos/matthiasbeyer/nixpkgs","forks_url":"https://api.github.com/repos/matthiasbeyer/nixpkgs/forks","keys_url":"https://api.github.com/repos/matthiasbeyer/nixpkgs/keys{/key_id}","collaborators_url":"https://api.github.com/repos/matthiasbeyer/nixpkgs/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/matthiasbeyer/nixpkgs/teams","hooks_url":"https://api.github.com/repos/matthiasbeyer/nixpkgs/hooks","issue_events_url":"https://api.github.com/repos/matthiasbeyer/nixpkgs/issues/events{/number}","events_url":"https://api.github.com/repos/matthiasbeyer/nixpkgs/events","assignees_url":"https://api.github.com/repos/matthiasbeyer/nixpkgs/assignees{/user}","branches_url":"https://api.github.com/repos/matthiasbeyer/nixpkgs/branches{/branch}","tags_url":"https://api.github.com/repos/matthiasbeyer/nixpkgs/tags","blobs_url":"https://api.github.com/repos/matthiasbeyer/nixpkgs/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/matthiasbeyer/nixpkgs/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/matthiasbeyer/nixpkgs/git/refs{/sha}","trees_url":"https://api.github.com/repos/matthiasbeyer/nixpkgs/git/trees{/sha}","statuses_url":"https://api.github.com/repos/matthiasbeyer/nixpkgs/statuses/{sha}","languages_url":"https://api.github.com/repos/matthiasbeyer/nixpkgs/languages","stargazers_url":"https://api.github.com/repos/matthiasbeyer/nixpkgs/stargazers","contributors_url":"https://api.github.com/repos/matthiasbeyer/nixpkgs/contributors","subscribers_url":"https://api.github.com/repos/matthiasbeyer/nixpkgs/subscribers","subscription_url":"https://api.github.com/repos/matthiasbeyer/nixpkgs/subscription","commits_url":"https://api.github.com/repos/matthiasbeyer/nixpkgs/commits{/sha}","git_commits_url":"https://api.github.com/repos/matthiasbeyer/nixpkgs/git/commits{/sha}","comments_url":"https://api.github.com/repos/matthiasbeyer/nixpkgs/comments{/number}","issue_comment_url":"https://api.github.com/repos/matthiasbeyer/nixpkgs/issues/comments/{number}","contents_url":"https://api.github.com/repos/matthiasbeyer/nixpkgs/contents/{+path}","compare_url":"https://api.github.com/repos/matthiasbeyer/nixpkgs/compare/{base}...{head}","merges_url":"https://api.github.com/repos/matthiasbeyer/nixpkgs/merges","archive_url":"https://api.github.com/repos/matthiasbeyer/nixpkgs/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/matthiasbeyer/nixpkgs/downloads","issues_url":"https://api.github.com/repos/matthiasbeyer/nixpkgs/issues{/number}","pulls_url":"https://api.github.com/repos/matthiasbeyer/nixpkgs/pulls{/number}","milestones_url":"https://api.github.com/repos/matthiasbeyer/nixpkgs/milestones{/number}","notifications_url":"https://api.github.com/repos/matthiasbeyer/nixpkgs/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/matthiasbeyer/nixpkgs/labels{/name}","releases_url":"https://api.github.com/repos/matthiasbeyer/nixpkgs/releases{/id}","created_at":"2014-09-04T17:01:03Z","updated_at":"2015-01-15T15:18:46Z","pushed_at":"2015-01-26T07:35:33Z","git_url":"git://github.com/matthiasbeyer/nixpkgs.git","ssh_url":"git@github.com:matthiasbeyer/nixpkgs.git","clone_url":"https://github.com/matthiasbeyer/nixpkgs.git","svn_url":"https://github.com/matthiasbeyer/nixpkgs","homepage":null,"size":127049,"stargazers_count":0,"watchers_count":0,"language":"Nix","has_issues":false,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":0,"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"NixOS:master","ref":"master","sha":"e29996c5c388c6c2aaaf6b85bbfc03b3048a7f28","user":{"login":"NixOS","id":487568,"avatar_url":"https://avatars.githubusercontent.com/u/487568?v=3","gravatar_id":"","url":"https://api.github.com/users/NixOS","html_url":"https://github.com/NixOS","followers_url":"https://api.github.com/users/NixOS/followers","following_url":"https://api.github.com/users/NixOS/following{/other_user}","gists_url":"https://api.github.com/users/NixOS/gists{/gist_id}","starred_url":"https://api.github.com/users/NixOS/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/NixOS/subscriptions","organizations_url":"https://api.github.com/users/NixOS/orgs","repos_url":"https://api.github.com/users/NixOS/repos","events_url":"https://api.github.com/users/NixOS/events{/privacy}","received_events_url":"https://api.github.com/users/NixOS/received_events","type":"Organization","site_admin":false},"repo":{"id":4542716,"name":"nixpkgs","full_name":"NixOS/nixpkgs","owner":{"login":"NixOS","id":487568,"avatar_url":"https://avatars.githubusercontent.com/u/487568?v=3","gravatar_id":"","url":"https://api.github.com/users/NixOS","html_url":"https://github.com/NixOS","followers_url":"https://api.github.com/users/NixOS/followers","following_url":"https://api.github.com/users/NixOS/following{/other_user}","gists_url":"https://api.github.com/users/NixOS/gists{/gist_id}","starred_url":"https://api.github.com/users/NixOS/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/NixOS/subscriptions","organizations_url":"https://api.github.com/users/NixOS/orgs","repos_url":"https://api.github.com/users/NixOS/repos","events_url":"https://api.github.com/users/NixOS/events{/privacy}","received_events_url":"https://api.github.com/users/NixOS/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/NixOS/nixpkgs","description":"Nix Packages collection","fork":false,"url":"https://api.github.com/repos/NixOS/nixpkgs","forks_url":"https://api.github.com/repos/NixOS/nixpkgs/forks","keys_url":"https://api.github.com/repos/NixOS/nixpkgs/keys{/key_id}","collaborators_url":"https://api.github.com/repos/NixOS/nixpkgs/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/NixOS/nixpkgs/teams","hooks_url":"https://api.github.com/repos/NixOS/nixpkgs/hooks","issue_events_url":"https://api.github.com/repos/NixOS/nixpkgs/issues/events{/number}","events_url":"https://api.github.com/repos/NixOS/nixpkgs/events","assignees_url":"https://api.github.com/repos/NixOS/nixpkgs/assignees{/user}","branches_url":"https://api.github.com/repos/NixOS/nixpkgs/branches{/branch}","tags_url":"https://api.github.com/repos/NixOS/nixpkgs/tags","blobs_url":"https://api.github.com/repos/NixOS/nixpkgs/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/NixOS/nixpkgs/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/NixOS/nixpkgs/git/refs{/sha}","trees_url":"https://api.github.com/repos/NixOS/nixpkgs/git/trees{/sha}","statuses_url":"https://api.github.com/repos/NixOS/nixpkgs/statuses/{sha}","languages_url":"https://api.github.com/repos/NixOS/nixpkgs/languages","stargazers_url":"https://api.github.com/repos/NixOS/nixpkgs/stargazers","contributors_url":"https://api.github.com/repos/NixOS/nixpkgs/contributors","subscribers_url":"https://api.github.com/repos/NixOS/nixpkgs/subscribers","subscription_url":"https://api.github.com/repos/NixOS/nixpkgs/subscription","commits_url":"https://api.github.com/repos/NixOS/nixpkgs/commits{/sha}","git_commits_url":"https://api.github.com/repos/NixOS/nixpkgs/git/commits{/sha}","comments_url":"https://api.github.com/repos/NixOS/nixpkgs/comments{/number}","issue_comment_url":"https://api.github.com/repos/NixOS/nixpkgs/issues/comments/{number}","contents_url":"https://api.github.com/repos/NixOS/nixpkgs/contents/{+path}","compare_url":"https://api.github.com/repos/NixOS/nixpkgs/compare/{base}...{head}","merges_url":"https://api.github.com/repos/NixOS/nixpkgs/merges","archive_url":"https://api.github.com/repos/NixOS/nixpkgs/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/NixOS/nixpkgs/downloads","issues_url":"https://api.github.com/repos/NixOS/nixpkgs/issues{/number}","pulls_url":"https://api.github.com/repos/NixOS/nixpkgs/pulls{/number}","milestones_url":"https://api.github.com/repos/NixOS/nixpkgs/milestones{/number}","notifications_url":"https://api.github.com/repos/NixOS/nixpkgs/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/NixOS/nixpkgs/labels{/name}","releases_url":"https://api.github.com/repos/NixOS/nixpkgs/releases{/id}","created_at":"2012-06-04T02:49:46Z","updated_at":"2015-01-26T11:12:19Z","pushed_at":"2015-01-26T11:12:19Z","git_url":"git://github.com/NixOS/nixpkgs.git","ssh_url":"git@github.com:NixOS/nixpkgs.git","clone_url":"https://github.com/NixOS/nixpkgs.git","svn_url":"https://github.com/NixOS/nixpkgs","homepage":null,"size":273730,"stargazers_count":510,"watchers_count":510,"language":"Nix","has_issues":true,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":612,"mirror_url":null,"open_issues_count":535,"forks":612,"open_issues":535,"watchers":510,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/NixOS/nixpkgs/pulls/5892"},"html":{"href":"https://github.com/NixOS/nixpkgs/pull/5892"},"issue":{"href":"https://api.github.com/repos/NixOS/nixpkgs/issues/5892"},"comments":{"href":"https://api.github.com/repos/NixOS/nixpkgs/issues/5892/comments"},"review_comments":{"href":"https://api.github.com/repos/NixOS/nixpkgs/pulls/5892/comments"},"review_comment":{"href":"https://api.github.com/repos/NixOS/nixpkgs/pulls/comments/{number}"},"commits":{"href":"https://api.github.com/repos/NixOS/nixpkgs/pulls/5892/commits"},"statuses":{"href":"https://api.github.com/repos/NixOS/nixpkgs/statuses/aca361fa4960b51e5bcdf13fc826ebdbcb534302"}}}}