Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[WIP] Add (optional) license white/blacklisting #5892

Merged
merged 1 commit into from Jan 24, 2015

Conversation

matthiasbeyer
Copy link
Contributor

[WIP]

This adds optional white- or blacklisting for licenses from the users configuration as I proposed on the ML.

Please tell me what you guys think about this.


(I hope the [ci skip] thing worked here... as this is wip)

assert (unfreeOrBroken == "Unfree"
|| unfreeOrBroken == "Broken"
|| unfreeOrBroken == "AllowedLicense"
|| unfreeOrBroken == "BlacklistedLicense");
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You could use

builtins.elem x xs
    Return true if a value equal to x occurs in the list xs, and false otherwise.

to make this shorter. Not sure if it is better from a memory or speed standpoint though.

@wmertens
Copy link
Contributor

So right now if you want to allow a specific unfree license, you need to set allowUnfree and blacklist all the ones you don't like. Wouldn't it be better to let allowedLicenses be empty by default and work as a whitelist?

@matthiasbeyer
Copy link
Contributor Author

So, I'm done for today. I would like to hear some more feedback on this and whether this is a good idea or not, before putting effort in history-cleanup.

But now I need some sleep.


My idea was not to change the type of the allowUnfree setting at all, to be backwards compatible. Of course, the expected behaviour needs some discussion here! A combination of all three would be nice, where each option as a sane default value, of course.

@wmertens
Copy link
Contributor

Behavior I'd expect:

  • allowUnfree* behavior is unchanged
  • whitelistedLicenses enables licenses and overrides allowUnfree*, e.g. allow the Oracle one
  • blacklistedLicense disables licenses even if they're free, e.g. GPLv3

@matthiasbeyer
Copy link
Contributor Author

@wmertens Of course, that's what I'd like too, but how should they play together? If I do not allow unfree licenses but whitelist the Oracle one and then blacklist it again... is it allowed or not?

If I both black- and whitelist GPLv3, is it allowed or not?

@bjornfor
Copy link
Contributor

I'm just jumping in here.

"If I both black- and whitelist GPLv3, is it allowed or not?" -> That's a configuration error that can be caught by an assertion (i.e. it's not allowed).

@matthiasbeyer
Copy link
Contributor Author

"If I both black- and whitelist GPLv3, is it allowed or not?" -> That's a configuration error that can be caught by an assertion (i.e. it's not allowed).

Would be a good idea to do it this way, yes.

@wmertens
Copy link
Contributor

Indeed, assert that blacklist and whitelist are mutually exclusive.
Blacklist gets precedence, then whitelist, then unfree. IMHO ;-)

On Thu Jan 22 2015 at 9:04:26 AM Matthias Beyer notifications@github.com
wrote:

"If I both black- and whitelist GPLv3, is it allowed or not?" -> That's a
configuration error that can be caught by an assertion (i.e. it's not
allowed).

Would be a good idea to do it this way, yes.


Reply to this email directly or view it on GitHub
#5892 (comment).

@matthiasbeyer
Copy link
Contributor Author

I would do it this way:

(Pseudocode ahead!)


if (unfreeAllowed) then
  if (packageBlacklisted? pkg)
    fail
  else install pkg
else # if unfree not allowed
  if (packageWhitelisted? pkg)
    install pkg
  else fail
endif

@wmertens
Copy link
Contributor

Not quite - some companies do not want to use e.g. free GPLv3 software so
they should be able to blacklist free licenses.

On Thu Jan 22 2015 at 12:27:26 PM Matthias Beyer notifications@github.com
wrote:

I would do it this way:

(Pseudocode ahead!)

if (unfreeAllowed) then
if (packageBlacklisted? pkg)
fail
else install pkg
else # if unfree not allowed
if (packageWhitelisted? pkg)
install pkg
else fail
endif


Reply to this email directly or view it on GitHub
#5892 (comment).

@matthiasbeyer
Copy link
Contributor Author

@wmertens look at my latest patch. It does it this way:

if (hasUnallowedUnfreeLicense pkg) && !(hasWhitelistedLicense pkg) then
  fail
else if hasBlacklistedLicense pkg then
  fail
[...]

I will patch hasUnfreeLicense because I consider the name hasUnallowedUnfreeLicense better right now.

@@ -16,6 +16,12 @@ let

allowUnfree = config.allowUnfree or false || builtins.getEnv "NIXPKGS_ALLOW_UNFREE" == "1";

# Allowed licenses, defaults to no licenses
whitelistedLicenses = config.allowedLicenses or [];
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd also like to see config.allowedLicenses renamed...

@wmertens
Copy link
Contributor

I'd expect

    if hasBlacklistedLicense attrs then
      throw...
    else if (! hasWhitelistedLicense attrs) and (hasDeniedUnfreeLicense attrs) then
      throw...
    else

@matthiasbeyer
Copy link
Contributor Author

That's exactly what's implemented right now, isn't it?

The mutual-exclusive check is added as well, of course.

