Skip to content

Commit

Permalink
Make the Plutus Tx plugin an internal library
Browse files Browse the repository at this point in the history
The documentation for `addCorePlugin` says it has to be in a separate
package to the plugin. However it appears that in GHC's eyes internal
libraries in a Cabal package are separate packages, so we can hide all
of this in a single package, which is much nicer.

We then have to do some shennanigans to get doctest to work. The normal
tests work fine, since Cabal registers the built internal library as a
package, and that's fine. But doctest interprets things, which *doesn't*
work.

Now, I initially tried to just pass the appropriate `-package-db`
arguments to `doctest`, but in doing so I hit what appears to be a [Cabal
bug with internal libraries](haskell/cabal#5857).
However, somehow `cabal repl` and friends seem to get around this, and
fortunately there is now a `cabal doctest` command, which amazingly
also seems to pass the right set of obscure flags. So we use that.

Finally, in an extremely irritating discovery, apparently [Haddock
doesn't work with internal libraries]
(haskell/cabal#4969) (possibly fixed in a
newer Cabal, who knows), so I ended up having to exclude `plutus-tx`
from Haddock generation for now.
  • Loading branch information
michaelpj committed Jan 23, 2019
1 parent fc145b5 commit afe1176
Show file tree
Hide file tree
Showing 143 changed files with 301 additions and 362 deletions.
2 changes: 0 additions & 2 deletions cabal.project
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,13 @@ packages: language-plutus-core
plutus-exe
wallet-api
plutus-tx
plutus-tx-plugin
plutus-use-cases
plutus-ir
plutus-playground/plutus-playground-server
plutus-playground/plutus-playground-lib
optimization: 2
constraints: language-plutus-core +development
, wallet-api +development
, plutus-tx-plugin +development
, plutus-exe +development
, plutus-core-interpreter +development
, plutus-ir +development
Expand Down
14 changes: 9 additions & 5 deletions default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -78,24 +78,28 @@ let
filter = localLib.isPlutus;
};
customOverlays = optional forceError errorOverlay;
# Filter down to local packages, except those named in the given list
localButNot = nope:
let okay = builtins.filter (name: !(builtins.elem name nope)) localLib.plutusPkgList;
in name: builtins.elem name okay;
in self.callPackage localLib.iohkNix.haskellPackages {
inherit forceDontCheck enableProfiling enablePhaseMetrics
enableHaddockHydra enableBenchmarks fasterBuild enableDebugging
enableSplitCheck customOverlays;
pkgsGenerated = ./pkgs;
filter = localLib.isPlutus;
filterOverrides = {
splitCheck = let
dontSplit = [
splitCheck = localButNot [
# Broken for things with test tool dependencies
"wallet-api"
"plutus-tx"
# Broken for things which pick up other files at test runtime
"plutus-playground-server"
];
# Split only local packages not in the don't split list
doSplit = builtins.filter (name: !(builtins.elem name dontSplit)) localLib.plutusPkgList;
in name: builtins.elem name doSplit;
haddock = localButNot [
# Haddock is broken for things with internal libraries
"plutus-tx"
];
};
requiredOverlay = ./nix/overlays/required.nix;
};
Expand Down
7 changes: 6 additions & 1 deletion nix/overlays/required.nix
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,20 @@ let
addRealTimeTestLogs = drv: overrideCabal drv (attrs: {
testTarget = "--show-details=streaming";
});
doctest = opts: drv: overrideCabal drv (attrs: {
postCheck = "./Setup doctest --doctest-options=\"${opts}\"";
});
in

self: super: {

########################################################################
# Overides of local packages
language-plutus-core = addRealTimeTestLogs super.language-plutus-core;
# cabal doctest doesn't seem to be clever enough to pick these up from the cabal file
plutus-tx = doctest "-pgmL markdown-unlit -XTemplateHaskell -XDeriveFunctor -XScopedTypeVariables" super.plutus-tx;

########################################################################
language-plutus-core = addRealTimeTestLogs super.language-plutus-core;
# The base Haskell package builder

mkDerivation = args: super.mkDerivation (args //
Expand Down
79 changes: 11 additions & 68 deletions pkgs/default.nix

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,6 @@ library
, bytestring
, containers
, plutus-tx -any
, plutus-tx-plugin -any
, hint >= 0.9.0
, http-media
, insert-ordered-containers
Expand Down Expand Up @@ -79,4 +78,4 @@ test-suite playground-lib-test
ghc-options:
-Wall -Wnoncanonical-monad-instances
-Wincomplete-uni-patterns -Wincomplete-record-updates
-Wredundant-constraints -Widentities
-Wredundant-constraints -Widentities
11 changes: 0 additions & 11 deletions plutus-tx-plugin/LICENSE

This file was deleted.

13 changes: 0 additions & 13 deletions plutus-tx-plugin/README.md

This file was deleted.

Loading

0 comments on commit afe1176

Please sign in to comment.