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

Failure to recognise the license in stack new simple-library template. #117

Closed
philderbeast opened this issue Aug 18, 2018 · 4 comments
Closed

Comments

@philderbeast
Copy link
Contributor

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
@nh2
Copy link
Member

nh2 commented Aug 24, 2018

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

nh2 added a commit to nh2/stack2nix that referenced this issue Aug 24, 2018
nh2 added a commit to nh2/stack2nix that referenced this issue Aug 25, 2018
nh2 added a commit to nh2/stack2nix that referenced this issue Aug 25, 2018
@philderbeast
Copy link
Contributor Author

philderbeast commented Aug 25, 2018

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

nh2 added a commit to nh2/stack2nix that referenced this issue Sep 3, 2018
@domenkozar
Copy link
Contributor

@philderbeast you're hitting #103

@domenkozar
Copy link
Contributor

Original issue has been fixed and released in stack 0.2.1, the second issue is in #103 so closing.

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

Successfully merging a pull request may close this issue.

3 participants