|
25 | 25 | (import ./extras/build.nix) |
26 | 26 | (import ./extras/lbf-nix/build.nix) |
27 | 27 | (import ./libs/build.nix) |
| 28 | + (import ./api/build.nix) |
| 29 | + (import ./lambda-buffers-compiler/build.nix) |
| 30 | + (import ./lambda-buffers-codegen/build.nix) |
| 31 | + (import ./lambda-buffers-frontend/build.nix) |
28 | 32 | (import ./runtimes/haskell/lbr-prelude/build.nix) |
29 | 33 | (import ./runtimes/haskell/lbr-plutus/build.nix) |
30 | 34 | (import ./runtimes/purescript/lbr-prelude/build.nix) |
|
45 | 49 | let |
46 | 50 | inherit self; |
47 | 51 |
|
48 | | - haskell-nix = pkgs.haskell-nix; |
49 | | - |
50 | 52 | # pre-commit-hooks.nix |
51 | 53 |
|
52 | 54 | fourmolu = pkgs.haskell.packages.ghc924.fourmolu; |
|
59 | 61 | inherit fourmolu; |
60 | 62 | inherit apply-refact; |
61 | 63 | }; |
62 | | - |
63 | | - shellHook = config.pre-commit.installationScript; |
64 | | - |
65 | | - # Protos build |
66 | | - |
67 | | - pbnix-lib = protobufs-nix.lib.${system}; |
68 | | - |
69 | | - protosBuild = import ./api/build.nix { |
70 | | - inherit pkgs pbnix-lib commonTools shellHook; |
71 | | - }; |
72 | | - |
73 | | - index-state = "2022-12-01T00:00:00Z"; |
74 | | - compiler-nix-name = "ghc925"; |
75 | | - |
76 | | - # Common build abstraction for the components. |
77 | | - |
78 | | - buildAbstraction = { import-location, additional ? { } }: |
79 | | - import import-location ({ |
80 | | - inherit pkgs compiler-nix-name index-state haskell-nix mlabs-tooling commonTools shellHook; |
81 | | - } // additional); |
82 | | - |
83 | | - # Common Flake abstraction for the components. |
84 | | - |
85 | | - flakeAbstraction = component-name: component-name.hsNixProj.flake { }; |
86 | | - |
87 | | - # Compiler Build |
88 | | - |
89 | | - compilerBuild = buildAbstraction { |
90 | | - import-location = ./lambda-buffers-compiler/build.nix; |
91 | | - additional = { inherit (protosBuild.packages) lambda-buffers-lang-hs-pb lambda-buffers-compiler-hs-pb lambda-buffers-codegen-hs-pb; }; |
92 | | - }; |
93 | | - compilerFlake = flakeAbstraction compilerBuild; |
94 | | - |
95 | | - # Codegen Build |
96 | | - |
97 | | - codegenBuild = buildAbstraction { |
98 | | - import-location = ./lambda-buffers-codegen/build.nix; |
99 | | - additional = { |
100 | | - inherit (protosBuild.packages) lambda-buffers-lang-hs-pb lambda-buffers-compiler-hs-pb lambda-buffers-codegen-hs-pb; |
101 | | - lambda-buffers-compiler = ./lambda-buffers-compiler; |
102 | | - }; |
103 | | - }; |
104 | | - codegenFlake = flakeAbstraction codegenBuild; |
105 | | - |
106 | | - # Frontend Build |
107 | | - |
108 | | - frontendBuild = buildAbstraction { |
109 | | - import-location = ./lambda-buffers-frontend/build.nix; |
110 | | - additional = { |
111 | | - inherit (protosBuild.packages) lambda-buffers-lang-hs-pb lambda-buffers-compiler-hs-pb lambda-buffers-codegen-hs-pb; |
112 | | - lambda-buffers-compiler = ./lambda-buffers-compiler; |
113 | | - inherit (clis) lbc lbg lbg-haskell lbg-purescript; |
114 | | - }; |
115 | | - }; |
116 | | - frontendFlake = flakeAbstraction frontendBuild; |
117 | | - |
118 | | - # LambdaBuffers CLIs |
119 | | - |
120 | | - clis = rec { |
121 | | - lbf-pure = frontendFlake.packages."lambda-buffers-frontend:exe:lbf"; |
122 | | - lbc = compilerFlake.packages."lambda-buffers-compiler:exe:lbc"; |
123 | | - lbg = codegenFlake.packages."lambda-buffers-codegen:exe:lbg"; |
124 | | - lbg-haskell = pkgs.writeShellScriptBin "lbg-haskell" '' |
125 | | - ${lbg}/bin/lbg gen-haskell $@ |
126 | | - ''; |
127 | | - lbg-purescript = pkgs.writeShellScriptBin "lbg-purescript" '' |
128 | | - ${lbg}/bin/lbg gen-purescript $@ |
129 | | - ''; |
130 | | - lbf = pkgs.writeShellScriptBin "lbf" '' |
131 | | - export LB_CODEGEN=${lbg-haskell}/bin/lbg-haskell; |
132 | | - export LB_COMPILER=${lbc}/bin/lbc; |
133 | | - ${lbf-pure}/bin/lbf $@ |
134 | | - ''; |
135 | | - lbf-to-haskell = pkgs.writeShellScriptBin "lbf-to-haskell" '' |
136 | | - export LB_COMPILER=${lbc}/bin/lbc; |
137 | | -
|
138 | | - ${lbf-pure}/bin/lbf build --gen ${lbg-haskell}/bin/lbg-haskell $@ |
139 | | - ''; |
140 | | - lbf-to-haskell-prelude = pkgs.writeShellScriptBin "lbf-to-haskell-prelude" '' |
141 | | - export LB_COMPILER=${lbc}/bin/lbc; |
142 | | -
|
143 | | - ${lbf-pure}/bin/lbf build --import-path ${./libs/lbf-prelude} \ |
144 | | - --gen-class Prelude.Eq --gen-class Prelude.Json \ |
145 | | - --gen ${lbg-haskell}/bin/lbg-haskell $@ |
146 | | - ''; |
147 | | - lbf-to-purescript = pkgs.writeShellScriptBin "lbf-to-purescript" '' |
148 | | - export LB_COMPILER=${lbc}/bin/lbc; |
149 | | -
|
150 | | - ${lbf-pure}/bin/lbf build --gen ${lbg-purescript}/bin/lbg-purescript $@ |
151 | | - ''; |
152 | | - lbf-to-purescript-prelude = pkgs.writeShellScriptBin "lbf-to-purescript-prelude" '' |
153 | | - export LB_COMPILER=${lbc}/bin/lbc; |
154 | | -
|
155 | | - ${lbf-pure}/bin/lbf build --import-path ${./libs/lbf-prelude} \ |
156 | | - --gen-class Prelude.Eq --gen-class Prelude.Json \ |
157 | | - --gen ${lbg-purescript}/bin/lbg-purescript $@ |
158 | | - ''; |
159 | | - |
160 | | - }; |
161 | | - |
162 | | - # LambdaBuffers environment |
163 | | - |
164 | | - lbEnv = pkgs.mkShell { |
165 | | - name = "lambdabuffers-env"; |
166 | | - packages = builtins.attrValues clis; |
167 | | - }; |
168 | | - |
169 | | - # Utilities |
170 | | - renameAttrs = rnFn: pkgs.lib.attrsets.mapAttrs' (n: value: { name = rnFn n; inherit value; }); |
171 | 64 | in |
172 | | - rec |
173 | | - { |
174 | | - # Standard flake attributes |
175 | | - packages = protosBuild.packages |
176 | | - // compilerFlake.packages |
177 | | - // frontendFlake.packages |
178 | | - // codegenFlake.packages |
179 | | - // clis; |
180 | | - |
181 | | - devShells = rec { |
182 | | - dev-protos = protosBuild.devShell; |
183 | | - dev-compiler = compilerFlake.devShell; |
184 | | - dev-frontend = frontendFlake.devShell; |
185 | | - dev-codegen = codegenFlake.devShell; |
186 | | - lb = lbEnv; |
187 | | - }; |
188 | | - |
189 | | - # nix flake check |
190 | | - checks = devShells // |
191 | | - packages // |
192 | | - renameAttrs (n: "check-${n}") ( |
193 | | - compilerFlake.checks // |
194 | | - frontendFlake.checks // |
195 | | - codegenFlake.checks |
196 | | - ); |
197 | | - |
198 | | - }; |
| 65 | + { }; |
199 | 66 | }; |
200 | 67 | } |
0 commit comments