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

Remove dead code from stdenv check-meta license logic #47230

Merged
merged 1 commit into from Oct 6, 2018

Conversation

bhipple
Copy link
Contributor

@bhipple bhipple commented Sep 23, 2018

The unfree and unfreeRedistributable licenses both have free = false,
which will trigger the first portion of logic. This removes dead code to
simplify the logic.

As a follow-up, I plan to add an attribute redistributable = [true|false],
which can be used by Hydra to determine whether a given package with a given
license can be included in the channel.

Motivation for this change
Things done
  • Tested using sandboxing (nix.useSandbox on NixOS, or option sandbox in nix.conf on non-NixOS)
  • Built on platform(s)
    • NixOS
    • macOS
    • other Linux distributions
  • Tested via one or more NixOS test(s) if existing and applicable for the change (look inside nixos/tests)
  • Tested compilation of all pkgs that depend on this change using nix-shell -p nox --run "nox-review wip"
  • Tested execution of all binary files (usually in ./result/bin/)
  • Determined the impact on package closure size (by running nix path-info -S before and after)
  • Fits CONTRIBUTING.md.

The `unfree` and `unfreeRedistributable` licenses both have `free = false`,
which will trigger the first portion of logic. This removes dead code to
simplify the logic.

As a follow-up, I plan to add an attribute `redistributable = [true|false]`,
which can be used by Hydra to determine whether a given package with a given
license can be included in the channel.
@@ -42,8 +42,7 @@ let
allowUnsupportedSystem = config.allowUnsupportedSystem or false
|| builtins.getEnv "NIXPKGS_ALLOW_UNSUPPORTED_SYSTEM" == "1";

isUnfree = licenses: lib.lists.any (l:
!l.free or true || l == "unfree" || l == "unfree-redistributable") licenses;
isUnfree = licenses: lib.lists.any (l: !l.free or true) licenses;
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 may be reading this incorrectly, but as far as I can tell both unfree and unfreeRedistributable have free = false, which means the first condition will always return true and we don't need the special casing:
https://github.com/NixOS/nixpkgs/blob/master/lib/licenses.nix#L600-L608

Copy link
Member

Choose a reason for hiding this comment

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

I think this comes from a while back when licenses were just strings - not attrsets. Might be reasonable to just leave it though.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It's somewhat reasonable, I suppose, but it's dead code -- and the stdenv package is already quite big and complicated. I'd argue we should take the opportunity to simplify our logic slightly.

Copy link
Member

Choose a reason for hiding this comment

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

We can just flat up require they not be mere strings elsewhere too

Copy link
Contributor Author

@bhipple bhipple Sep 29, 2018

Choose a reason for hiding this comment

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

Seems like a sensible improvement. I did some initial searching with

git grep 'license = ".*'

and found a few thousand packages with string licenses, but only in ~160 files. Looks like we can fix the bulk of them by updating the Haskell and NodeJS generators to output attr licenses instead of string licenses.

As for the rest, there are quite a few that just say "GPL", but not which GPL version, so it'll take some more effort than just blasting with sed.

@matthewbauer
Copy link
Member

Yeah looks reasonable for now.

@matthewbauer matthewbauer merged commit 93834fe into NixOS:master Oct 6, 2018
@bhipple bhipple deleted the fix/licenses branch February 27, 2019 23:05
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

4 participants