Skip to content

Commit

Permalink
Merge pull request #114 from mlabs-haskell/bladyjoker/plutustx-flakep…
Browse files Browse the repository at this point in the history
…arts

Enable PlutusTx.Eq code generation plus massive Nix flake-partsify effort
  • Loading branch information
bladyjoker authored Oct 17, 2023
2 parents be0d0c8 + 2f9c8e2 commit c1323f3
Show file tree
Hide file tree
Showing 67 changed files with 1,976 additions and 1,614 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ Visit [LambdaBuffers Github Pages](https://mlabs-haskell.github.io/lambda-buffer

## Acknowledgements

This project was graciously funded by the Cardano Treasury in [Catalyst Fund 9](https://cardano.ideascale.com/c/idea/421376).
This project was graciously funded by the Cardano Treasury in [Catalyst Fund 9](https://cardano.ideascale.com/c/idea/421376) and [Catalyst Fund 10](https://cardano.ideascale.com/c/idea/105975).

Authors:

Expand Down
2 changes: 1 addition & 1 deletion api/.envrc
Original file line number Diff line number Diff line change
@@ -1 +1 @@
use flake ..#dev-protos
use flake ..#dev-api
93 changes: 50 additions & 43 deletions api/build.nix
Original file line number Diff line number Diff line change
@@ -1,50 +1,57 @@
{ pkgs, pbnix-lib, commonTools, shellHook }:
rec {
devShell = pkgs.mkShell {
name = "protos-env";
buildInputs = [
pkgs.protobuf
pkgs.haskellPackages.proto-lens-protoc
pkgs.protoc-gen-doc
] ++ builtins.attrValues commonTools;
{ inputs, ... }:
{
perSystem = { pkgs, system, config, ... }:
let
pbnix-lib = inputs.protobufs-nix.lib.${system};
in
rec {

inherit shellHook;
};
devShells.dev-api = pkgs.mkShell {
name = "protos-env";
buildInputs = [
pkgs.protobuf
pkgs.haskellPackages.proto-lens-protoc
pkgs.protoc-gen-doc
] ++ config.settings.shell.tools;

packages = {
lambda-buffers-lang-hs-pb = pbnix-lib.haskellProto {
inherit pkgs;
src = ./.;
proto = "lang.proto";
cabalPackageName = "lambda-buffers-lang-pb";
};
shellHook = config.settings.shell.hook;
};

lambda-buffers-compiler-hs-pb = pbnix-lib.haskellProto {
inherit pkgs;
src = ./.;
proto = "compiler.proto";
cabalBuildDepends = [ packages.lambda-buffers-lang-hs-pb ];
cabalPackageName = "lambda-buffers-compiler-pb";
};
packages = {
lambda-buffers-lang-hs-pb = pbnix-lib.haskellProto {
inherit pkgs;
src = ./.;
proto = "lang.proto";
cabalPackageName = "lambda-buffers-lang-pb";
};

lambda-buffers-codegen-hs-pb = pbnix-lib.haskellProto {
inherit pkgs;
src = ./.;
proto = "codegen.proto";
cabalBuildDepends = [ packages.lambda-buffers-lang-hs-pb ];
cabalPackageName = "lambda-buffers-codegen-pb";
};
lambda-buffers-compiler-hs-pb = pbnix-lib.haskellProto {
inherit pkgs;
src = ./.;
proto = "compiler.proto";
cabalBuildDepends = [ packages.lambda-buffers-lang-hs-pb ];
cabalPackageName = "lambda-buffers-compiler-pb";
};

lambda-buffers-codegen-hs-pb = pbnix-lib.haskellProto {
inherit pkgs;
src = ./.;
proto = "codegen.proto";
cabalBuildDepends = [ packages.lambda-buffers-lang-hs-pb ];
cabalPackageName = "lambda-buffers-codegen-pb";
};

lambda-buffers-api-docs = pkgs.stdenv.mkDerivation {
src = ./.;
name = "lambdabuffers-api-docs";
buildInputs = [
pkgs.protobuf
];
buildPhase = ''
mkdir $out;
protoc --plugin=${pkgs.protoc-gen-doc}/bin/protoc-gen-doc lang.proto compiler.proto codegen.proto --doc_out=$out --doc_opt=markdown,api.md;
'';
lambda-buffers-api-docs = pkgs.stdenv.mkDerivation {
src = ./.;
name = "lambdabuffers-api-docs";
buildInputs = [
pkgs.protobuf
];
buildPhase = ''
mkdir $out;
protoc --plugin=${pkgs.protoc-gen-doc}/bin/protoc-gen-doc lang.proto compiler.proto codegen.proto --doc_out=$out --doc_opt=markdown,api.md;
'';
};
};
};
};
}
4 changes: 2 additions & 2 deletions docs/build.nix
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{ inputs, lib, ... }: {
perSystem = { pkgs, system, inputs', config, ... }:
_: {
perSystem = { pkgs, config, ... }:
{
devShells.dev-docs = pkgs.mkShell {
name = "docs-env";
Expand Down
42 changes: 24 additions & 18 deletions experimental/build.nix
Original file line number Diff line number Diff line change
@@ -1,22 +1,28 @@
{ pkgs, commonTools, shellHook }:
pkgs.mkShell {
name = "experimental-env";
buildInputs = [
pkgs.dhall
pkgs.dhall-lsp-server
pkgs.dhall-json
_: {
perSystem = { pkgs, config, ... }:
{

(pkgs.haskellPackages.ghcWithPackages (pkgs: [
pkgs.text
pkgs.unification-fd
pkgs.HUnit
]))
pkgs.haskell-language-server
devShells.dev-experimental = pkgs.mkShell {
name = "experimental-env";
buildInputs = [
pkgs.dhall
pkgs.dhall-lsp-server
pkgs.dhall-json

pkgs.protobuf
pkgs.haskellPackages.proto-lens-protoc
pkgs.swiPrologWithGui
] ++ builtins.attrValues commonTools;
(pkgs.haskellPackages.ghcWithPackages (pkgs: [
pkgs.text
pkgs.unification-fd
pkgs.HUnit
]))
pkgs.haskell-language-server

inherit shellHook;
pkgs.protobuf
pkgs.haskellPackages.proto-lens-protoc
pkgs.swiPrologWithGui
] ++ config.settings.shell.tools;

shellHook = config.settings.shell.hook;
};

};
}
17 changes: 17 additions & 0 deletions extras/build.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# TODO(bladyjoker): Using overlayAttrs here as a hack to share functions -.- Do this properly.
{ inputs, ... }: {
imports = [
inputs.flake-parts.flakeModules.easyOverlay # Adds perSystem.overlayAttrs
];
perSystem = { pkgs, ... }:
{

overlayAttrs = {
extras = {
purescriptFlake = import ./flake-purescript.nix pkgs;
haskellData = import ./haskell-data.nix pkgs;
};
};

};
}
10 changes: 8 additions & 2 deletions extras/flake-purescript.nix
Original file line number Diff line number Diff line change
@@ -1,7 +1,13 @@
pursProjOpts:
pkgs: pursProjOpts:
let
mkFlake = projectName: purs: {
packages = {
"purescript:${projectName}:src" = pkgs.stdenv.mkDerivation {
name = projectName;
inherit (pursProjOpts) src;
phases = "installPhase";
installPhase = "ln -s $src $out";
};
"purescript:${projectName}:lib" = purs.compiled;
"purescript:${projectName}:node-modules" = purs.nodeModules;
"purescript:${projectName}:bundle" = purs.bundlePursProject { main = "Test.Main"; entrypoint = "app/index.js"; bundledModuleName = "dist/output.js"; };
Expand All @@ -16,4 +22,4 @@ let
devShell = purs.devShell;
};
in
mkFlake pursProjOpts.projectName (pursProjOpts.pkgs.purescriptProject pursProjOpts)
mkFlake pursProjOpts.projectName (pkgs.purescriptProject pursProjOpts)
3 changes: 2 additions & 1 deletion extras/haskell-data.nix
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
{ pkgs, srcs, cabalDataPatterns, cabalPackageName, cabalPackageVersion ? "0.1.0.0" }:
# Makes a Cabal package with just a 'data' directory with proper 'data-filers' stanza
pkgs: { srcs, cabalDataPatterns, cabalPackageName, cabalPackageVersion ? "0.1.0.0" }:
let
cabalTemplate = pkgs.writeTextFile {
name = "haskell-data.nix-cabal-template";
Expand Down
20 changes: 0 additions & 20 deletions extras/lbf-haskell-plutus.nix

This file was deleted.

88 changes: 0 additions & 88 deletions extras/lbf-haskell.nix

This file was deleted.

22 changes: 22 additions & 0 deletions extras/lbf-nix/build.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
# TODO(bladyjoker): Using overlayAttrs here as a hack to share functions -.- Do this properly.
{ inputs, ... }: {
imports = [
inputs.flake-parts.flakeModules.easyOverlay # Adds perSystem.overlayAttrs
];
perSystem = { pkgs, config, ... }:
{

overlayAttrs = {
lbf-nix = {
lbfBuild = import ./lbf-build.nix pkgs config.packages.lbf;
lbfHaskell = import ./lbf-haskell.nix pkgs config.packages.lbf config.packages.lbg-haskell;
lbfPreludeHaskell = import ./lbf-prelude-hs.nix pkgs config.packages.lbf config.packages.lbg-haskell;
lbfPlutusHaskell = import ./lbf-plutus-hs-plutustx.nix pkgs config.packages.lbf config.packages.lbg-haskell;
lbfPurescript = import ./lbf-purescript.nix pkgs config.packages.lbf config.packages.lbg-purescript;
lbfPreludePurescript = import ./lbf-prelude-purescript.nix pkgs config.packages.lbf config.packages.lbg-purescript;
lbfPlutusPurescript = import ./lbf-plutus-purescript.nix pkgs config.packages.lbf config.packages.lbg-purescript;
};
};

};
}
Loading

0 comments on commit c1323f3

Please sign in to comment.