Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions cabal2nix/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
# Revision History for cabal2nix

## Upcomming

* Complex licenses now make use of the compound license system added in [nixpkgs#468378](https://github.com/NixOS/nixpkgs/pull/468378).
* Unknown licenses are now treated as if they unfree packages.
* Most licenses that where previously represented as strings are now show as a generic free license.

## 2.21.3

* Add `--src-expression` flag to `cabal2nix` which allows overriding
Expand Down
2 changes: 1 addition & 1 deletion cabal2nix/src/Distribution/Nixpkgs/Haskell/FromCabal.hs
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,7 @@ fromPackageDescription haskellResolver nixpkgsResolver missingDeps flags Package
& Nix.license .~ nixLicense
& Nix.platforms .~ Nothing
& Nix.badPlatforms .~ Nothing
& Nix.hydraPlatforms .~ (if isFreeLicense nixLicense then Nothing else Just Set.empty)
& Nix.hydraPlatforms .~ Nothing
& Nix.mainProgram .~ nixMainProgram
& Nix.maintainers .~ mempty
& Nix.broken .~ not (null missingDeps)
Expand Down
46 changes: 24 additions & 22 deletions cabal2nix/src/Distribution/Nixpkgs/Haskell/FromCabal/License.hs
Original file line number Diff line number Diff line change
Expand Up @@ -9,24 +9,25 @@ module Distribution.Nixpkgs.Haskell.FromCabal.License
import Data.List (intercalate)
import Distribution.License ( License(..), knownLicenses )
import Distribution.Nixpkgs.License
import Distribution.Pretty (prettyShow)
import Distribution.Pretty as DP
import Language.Nix.PrettyPrinting as NPP
import qualified Distribution.SPDX as SPDX
import Distribution.Text (display)
import Distribution.Version

-- TODO: Programmatically strip trailing zeros from license version numbers.

fromCabalLicense :: Distribution.License.License -> Distribution.Nixpkgs.License.License
fromCabalLicense (GPL Nothing) = Unknown (Just "GPL")
fromCabalLicense (GPL Nothing) = Known "lib.licenses.free"
fromCabalLicense (GPL (Just (versionNumbers -> [2]))) = Known "lib.licenses.gpl2Only"
fromCabalLicense (GPL (Just (versionNumbers -> [3]))) = Known "lib.licenses.gpl3Only"
fromCabalLicense (GPL (Just (versionNumbers -> [3,0]))) = Known "lib.licenses.gpl3Only"
fromCabalLicense (LGPL Nothing) = Unknown (Just "LGPL")
fromCabalLicense (LGPL Nothing) = Known "lib.licenses.free"
fromCabalLicense (LGPL (Just (versionNumbers -> [2,1]))) = Known "lib.licenses.lgpl21Only"
fromCabalLicense (LGPL (Just (versionNumbers -> [2]))) = Known "lib.licenses.lgpl2Only"
fromCabalLicense (LGPL (Just (versionNumbers -> [3]))) = Known "lib.licenses.lgpl3Only"
fromCabalLicense (LGPL (Just (versionNumbers -> [3,0]))) = Known "lib.licenses.lgpl3Only"
fromCabalLicense (AGPL Nothing) = Unknown (Just "AGPL")
fromCabalLicense (AGPL Nothing) = Known "lib.licenses.free"
fromCabalLicense (AGPL (Just (versionNumbers -> [3]))) = Known "lib.licenses.agpl3Only"
fromCabalLicense (AGPL (Just (versionNumbers -> [3,0]))) = Known "lib.licenses.agpl3Only"
fromCabalLicense (MPL (versionNumbers -> [2,0])) = Known "lib.licenses.mpl20"
Expand All @@ -40,29 +41,30 @@ fromCabalLicense AllRightsReserved = Known "lib.licenses
fromCabalLicense (Apache Nothing) = Known "lib.licenses.asl20"
fromCabalLicense (Apache (Just (versionNumbers -> [2,0]))) = Known "lib.licenses.asl20"
fromCabalLicense ISC = Known "lib.licenses.isc"
fromCabalLicense OtherLicense = Unknown Nothing
fromCabalLicense OtherLicense = Known "lib.licenses.unfree"
fromCabalLicense (UnknownLicense "CC0-1.0") = Known "lib.licenses.cc0"
fromCabalLicense (UnknownLicense "BSD3ClauseORApache20") = Known "lib.licenses.bsd3"
fromCabalLicense (UnknownLicense "BSD3ClauseORApache20") = Known "lib.licenses.OR [ lib.licenses.bsd3 lib.licenses.asl20 ]"
fromCabalLicense l = error $ "Distribution.Nixpkgs.Haskell.FromCabal.License.fromCabalLicense: unknown license"
++ show l ++"\nChoose one of: " ++ intercalate ", " (map display knownLicenses)

-- FIXME(@sternenseemann): this is not exactly Known, but a best effort lookup
fromSPDXExpression :: SPDX.LicenseExpression -> Distribution.Nixpkgs.License.License
fromSPDXExpression (SPDX.ELicense simpl Nothing) =
case simpl of
SPDX.ELicenseId lid -> Known ("lib.meta.getLicenseFromSpdxId \"" ++ DP.prettyShow lid ++ "\"")
SPDX.ELicenseIdPlus lid -> Known ("lib.licenses.PLUS (lib.meta.getLicenseFromSpdxId \"" ++ DP.prettyShow lid ++ "\")")
SPDX.ELicenseRef lid -> Known ("lib.meta.getLicenseFromSpdxId \"" ++ DP.prettyShow lid ++ "\"")
fromSPDXExpression (SPDX.ELicense simpl (Just excep)) =
case simpl of
SPDX.ELicenseId lid -> Known ("lib.licenses.WITH (lib.meta.getLicenseFromSpdxId \"" ++ DP.prettyShow lid ++ "\") (lib.meta.getLicenseFromSpdxId \"" ++ DP.prettyShow excep ++ "\")")
SPDX.ELicenseIdPlus lid -> Known ("lib.licenses.WITH (lib.licenses.PLUS (lib.meta.getLicenseFromSpdxId \"" ++ DP.prettyShow lid ++ "\")) (lib.meta.getLicenseFromSpdxId \"" ++ DP.prettyShow excep ++ "\")")
SPDX.ELicenseRef lid -> Known ("lib.licenses.WITH (lib.licenses.PLUS (lib.meta.getLicenseFromSpdxId \"" ++ DP.prettyShow lid ++ "\")) (lib.meta.getLicenseFromSpdxId \"" ++ DP.prettyShow excep ++ "\")")
fromSPDXExpression (SPDX.EAnd expres1 expres2) = Known ("lib.licenses.AND [ (" ++ NPP.prettyShow (fromSPDXExpression expres1) ++ ") (" ++ NPP.prettyShow (fromSPDXExpression expres2) ++ ") ]")
fromSPDXExpression (SPDX.EOr expres1 expres2) = Known ("lib.licenses.AND [ (" ++ NPP.prettyShow (fromSPDXExpression expres1) ++ ") (" ++ NPP.prettyShow (fromSPDXExpression expres2) ++ ") ]")

fromSPDXLicense :: SPDX.License -> Distribution.Nixpkgs.License.License
fromSPDXLicense SPDX.NONE = Unknown Nothing
fromSPDXLicense (SPDX.License expr) =
case expr of
SPDX.ELicense simpl Nothing ->
-- Not handled: license exceptions
case simpl of
-- FIXME(@sternenseemann): this is not exactly Known, but a best effort lookup
SPDX.ELicenseId lid -> Known ("lib.meta.getLicenseFromSpdxId \"" ++ prettyShow lid ++ "\"")
_ ->
-- Not handed: the '+' suffix and user-defined licences references.
-- Use the SPDX expression as a free-form license string.
Unknown (Just $ prettyShow expr)
_ ->
-- Not handled: compound expressions, not expressible in Nixpkgs.
-- Use the SPDX expression as a free-form license string.
Unknown (Just $ prettyShow expr)
fromSPDXLicense SPDX.NONE = Known "lib.licenses.unfree"
fromSPDXLicense (SPDX.License expr) = fromSPDXExpression expr

-- "isFreeLicense" is used to determine whether we generate a "hydraPlatforms =
-- none" in the hackage2nix output for a package with the given license.
Expand Down
2 changes: 1 addition & 1 deletion cabal2nix/test/golden-test-cases/HTF.nix.golden
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,6 @@ mkDerivation {
];
homepage = "https://github.com/skogsbaer/HTF/";
description = "The Haskell Test Framework";
license = "LGPL";
license = lib.licenses.free;
mainProgram = "htfpp";
}
2 changes: 1 addition & 1 deletion cabal2nix/test/golden-test-cases/bioalign.nix.golden
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,5 @@ mkDerivation {
libraryHaskellDepends = [ base biocore bytestring ];
homepage = "https://patch-tag.com/r/dfornika/biophd/home";
description = "Data structures and helper functions for calculating alignments";
license = "GPL";
license = lib.licenses.free;
}
2 changes: 1 addition & 1 deletion cabal2nix/test/golden-test-cases/ede.nix.golden
Original file line number Diff line number Diff line change
Expand Up @@ -20,5 +20,5 @@ mkDerivation {
];
homepage = "http://github.com/brendanhay/ede";
description = "Templating language with similar syntax and features to Liquid or Jinja2";
license = "unknown";
license = lib.licenses.unfree;
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,5 @@ mkDerivation {
libraryHaskellDepends = [ base gogol-core ];
homepage = "https://github.com/brendanhay/gogol";
description = "Google Ad Exchange Buyer SDK";
license = "unknown";
license = lib.licenses.unfree;
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,5 @@ mkDerivation {
libraryHaskellDepends = [ base gogol-core ];
homepage = "https://github.com/brendanhay/gogol";
description = "Google Email Migration API v2 SDK";
license = "unknown";
license = lib.licenses.unfree;
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,5 @@ mkDerivation {
libraryHaskellDepends = [ base gogol-core ];
homepage = "https://github.com/brendanhay/gogol";
description = "Google Affiliate Network SDK";
license = "unknown";
license = lib.licenses.unfree;
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,5 @@ mkDerivation {
libraryHaskellDepends = [ base gogol-core ];
homepage = "https://github.com/brendanhay/gogol";
description = "Google Tasks SDK";
license = "unknown";
license = lib.licenses.unfree;
}
2 changes: 1 addition & 1 deletion cabal2nix/test/golden-test-cases/gogol-appstate.nix.golden
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,5 @@ mkDerivation {
libraryHaskellDepends = [ base gogol-core ];
homepage = "https://github.com/brendanhay/gogol";
description = "Google App State SDK";
license = "unknown";
license = lib.licenses.unfree;
}
2 changes: 1 addition & 1 deletion cabal2nix/test/golden-test-cases/gogol-blogger.nix.golden
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,5 @@ mkDerivation {
libraryHaskellDepends = [ base gogol-core ];
homepage = "https://github.com/brendanhay/gogol";
description = "Google Blogger SDK";
license = "unknown";
license = lib.licenses.unfree;
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,5 @@ mkDerivation {
libraryHaskellDepends = [ base gogol-core ];
homepage = "https://github.com/brendanhay/gogol";
description = "Google Cloud Datastore SDK";
license = "unknown";
license = lib.licenses.unfree;
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,5 @@ mkDerivation {
libraryHaskellDepends = [ base gogol-core ];
homepage = "https://github.com/brendanhay/gogol";
description = "Google DCM/DFA Reporting And Trafficking SDK";
license = "unknown";
license = lib.licenses.unfree;
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,5 @@ mkDerivation {
libraryHaskellDepends = [ base gogol-core ];
homepage = "https://github.com/brendanhay/gogol";
description = "Google Firebase Rules SDK";
license = "unknown";
license = lib.licenses.unfree;
}
2 changes: 1 addition & 1 deletion cabal2nix/test/golden-test-cases/gogol-gmail.nix.golden
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,5 @@ mkDerivation {
libraryHaskellDepends = [ base gogol-core ];
homepage = "https://github.com/brendanhay/gogol";
description = "Google Gmail SDK";
license = "unknown";
license = lib.licenses.unfree;
}
2 changes: 1 addition & 1 deletion cabal2nix/test/golden-test-cases/gogol-kgsearch.nix.golden
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,5 @@ mkDerivation {
libraryHaskellDepends = [ base gogol-core ];
homepage = "https://github.com/brendanhay/gogol";
description = "Google Knowledge Graph Search SDK";
license = "unknown";
license = lib.licenses.unfree;
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,5 @@ mkDerivation {
libraryHaskellDepends = [ base gogol-core ];
homepage = "https://github.com/brendanhay/gogol";
description = "Google Maps Engine SDK";
license = "unknown";
license = lib.licenses.unfree;
}
2 changes: 1 addition & 1 deletion cabal2nix/test/golden-test-cases/gogol-plus.nix.golden
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,5 @@ mkDerivation {
libraryHaskellDepends = [ base gogol-core ];
homepage = "https://github.com/brendanhay/gogol";
description = "Google + SDK";
license = "unknown";
license = lib.licenses.unfree;
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,5 @@ mkDerivation {
libraryHaskellDepends = [ base gogol-core ];
homepage = "https://github.com/brendanhay/gogol";
description = "Google Compute Engine Instance Groups SDK";
license = "unknown";
license = lib.licenses.unfree;
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,5 @@ mkDerivation {
libraryHaskellDepends = [ base gogol-core ];
homepage = "https://github.com/brendanhay/gogol";
description = "Google Translate SDK";
license = "unknown";
license = lib.licenses.unfree;
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,5 @@ mkDerivation {
libraryHaskellDepends = [ base gogol-core ];
homepage = "https://github.com/brendanhay/gogol";
description = "Google Search Console SDK";
license = "unknown";
license = lib.licenses.unfree;
}
2 changes: 1 addition & 1 deletion cabal2nix/test/golden-test-cases/gogol-youtube.nix.golden
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,5 @@ mkDerivation {
libraryHaskellDepends = [ base gogol-core ];
homepage = "https://github.com/brendanhay/gogol";
description = "Google YouTube Data SDK";
license = "unknown";
license = lib.licenses.unfree;
}
Original file line number Diff line number Diff line change
Expand Up @@ -18,5 +18,5 @@ mkDerivation {
];
homepage = "http://github.com/jgm/highlighting-kate";
description = "Syntax highlighting";
license = "GPL";
license = lib.licenses.free;
}
2 changes: 1 addition & 1 deletion cabal2nix/test/golden-test-cases/hxt-expat.nix.golden
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,5 @@ mkDerivation {
libraryHaskellDepends = [ base bytestring hexpat hxt ];
homepage = "http://www.fh-wedel.de/~si/HXmlToolbox/index.html";
description = "Expat parser for HXT";
license = "unknown";
license = lib.licenses.unfree;
}
2 changes: 1 addition & 1 deletion cabal2nix/test/golden-test-cases/hxt-tagsoup.nix.golden
Original file line number Diff line number Diff line change
Expand Up @@ -10,5 +10,5 @@ mkDerivation {
];
homepage = "https://github.com/UweSchmidt/hxt";
description = "TagSoup parser for HXT";
license = "unknown";
license = lib.licenses.unfree;
}
Original file line number Diff line number Diff line change
Expand Up @@ -14,5 +14,5 @@ mkDerivation {
];
homepage = "https://github.com/blamario/incremental-parser";
description = "Generic parser library capable of providing partial results from partial input";
license = "GPL";
license = lib.licenses.free;
}
Original file line number Diff line number Diff line change
Expand Up @@ -10,5 +10,5 @@ mkDerivation {
];
homepage = "https://wiki.haskell.org/Lambdabot";
description = "Social plugins for Lambdabot";
license = "GPL";
license = lib.licenses.free;
}
Original file line number Diff line number Diff line change
Expand Up @@ -14,5 +14,5 @@ mkDerivation {
];
homepage = "http://floss.scru.org/openpgp-asciiarmor";
description = "OpenPGP (RFC4880) ASCII Armor codec";
license = "unknown";
license = lib.licenses.unfree;
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,5 @@ mkDerivation {
sha256 = "deadbeef";
libraryHaskellDepends = [ base vector ];
description = "A solver for systems of polynomial equations in bernstein form";
license = "GPL";
license = lib.licenses.free;
}
2 changes: 1 addition & 1 deletion cabal2nix/test/golden-test-cases/readline.nix.golden
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,5 @@ mkDerivation {
libraryHaskellDepends = [ base process ];
librarySystemDepends = [ ncurses readline ];
description = "An interface to the GNU readline library";
license = "GPL";
license = lib.licenses.free;
}
2 changes: 1 addition & 1 deletion cabal2nix/test/golden-test-cases/swagger.nix.golden
Original file line number Diff line number Diff line change
Expand Up @@ -10,5 +10,5 @@ mkDerivation {
];
testHaskellDepends = [ aeson base bytestring tasty tasty-hunit ];
description = "Implementation of swagger data model";
license = "unknown";
license = lib.licenses.unfree;
}
2 changes: 1 addition & 1 deletion cabal2nix/test/golden-test-cases/texmath.nix.golden
Original file line number Diff line number Diff line change
Expand Up @@ -17,5 +17,5 @@ mkDerivation {
];
homepage = "http://github.com/jgm/texmath";
description = "Conversion between formats used to represent mathematics";
license = "GPL";
license = lib.licenses.free;
}
Original file line number Diff line number Diff line change
Expand Up @@ -13,5 +13,5 @@ mkDerivation {
vivid-osc
];
description = "Implementation of SuperCollider server specifications";
license = "GPL";
license = lib.licenses.free;
}
Loading