Skip to content

Commit

Permalink
Added devShells: dev-prelude-haskell and dev-plutustx for
Browse files Browse the repository at this point in the history
Conveniently playing around with some `.lbf` schemas in Haskell
  • Loading branch information
jared committed Oct 24, 2023
1 parent c1e5a31 commit e6fb64e
Showing 1 changed file with 144 additions and 1 deletion.
145 changes: 144 additions & 1 deletion libs/build.nix
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Foundational .lbf packages
# TODO(bladyjoker): Make packages that actually try and compile.
_:
{ inputs, ... }:
{
perSystem = { pkgs, config, ... }: {

Expand Down Expand Up @@ -57,6 +57,149 @@ _:

};

# The following devShells allow one to conveniently play with some of the
# above schemas
devShells = {
dev-prelude-haskell =
# Note:
# `lbf-prelude-haskell` (defined above
# `packages.lbf-prelude-haskell`) essentially generates a cabal
# project from the `./Prelude.lbf` schema; and the following uses
# `haskell.nix` to convert the `.cabal` project into a dev shell.
# This is a dev shell which provides ghc with
# - `lbf-prelude-haskell` package (and its dependencies)
# - the CLI application (`lbf-prelude-to-haskell`) to compile `.lbf`
# schemas
let
project = { lib, ... }: {
src = config.packages.lbf-prelude-haskell;

name = "lbf-prelude-haskell";

inherit (config.settings.haskell) index-state compiler-nix-name;

extraHackage = [
"${config.packages.lbr-prelude-haskell-src}"
"${config.packages.lbf-prelude-haskell}"
];

modules = [
(_: {
packages = {
allComponent.doHoogle = true;
allComponent.doHaddock = true;

# Enable strict compilation
lbt-plutus-haskell.configureFlags = [ "-f-dev" ];
};
})
];

shell = {

withHoogle = true;

exactDeps = true;

nativeBuildInputs = config.settings.shell.tools
++ [ config.packages.lbf-prelude-to-haskell ];

# Note: the `additional` (contrast to `packages`) attribute
# includes the dependencies + the package itself. See:
# https://input-output-hk.github.io/haskell.nix/reference/library.html#shellfor
# This *must* be the name of the autogenerated cabal package from
# `lbf-prelude-haskell`
additional = ps: [ ps.lbf-prelude ];

tools = {
cabal = { };
haskell-language-server = { };
};

shellHook = lib.mkForce config.settings.shell.hook;
};
};
hsNixFlake = (pkgs.haskell-nix.cabalProject' [
inputs.mlabs-tooling.lib.mkHackageMod
inputs.mlabs-tooling.lib.moduleMod
project
]).flake { };
in
hsNixFlake.devShell;

dev-plutustx =
# Note:
# Similarly to `dev-prelude-haskell`, `packages.lbf-plutus-haskell`
# essentially generates a cabal project from the `*.lbf` schemas; and
# the following uses `haskell.nix` to convert the `.cabal` project into
# a dev shell.
# This is a dev shell which provides ghc with
# - `lbf-plutus-haskell` package (and its dependencies)
# - the CLI application (`lbf-plutus-to-haskell`) to compile `.lbf`
# schemas.
#
# Note:
# This is mostly duplicated code from `dev-prelude-haskell`
let
project = { lib, ... }: {
src = config.packages.lbf-plutus-haskell;

name = "lbf-plutus-haskell";

inherit (config.settings.haskell) index-state compiler-nix-name;

extraHackage = [
"${config.packages.lbr-prelude-haskell-src}"
"${config.packages.lbf-prelude-haskell}"
"${config.packages.lbr-plutus-haskell-src}"
"${config.packages.lbf-plutus-haskell}"
];

modules = [
(_: {
packages = {
allComponent.doHoogle = true;
allComponent.doHaddock = true;

# Enable strict compilation
lbt-plutus-haskell.configureFlags = [ "-f-dev" ];
};
})
];

shell = {

withHoogle = true;

exactDeps = true;

nativeBuildInputs = config.settings.shell.tools
++ [
# We include both the Prelude and Plutus
# frontend. Perhaps, we should _only_ include the
# Plutus frontend, but it doesn't hurt to include both.
config.packages.lbf-prelude-to-haskell
config.packages.lbf-plutus-to-haskell
];

additional = ps: [ ps.lbf-plutus ];

tools = {
cabal = { };
haskell-language-server = { };
};

shellHook = lib.mkForce config.settings.shell.hook;
};
};
hsNixFlake = (pkgs.haskell-nix.cabalProject' [
inputs.mlabs-tooling.lib.mkHackageMod
inputs.mlabs-tooling.lib.moduleMod
project
]).flake { };
in
hsNixFlake.devShell;
};
};
}

0 comments on commit e6fb64e

Please sign in to comment.