-
Notifications
You must be signed in to change notification settings - Fork 250
Adds sublib support #63
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
Merged
Merged
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
module Main where | ||
|
||
main :: IO () | ||
main = putStrLn "Hello, Haskell!" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
import Distribution.Simple | ||
main = defaultMain |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
cabal-version: 2.2 | ||
-- Initial package description 'cabal-simple.cabal' generated by 'cabal | ||
-- init'. For further documentation, see | ||
-- http://haskell.org/cabal/users-guide/ | ||
|
||
name: cabal-sublib | ||
version: 0.1.0.0 | ||
-- synopsis: | ||
-- description: | ||
-- bug-reports: | ||
license: MIT | ||
author: Moritz Angermann | ||
maintainer: [email protected] | ||
-- category: | ||
build-type: Simple | ||
|
||
library | ||
-- exposed-modules: | ||
-- other-modules: | ||
-- other-extensions: | ||
build-depends: base >=4.11 && <4.12 | ||
, slib | ||
-- hs-source-dirs: | ||
default-language: Haskell2010 | ||
|
||
library slib | ||
build-depends: extra | ||
, safe | ||
, aeson | ||
default-language: Haskell2010 | ||
|
||
executable cabal-sublib | ||
main-is: Main.hs | ||
-- other-modules: | ||
-- other-extensions: | ||
build-depends: base >=4.11 && <4.12 | ||
, cabal-sublib | ||
, extra | ||
, optparse-applicative | ||
-- hs-source-dirs: | ||
default-language: Haskell2010 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
{ system, compiler, flags, pkgs, hsPkgs, pkgconfPkgs, ... }: | ||
{ | ||
flags = {}; | ||
package = { | ||
specVersion = "2.2"; | ||
identifier = { name = "cabal-sublib"; version = "0.1.0.0"; }; | ||
license = "MIT"; | ||
copyright = ""; | ||
maintainer = "[email protected]"; | ||
author = "Moritz Angermann"; | ||
homepage = ""; | ||
url = ""; | ||
synopsis = ""; | ||
description = ""; | ||
buildType = "Simple"; | ||
}; | ||
components = { | ||
"library" = { depends = [ (hsPkgs.base) (hsPkgs.slib) ]; }; | ||
sublibs = { | ||
"slib" = { depends = [ (hsPkgs.extra) (hsPkgs.safe) (hsPkgs.aeson) ]; }; | ||
}; | ||
exes = { | ||
"cabal-sublib" = { | ||
depends = [ | ||
(hsPkgs.base) | ||
(hsPkgs.cabal-sublib) | ||
(hsPkgs.extra) | ||
(hsPkgs.optparse-applicative) | ||
]; | ||
}; | ||
}; | ||
}; | ||
} // rec { src = (pkgs.lib).mkDefault ./.; } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
# Test a package set | ||
{ stdenv, util, mkPkgSet }: | ||
|
||
with stdenv.lib; | ||
|
||
let | ||
## steps to generate local files | ||
# 1. cabal-to-nix cabal-sublib.cabal > cabal-sublib.nix | ||
# 2. cabal new-build | ||
# 3. plan-to-nix ./dist-newstyle/cache/plan.json > plan.nix | ||
pkgSet = mkPkgSet { | ||
pkg-def = import ./plan.nix; | ||
pkg-def-overlays = [ | ||
{ cabal-sublib = ./cabal-sublib.nix; | ||
} | ||
]; | ||
modules = [ | ||
{ | ||
# Package has no exposed modules which causes | ||
# haddock: No input file(s) | ||
packages.cabal-sublib.doHaddock = false; | ||
} | ||
]; | ||
}; | ||
|
||
packages = pkgSet.config.hsPkgs; | ||
|
||
in | ||
stdenv.mkDerivation { | ||
name = "cabal-sublib-test"; | ||
|
||
buildCommand = '' | ||
exe="${packages.cabal-sublib.components.exes.cabal-sublib}/bin/cabal-sublib" | ||
|
||
size=$(command stat --format '%s' "$exe") | ||
printf "size of executable $exe is $size. \n" >& 2 | ||
|
||
# fixme: run on target platform when cross-compiled | ||
printf "checking whether executable runs... " >& 2 | ||
$exe | ||
|
||
printf "checking that executable is dynamically linked to system libraries... " >& 2 | ||
'' + optionalString stdenv.isLinux '' | ||
ldd $exe | grep libpthread | ||
'' + optionalString stdenv.isDarwin '' | ||
otool -L $exe |grep .dylib | ||
'' + '' | ||
|
||
printf "Checking that \"all\" component has the programs... " >& 2 | ||
all_exe="${packages.cabal-sublib.components.all}/bin/cabal-sublib" | ||
test -f "$all_exe" | ||
echo "$all_exe" >& 2 | ||
|
||
touch $out | ||
''; | ||
|
||
meta.platforms = platforms.all; | ||
|
||
passthru = { | ||
# Used for debugging with nix repl | ||
inherit pkgSet packages; | ||
|
||
# Used for testing externally with nix-shell (../tests.sh). | ||
# This just adds cabal-install to the existing shells. | ||
test-shell = util.addCabalInstall packages.cabal-sublib.components.all; | ||
}; | ||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,111 @@ | ||
hackage: | ||
{ | ||
packages = { | ||
"binary".revision = hackage."binary"."0.8.5.1".revisions.default; | ||
"ghc-prim".revision = hackage."ghc-prim"."0.5.2.0".revisions.default; | ||
"extra".revision = hackage."extra"."1.6.14".revisions.default; | ||
"stm".revision = hackage."stm"."2.4.5.1".revisions.default; | ||
"unix".revision = hackage."unix"."2.7.2.2".revisions.default; | ||
"rts".revision = hackage."rts"."1.0".revisions.default; | ||
"clock".revision = hackage."clock"."0.7.2".revisions.default; | ||
"clock".flags.llvm = false; | ||
"scientific".revision = hackage."scientific"."0.3.6.2".revisions.default; | ||
"scientific".flags.integer-simple = false; | ||
"scientific".flags.bytestring-builder = false; | ||
"deepseq".revision = hackage."deepseq"."1.4.3.0".revisions.default; | ||
"random".revision = hackage."random"."1.1".revisions.default; | ||
"uuid-types".revision = hackage."uuid-types"."1.0.3".revisions.default; | ||
"optparse-applicative".revision = hackage."optparse-applicative"."0.14.3.0".revisions.default; | ||
"dlist".revision = hackage."dlist"."0.8.0.5".revisions.default; | ||
"directory".revision = hackage."directory"."1.3.1.5".revisions.default; | ||
"transformers-compat".revision = hackage."transformers-compat"."0.6.2".revisions.default; | ||
"transformers-compat".flags.five = false; | ||
"transformers-compat".flags.generic-deriving = true; | ||
"transformers-compat".flags.two = false; | ||
"transformers-compat".flags.five-three = true; | ||
"transformers-compat".flags.mtl = true; | ||
"transformers-compat".flags.four = false; | ||
"transformers-compat".flags.three = false; | ||
"template-haskell".revision = hackage."template-haskell"."2.13.0.0".revisions.default; | ||
"vector".revision = hackage."vector"."0.12.0.2".revisions.default; | ||
"vector".flags.unsafechecks = false; | ||
"vector".flags.internalchecks = false; | ||
"vector".flags.wall = false; | ||
"vector".flags.boundschecks = true; | ||
"primitive".revision = hackage."primitive"."0.6.4.0".revisions.default; | ||
"time-locale-compat".revision = hackage."time-locale-compat"."0.1.1.5".revisions.default; | ||
"time-locale-compat".flags.old-locale = false; | ||
"safe".revision = hackage."safe"."0.3.17".revisions.default; | ||
"base-compat".revision = hackage."base-compat"."0.10.5".revisions.default; | ||
"ansi-terminal".revision = hackage."ansi-terminal"."0.8.2".revisions.default; | ||
"ansi-terminal".flags.example = false; | ||
"tagged".revision = hackage."tagged"."0.8.6".revisions.default; | ||
"tagged".flags.transformers = true; | ||
"tagged".flags.deepseq = true; | ||
"containers".revision = hackage."containers"."0.5.11.0".revisions.default; | ||
"integer-logarithms".revision = hackage."integer-logarithms"."1.0.2.2".revisions.default; | ||
"integer-logarithms".flags.check-bounds = false; | ||
"integer-logarithms".flags.integer-gmp = true; | ||
"bytestring".revision = hackage."bytestring"."0.10.8.2".revisions.default; | ||
"ansi-wl-pprint".revision = hackage."ansi-wl-pprint"."0.6.8.2".revisions.default; | ||
"ansi-wl-pprint".flags.example = false; | ||
"StateVar".revision = hackage."StateVar"."1.1.1.1".revisions.default; | ||
"contravariant".revision = hackage."contravariant"."1.5".revisions.default; | ||
"contravariant".flags.semigroups = true; | ||
"contravariant".flags.tagged = true; | ||
"contravariant".flags.statevar = true; | ||
"contravariant".flags.safe = false; | ||
"text".revision = hackage."text"."1.2.3.1".revisions.default; | ||
"unordered-containers".revision = hackage."unordered-containers"."0.2.9.0".revisions.default; | ||
"unordered-containers".flags.debug = false; | ||
"base".revision = hackage."base"."4.11.1.0".revisions.default; | ||
"time".revision = hackage."time"."1.8.0.2".revisions.default; | ||
"transformers".revision = hackage."transformers"."0.5.5.0".revisions.default; | ||
"hashable".revision = hackage."hashable"."1.2.7.0".revisions.default; | ||
"hashable".flags.sse2 = true; | ||
"hashable".flags.integer-gmp = true; | ||
"hashable".flags.sse41 = false; | ||
"hashable".flags.examples = false; | ||
"attoparsec".revision = hackage."attoparsec"."0.13.2.2".revisions.default; | ||
"attoparsec".flags.developer = false; | ||
"colour".revision = hackage."colour"."2.3.4".revisions.default; | ||
"filepath".revision = hackage."filepath"."1.4.2".revisions.default; | ||
"process".revision = hackage."process"."1.6.3.0".revisions.default; | ||
"pretty".revision = hackage."pretty"."1.1.3.6".revisions.default; | ||
"aeson".revision = hackage."aeson"."1.4.2.0".revisions.default; | ||
"aeson".flags.cffi = false; | ||
"aeson".flags.fast = false; | ||
"aeson".flags.bytestring-builder = false; | ||
"aeson".flags.developer = false; | ||
"ghc-boot-th".revision = hackage."ghc-boot-th"."8.4.4".revisions.default; | ||
"th-abstraction".revision = hackage."th-abstraction"."0.2.10.0".revisions.default; | ||
"array".revision = hackage."array"."0.5.2.0".revisions.default; | ||
"integer-gmp".revision = hackage."integer-gmp"."1.0.2.0".revisions.default; | ||
}; | ||
compiler = { | ||
version = "8.4.4"; | ||
nix-name = "ghc844"; | ||
packages = { | ||
"binary" = "0.8.5.1"; | ||
"ghc-prim" = "0.5.2.0"; | ||
"stm" = "2.4.5.1"; | ||
"unix" = "2.7.2.2"; | ||
"rts" = "1.0"; | ||
"deepseq" = "1.4.3.0"; | ||
"directory" = "1.3.1.5"; | ||
"template-haskell" = "2.13.0.0"; | ||
"containers" = "0.5.11.0"; | ||
"bytestring" = "0.10.8.2"; | ||
"text" = "1.2.3.1"; | ||
"base" = "4.11.1.0"; | ||
"time" = "1.8.0.2"; | ||
"transformers" = "0.5.5.0"; | ||
"filepath" = "1.4.2"; | ||
"process" = "1.6.3.0"; | ||
"pretty" = "1.1.3.6"; | ||
"ghc-boot-th" = "8.4.4"; | ||
"array" = "0.5.2.0"; | ||
"integer-gmp" = "1.0.2.0"; | ||
}; | ||
}; | ||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Shouldn't there only be one package per derivation? Why would there be multiple?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think the issue is the
all
target. If you run the following on a cabal file with a sublibrary:you end up with a folder for
pkg.conf
that contains the package configuration file for the library as well as the sublibrary.If you don't have sublibraries,
pkg.conf
is your package configuration file.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@angerman So this only comes up when a package depends on the
all
component? That shouldn't happen, should it?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why should this not happen? Why wouldn't we build the
all
component? We do allow this right now (and the test case tried to do precisely that).Thus, unless we want to remove the
all
component again, I'm afraid we'll need to keep this.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@angerman The all component is, to my understanding, only for the sake of users who want a shell for all, plus the novel purpose of building all components in one derivation. The intention is that components will depend on components, not on any
all
derivation.