Skip to content

Commit c1323f3

Browse files
authored
Merge pull request #114 from mlabs-haskell/bladyjoker/plutustx-flakeparts
Enable PlutusTx.Eq code generation plus massive Nix flake-partsify effort
2 parents be0d0c8 + 2f9c8e2 commit c1323f3

File tree

67 files changed

+1976
-1614
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

67 files changed

+1976
-1614
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ Visit [LambdaBuffers Github Pages](https://mlabs-haskell.github.io/lambda-buffer
4949

5050
## Acknowledgements
5151

52-
This project was graciously funded by the Cardano Treasury in [Catalyst Fund 9](https://cardano.ideascale.com/c/idea/421376).
52+
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).
5353

5454
Authors:
5555

api/.envrc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
use flake ..#dev-protos
1+
use flake ..#dev-api

api/build.nix

Lines changed: 50 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -1,50 +1,57 @@
1-
{ pkgs, pbnix-lib, commonTools, shellHook }:
2-
rec {
3-
devShell = pkgs.mkShell {
4-
name = "protos-env";
5-
buildInputs = [
6-
pkgs.protobuf
7-
pkgs.haskellPackages.proto-lens-protoc
8-
pkgs.protoc-gen-doc
9-
] ++ builtins.attrValues commonTools;
1+
{ inputs, ... }:
2+
{
3+
perSystem = { pkgs, system, config, ... }:
4+
let
5+
pbnix-lib = inputs.protobufs-nix.lib.${system};
6+
in
7+
rec {
108

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

14-
packages = {
15-
lambda-buffers-lang-hs-pb = pbnix-lib.haskellProto {
16-
inherit pkgs;
17-
src = ./.;
18-
proto = "lang.proto";
19-
cabalPackageName = "lambda-buffers-lang-pb";
20-
};
17+
shellHook = config.settings.shell.hook;
18+
};
2119

22-
lambda-buffers-compiler-hs-pb = pbnix-lib.haskellProto {
23-
inherit pkgs;
24-
src = ./.;
25-
proto = "compiler.proto";
26-
cabalBuildDepends = [ packages.lambda-buffers-lang-hs-pb ];
27-
cabalPackageName = "lambda-buffers-compiler-pb";
28-
};
20+
packages = {
21+
lambda-buffers-lang-hs-pb = pbnix-lib.haskellProto {
22+
inherit pkgs;
23+
src = ./.;
24+
proto = "lang.proto";
25+
cabalPackageName = "lambda-buffers-lang-pb";
26+
};
2927

30-
lambda-buffers-codegen-hs-pb = pbnix-lib.haskellProto {
31-
inherit pkgs;
32-
src = ./.;
33-
proto = "codegen.proto";
34-
cabalBuildDepends = [ packages.lambda-buffers-lang-hs-pb ];
35-
cabalPackageName = "lambda-buffers-codegen-pb";
36-
};
28+
lambda-buffers-compiler-hs-pb = pbnix-lib.haskellProto {
29+
inherit pkgs;
30+
src = ./.;
31+
proto = "compiler.proto";
32+
cabalBuildDepends = [ packages.lambda-buffers-lang-hs-pb ];
33+
cabalPackageName = "lambda-buffers-compiler-pb";
34+
};
35+
36+
lambda-buffers-codegen-hs-pb = pbnix-lib.haskellProto {
37+
inherit pkgs;
38+
src = ./.;
39+
proto = "codegen.proto";
40+
cabalBuildDepends = [ packages.lambda-buffers-lang-hs-pb ];
41+
cabalPackageName = "lambda-buffers-codegen-pb";
42+
};
3743

38-
lambda-buffers-api-docs = pkgs.stdenv.mkDerivation {
39-
src = ./.;
40-
name = "lambdabuffers-api-docs";
41-
buildInputs = [
42-
pkgs.protobuf
43-
];
44-
buildPhase = ''
45-
mkdir $out;
46-
protoc --plugin=${pkgs.protoc-gen-doc}/bin/protoc-gen-doc lang.proto compiler.proto codegen.proto --doc_out=$out --doc_opt=markdown,api.md;
47-
'';
44+
lambda-buffers-api-docs = pkgs.stdenv.mkDerivation {
45+
src = ./.;
46+
name = "lambdabuffers-api-docs";
47+
buildInputs = [
48+
pkgs.protobuf
49+
];
50+
buildPhase = ''
51+
mkdir $out;
52+
protoc --plugin=${pkgs.protoc-gen-doc}/bin/protoc-gen-doc lang.proto compiler.proto codegen.proto --doc_out=$out --doc_opt=markdown,api.md;
53+
'';
54+
};
55+
};
4856
};
49-
};
5057
}

docs/build.nix

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
{ inputs, lib, ... }: {
2-
perSystem = { pkgs, system, inputs', config, ... }:
1+
_: {
2+
perSystem = { pkgs, config, ... }:
33
{
44
devShells.dev-docs = pkgs.mkShell {
55
name = "docs-env";

experimental/build.nix

Lines changed: 24 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,28 @@
1-
{ pkgs, commonTools, shellHook }:
2-
pkgs.mkShell {
3-
name = "experimental-env";
4-
buildInputs = [
5-
pkgs.dhall
6-
pkgs.dhall-lsp-server
7-
pkgs.dhall-json
1+
_: {
2+
perSystem = { pkgs, config, ... }:
3+
{
84

9-
(pkgs.haskellPackages.ghcWithPackages (pkgs: [
10-
pkgs.text
11-
pkgs.unification-fd
12-
pkgs.HUnit
13-
]))
14-
pkgs.haskell-language-server
5+
devShells.dev-experimental = pkgs.mkShell {
6+
name = "experimental-env";
7+
buildInputs = [
8+
pkgs.dhall
9+
pkgs.dhall-lsp-server
10+
pkgs.dhall-json
1511

16-
pkgs.protobuf
17-
pkgs.haskellPackages.proto-lens-protoc
18-
pkgs.swiPrologWithGui
19-
] ++ builtins.attrValues commonTools;
12+
(pkgs.haskellPackages.ghcWithPackages (pkgs: [
13+
pkgs.text
14+
pkgs.unification-fd
15+
pkgs.HUnit
16+
]))
17+
pkgs.haskell-language-server
2018

21-
inherit shellHook;
19+
pkgs.protobuf
20+
pkgs.haskellPackages.proto-lens-protoc
21+
pkgs.swiPrologWithGui
22+
] ++ config.settings.shell.tools;
23+
24+
shellHook = config.settings.shell.hook;
25+
};
26+
27+
};
2228
}

extras/build.nix

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
# TODO(bladyjoker): Using overlayAttrs here as a hack to share functions -.- Do this properly.
2+
{ inputs, ... }: {
3+
imports = [
4+
inputs.flake-parts.flakeModules.easyOverlay # Adds perSystem.overlayAttrs
5+
];
6+
perSystem = { pkgs, ... }:
7+
{
8+
9+
overlayAttrs = {
10+
extras = {
11+
purescriptFlake = import ./flake-purescript.nix pkgs;
12+
haskellData = import ./haskell-data.nix pkgs;
13+
};
14+
};
15+
16+
};
17+
}

extras/flake-purescript.nix

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,13 @@
1-
pursProjOpts:
1+
pkgs: pursProjOpts:
22
let
33
mkFlake = projectName: purs: {
44
packages = {
5+
"purescript:${projectName}:src" = pkgs.stdenv.mkDerivation {
6+
name = projectName;
7+
inherit (pursProjOpts) src;
8+
phases = "installPhase";
9+
installPhase = "ln -s $src $out";
10+
};
511
"purescript:${projectName}:lib" = purs.compiled;
612
"purescript:${projectName}:node-modules" = purs.nodeModules;
713
"purescript:${projectName}:bundle" = purs.bundlePursProject { main = "Test.Main"; entrypoint = "app/index.js"; bundledModuleName = "dist/output.js"; };
@@ -16,4 +22,4 @@ let
1622
devShell = purs.devShell;
1723
};
1824
in
19-
mkFlake pursProjOpts.projectName (pursProjOpts.pkgs.purescriptProject pursProjOpts)
25+
mkFlake pursProjOpts.projectName (pkgs.purescriptProject pursProjOpts)

extras/haskell-data.nix

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
{ pkgs, srcs, cabalDataPatterns, cabalPackageName, cabalPackageVersion ? "0.1.0.0" }:
1+
# Makes a Cabal package with just a 'data' directory with proper 'data-filers' stanza
2+
pkgs: { srcs, cabalDataPatterns, cabalPackageName, cabalPackageVersion ? "0.1.0.0" }:
23
let
34
cabalTemplate = pkgs.writeTextFile {
45
name = "haskell-data.nix-cabal-template";

extras/lbf-haskell-plutus.nix

Lines changed: 0 additions & 20 deletions
This file was deleted.

extras/lbf-haskell.nix

Lines changed: 0 additions & 88 deletions
This file was deleted.

extras/lbf-nix/build.nix

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
# TODO(bladyjoker): Using overlayAttrs here as a hack to share functions -.- Do this properly.
2+
{ inputs, ... }: {
3+
imports = [
4+
inputs.flake-parts.flakeModules.easyOverlay # Adds perSystem.overlayAttrs
5+
];
6+
perSystem = { pkgs, config, ... }:
7+
{
8+
9+
overlayAttrs = {
10+
lbf-nix = {
11+
lbfBuild = import ./lbf-build.nix pkgs config.packages.lbf;
12+
lbfHaskell = import ./lbf-haskell.nix pkgs config.packages.lbf config.packages.lbg-haskell;
13+
lbfPreludeHaskell = import ./lbf-prelude-hs.nix pkgs config.packages.lbf config.packages.lbg-haskell;
14+
lbfPlutusHaskell = import ./lbf-plutus-hs-plutustx.nix pkgs config.packages.lbf config.packages.lbg-haskell;
15+
lbfPurescript = import ./lbf-purescript.nix pkgs config.packages.lbf config.packages.lbg-purescript;
16+
lbfPreludePurescript = import ./lbf-prelude-purescript.nix pkgs config.packages.lbf config.packages.lbg-purescript;
17+
lbfPlutusPurescript = import ./lbf-plutus-purescript.nix pkgs config.packages.lbf config.packages.lbg-purescript;
18+
};
19+
};
20+
21+
};
22+
}

0 commit comments

Comments
 (0)