Failure to recognise the license in stack new simple-library template.
philderbeast opened this issue · 4 comments
A new stack project created from template using the simple-library template fails conversion with stack2nix.
To reproduce this, create a new stack project using the simple-library template. Run stack2nix on this as a local path. The license is described as BSD3 in package.yaml and there is a LICENSE file but the conversion stops and reports an error of;
unknown licenseUnknownLicense "BSD3ClauseORApache20"
I have a repository with this test case.
> stack new simple-library
Downloading template "new-template" to create project "simple-library" in simple-library/ ...
The following parameters were needed by the template but not provided: author-email, author-name, category, copyright, github-username
You can provide them in /Users/pdejoux/.stack/config.yaml, like this:
templates:
params:
author-email: value
author-name: value
category: value
copyright: value
github-username: value
Or you can pass each one as parameters like this:
stack new simple-library new-template -p "author-email:value" -p "author-name:value" -p "category:value" -p "copyright:value" -p "github-username:value"
Looking for .cabal or package.yaml files to use to init the project.
Using cabal packages:
- simple-library/
Selecting the best among 14 snapshots...
* Matches lts-12.6
Selected resolver: lts-12.6
Initialising configuration using resolver: lts-12.6
Total number of user packages considered: 1
Writing configuration to file: simple-library/stack.yaml
All done.
> cd simple-library
simple-library> stack2nix --verbose . > default.nix
Ensuring git version is >= 2 ...
Ensuring cabal version is >= 2 ...
stack2nix (isLocalRepo): True
stack2nix (projRoot): "."
stack2nix (argUri): "."
handleStackConfig (cwd): /.../stack2nix-test-cases/simple-library
handleStackConfig (localDir): .
handleStackConfig (remoteUri): Nothing
handleStackConfig (alreadyExists): True
...
+ cabal2nix --subpath . --system x86_64-darwin cabal://ALUT-2.4.0.2
+ cabal2nix --subpath . --system x86_64-darwin cabal://Allure-0.8.3.0
...
+ cabal2nix --subpath . --system x86_64-darwin cabal://zot-0.0.3
+ cabal2nix --subpath . --system x86_64-darwin cabal://ztail-1.2.0.2
stack2nix: Distribution.Nixpkgs.Haskell.FromCabal.License.fromCabalLicense: unknown licenseUnknownLicense "BSD3ClauseORApache20"
Choose one of: GPL, GPL-2, GPL-3, LGPL, LGPL-2.1, LGPL-3, AGPL, AGPL-3, BSD2, BSD3, MIT, ISC, MPL-2.0, Apache, Apache-2.0, PublicDomain, AllRightsReserved, OtherLicense
CallStack (from HasCallStack):
error, called at src/Distribution/Nixpkgs/Haskell/FromCabal/License.hs:39:62 in cabal2nix-2.10.2-46haP2jmk03DpwNz2ajA5I:Distribution.Nixpkgs.Haskell.FromCabal.License
> stack2nix --version
stack2nix 0.2
> cabal2nix --version
cabal2nix 2.10.2
> cabal --version
cabal-install version 2.2.0.0
compiled using version 2.2.0.0 of the Cabal library
> stack --version
Version 1.7.1, Git revision 681c800873816c022739ca7ed14755e85a579565 (5807 commits) x86_64 hpack-0.28.2
This would be fixed by simply bumping the cabal2nix dependency to 2.11: NixOS/cabal2nix@e9ffc2b
That would also fix the same error ocurring when you try to run stack2nix against an lts-12 snapshot; just happened to me with lts-12.7:
...
+ cabal2nix --subpath . --system x86_64-linux --compiler ghc-8.4.3 cabal://ztail-1.2.0.2
+ cabal2nix --subpath . --system x86_64-linux --compiler ghc-8.4.3 cabal://zot-0.0.3
stack2nix: Distribution.Nixpkgs.Haskell.FromCabal.License.fromCabalLicense: unknown licenseUnknownLicense "BSD3ClauseORApache20"
Choose one of: GPL, GPL-2, GPL-3, LGPL, LGPL-2.1, LGPL-3, AGPL, AGPL-3, BSD2, BSD3, MIT, ISC, MPL-2.0, Apache, Apache-2.0, PublicDomain, AllRightsReserved, OtherLicense
CallStack (from HasCallStack):
error, called at src/Distribution/Nixpkgs/Haskell/FromCabal/License.hs:39:62 in cabal2nix-2.10.0-E4bnjsdDIPjsORi1nSTbT:Distribution.Nixpkgs.Haskell.FromCabal.License
Thanks @nh2, I installed stack2nix locally built against cabal2nix-2.11 and it worked for me to generate a nix expression without getting hung up on a license it didn't recognise.
Installing stack2nix using this stack-stack2nix.yaml;
resolver: nightly-2018-08-21
packages:
- location:
git: https://github.com/input-output-hk/stack2nix
commit: 030d161861c6452046a9af9b2855f6a764ee11f5
extra-dep: true
extra-deps:
- cabal2nix-2.11
allow-newer: true
local-bin-path: __build
simple-library> stack install stack2nix --stack-yaml=stack-stack2nix.yaml
simple-library> __build/stack2nix . > default.nix
I was not able to build with the generated nix expression;
simple-library> nix-build
error: anonymous function at /.../stack2nix-test-cases/simple-library/default.nix:1625:10
called without required argument 'Win32',
at /nix/store/zjwjsgxxr12k7xamk2x7pby6fgn3zwjv-nixpkgs-18.09pre149653.dc1b036c962
/nixpkgs/pkgs/development/haskell-modules/make-package-set.nix:88:27
@philderbeast you're hitting #103
Original issue has been fixed and released in stack 0.2.1, the second issue is in #103 so closing.