if mutualExclusive whitelistedLicenses blacklistedLicenses then
throw ''
Package blacklist and whitelist are not mutual exclusive.
'';
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That semicolon is unneeded (and I'm surprised it even evaluates)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I skip the CI.

@wmertens
Copy link
Contributor

You don't test locally? Because I think you didn't define mutEx 😁

@matthiasbeyer
Copy link
Contributor Author

I don't test locally because I do not want to test after every change. I want to test once, but do it right, after we agreed on the actual default behaviour.

@wmertens
Copy link
Contributor

well the patch looks good to me so start testing 😉

@matthiasbeyer
Copy link
Contributor Author

@wmertens Okay, can you tell me a way how you'd like this to be tested?

@wmertens
Copy link
Contributor

@matthiasbeyer we don't have unit tests for configuration afaik so simply clone your tree locally and try to evaluate few configurations with packages that have proper and denied licenses...

To evaluate, export NIX_PATH=nixpkgs=...your-tree/ and run nixos-rebuild dry-run -v. Make sure it uses the correct nixpkgs tree.

@matthiasbeyer
Copy link
Contributor Author

I was able to run nixos-rebuild dry-run -v, but as far as I understand it, this does not actually warn if packages which are already installed have a license which is blacklisted, should it?


Edit: I just blacklisted all GPLv2.* licenses, and it does not warn or fail that the linux kernel is installed... so this works only when installing new packages, I guess. Same applies to the normal allowUnfree configuration, right?

@matthiasbeyer
Copy link
Contributor Author

With GPLv2 blacklisted and a new environment.systemPackages entry for cups, which is GPLv2, the nixos-rebuild dry-run -v actually works, but it should fail, shouldn't it? :-)

@wmertens
Copy link
Contributor

Indeed. The -v shows that it is using your copy of the tree? Start
debugging ;-)

On Fri Jan 23 2015 at 3:38:13 PM Matthias Beyer notifications@github.com
wrote:

With GPLv2 blacklisted and a new environment.systemPackages entry for cups,
which is GPLv2, the nixos-rebuild dry-run -v actually works, but it
should fail, shouldn't it? :-)


Reply to this email directly or view it on GitHub
#5892 (comment).

@matthiasbeyer
Copy link
Contributor Author

Somehow, setting the environment variable did not work.

Doing

nixos-rebuild dry-run -v -I nixpkgs=~/nixpkgs

Fails because the linux kernel has a blacklisted license... yay!

I will do more debugging now...

@wmertens
Copy link
Contributor

I see a spurious ';'. Also, can you squash everything into one commit?

@matthiasbeyer matthiasbeyer force-pushed the add-license_selection branch 2 times, most recently from a4e955f to 9a45746 Compare January 23, 2015 16:38
@matthiasbeyer
Copy link
Contributor Author

I guess the work-in-progress label can be removed.

@wmertens
Copy link
Contributor

Can you remove the trace calls, that will also fix the travis build failure.

@matthiasbeyer
Copy link
Contributor Author

@wmertens I'd really love to have these kind of notification, as the users can actually see that there are things which can not be filtered.

Why are there packages without a name?

@wmertens
Copy link
Contributor

Well, trace is for debugging, it's not generally used in nixpkgs at this point in time. If you want to let people know which ones are allowed through, implement a disallowEmptyLicense flag 😁.

assert (builtins.elem unfreeOrBroken [ "Unfree"
"Broken"
"AllowedLicense"
"BlacklistedLicense"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You're not using BlacklistedLicense? Shouldn't AllowedLicense be taken out and instead use BlacklistedLicense?

@matthiasbeyer
Copy link
Contributor Author

Rebased onto latest master as I guess the latest breakage was not caused by my PR...

throwEvalHelp "Unfree" "has an unfree license"
if !(mutualExclusive whitelistedLicenses blacklistedLicenses) then
throw ''
Package blacklist and whitelist are not mutual exclusive.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Two more things : could you name the attributes in this error message and can you squash again?

@matthiasbeyer
Copy link
Contributor Author

@wmertens Can you tell me what causes the travis build failure? Is it caused by one of my patches, actually?

@wmertens
Copy link
Contributor

No, master is broken because of the ruby or python work. However the
previous failure was die to name missing on stdenv...

On Sat, Jan 24, 2015, 3:27 PM Matthias Beyer notifications@github.com
wrote:

@wmertens https://github.com/wmertens Can you tell me what causes the
travis build failure? Is it caused by one of my patches, actually?


Reply to this email directly or view it on GitHub
#5892 (comment).

@wmertens
Copy link
Contributor

Alright it looks good to merge now but can you squash it into a single commit?

@matthiasbeyer
Copy link
Contributor Author

I would actually like to keep the "Remove trace calls by outcommenting" commit as seperate commit. If further work needs to be done in this area, one can simply revert this bit and get this going.

If you really want me to squash it I'll do this, though.

@wmertens
Copy link
Contributor

Yes squash please, uncommenting the calls is easy enough.

@wmertens
Copy link
Contributor

Awesome, thanks! You might want to tell the mailing list about it :-)

wmertens added a commit that referenced this pull request Jan 24, 2015
Add (optional) license white/blacklisting
@wmertens wmertens merged commit be799bb into NixOS:master Jan 24, 2015
@matthiasbeyer matthiasbeyer deleted the add-license_selection branch January 24, 2015 19:15
in
if !allowUnfree && isUnfree (lib.lists.toList attrs.meta.license or []) && !allowUnfreePredicate attrs then
throwEvalHelp "Unfree" "has an unfree license"
if !(mutualExclusive whitelistedLicenses blacklistedLicenses) then
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should be lifted out to prevent it from being evaluated on every call to mkDerivation.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmmm should have caught that sorry. @matthiasbeyer feel like tackling this or shall I do that?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@wmertens Would be nice if you'd do it, I'm in the exams phase now and don't know how long it would take if I'd do it.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done in 0feb19b

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants