|
1 | 1 | # Foundational .lbf packages
|
2 | 2 | # TODO(bladyjoker): Make packages that actually try and compile.
|
3 |
| -_: |
| 3 | +{ inputs, ... }: |
4 | 4 | {
|
5 | 5 | perSystem = { pkgs, config, ... }: {
|
6 | 6 |
|
|
41 | 41 | imports = [ ./lbf-prelude ];
|
42 | 42 | files = [ "Plutus/V1.lbf" "Plutus/V2.lbf" ];
|
43 | 43 | classes = [ "Prelude.Eq" "Prelude.Json" "Plutus.V1.PlutusData" ];
|
44 |
| - dependencies = [ "lbf-prelude" ]; |
| 44 | + dependencies = |
| 45 | + [ |
| 46 | + "lbf-prelude" |
| 47 | + # TODO(jaredponn): Investigate why `lbr-plutus` is _not_ |
| 48 | + # being automatically included as a dependency. |
| 49 | + "lbr-plutus" |
| 50 | + ]; |
45 | 51 | configs = [ ../lambda-buffers-codegen/data/haskell-prelude-base.json ../lambda-buffers-codegen/data/haskell-plutus-plutustx.json ];
|
46 | 52 | };
|
47 | 53 |
|
|
57 | 63 |
|
58 | 64 | };
|
59 | 65 |
|
| 66 | + # The following devShells allow one to conveniently play with some of the |
| 67 | + # above schemas |
| 68 | + devShells = { |
| 69 | + dev-prelude-haskell = |
| 70 | + # Note: |
| 71 | + # `lbf-prelude-haskell` (defined above |
| 72 | + # `packages.lbf-prelude-haskell`) essentially generates a cabal |
| 73 | + # project from the `./Prelude.lbf` schema; and the following uses |
| 74 | + # `haskell.nix` to convert the `.cabal` project into a dev shell. |
| 75 | + # This is a dev shell which provides |
| 76 | + # - ghc with `lbf-prelude-haskell` package (and its dependencies) |
| 77 | + # - the CLI application (`lbf-prelude-to-haskell`) to compile `.lbf` |
| 78 | + # schemas |
| 79 | + let |
| 80 | + project = { lib, ... }: { |
| 81 | + src = config.packages.lbf-prelude-haskell; |
| 82 | + |
| 83 | + name = "lbf-prelude-haskell"; |
| 84 | + |
| 85 | + inherit (config.settings.haskell) index-state compiler-nix-name; |
| 86 | + |
| 87 | + extraHackage = [ |
| 88 | + "${config.packages.lbr-prelude-haskell-src}" |
| 89 | + "${config.packages.lbf-prelude-haskell}" |
| 90 | + ]; |
| 91 | + |
| 92 | + modules = [ |
| 93 | + (_: { |
| 94 | + packages = { |
| 95 | + allComponent.doHoogle = true; |
| 96 | + allComponent.doHaddock = true; |
| 97 | + |
| 98 | + # Enable strict compilation |
| 99 | + lbf-prelude.configureFlags = [ "-f-dev" ]; |
| 100 | + }; |
| 101 | + }) |
| 102 | + ]; |
| 103 | + |
| 104 | + shell = { |
| 105 | + |
| 106 | + withHoogle = true; |
| 107 | + |
| 108 | + exactDeps = true; |
| 109 | + |
| 110 | + nativeBuildInputs = config.settings.shell.tools |
| 111 | + ++ [ config.packages.lbf-prelude-to-haskell ]; |
| 112 | + |
| 113 | + # Note: the `additional` (contrast to `packages`) attribute |
| 114 | + # includes the dependencies + the package itself. See: |
| 115 | + # https://input-output-hk.github.io/haskell.nix/reference/library.html#shellfor |
| 116 | + # This *must* be the name of the autogenerated cabal package from |
| 117 | + # `lbf-prelude-haskell` |
| 118 | + additional = ps: [ ps.lbf-prelude ]; |
| 119 | + |
| 120 | + tools = { |
| 121 | + cabal = { }; |
| 122 | + haskell-language-server = { }; |
| 123 | + }; |
| 124 | + |
| 125 | + shellHook = lib.mkForce config.settings.shell.hook; |
| 126 | + }; |
| 127 | + }; |
| 128 | + hsNixFlake = (pkgs.haskell-nix.cabalProject' [ |
| 129 | + inputs.mlabs-tooling.lib.mkHackageMod |
| 130 | + inputs.mlabs-tooling.lib.moduleMod |
| 131 | + project |
| 132 | + ]).flake { }; |
| 133 | + in |
| 134 | + hsNixFlake.devShell; |
| 135 | + |
| 136 | + dev-plutustx = |
| 137 | + # Note: |
| 138 | + # Similarly to `dev-prelude-haskell`, `packages.lbf-plutus-haskell` |
| 139 | + # essentially generates a cabal project from the `*.lbf` schemas; and |
| 140 | + # the following uses `haskell.nix` to convert the `.cabal` project into |
| 141 | + # a dev shell. |
| 142 | + # This is a dev shell which provides |
| 143 | + # - ghc with `lbf-plutus-haskell` package (and its dependencies) |
| 144 | + # - the CLI application (`lbf-plutus-to-haskell`) to compile `.lbf` |
| 145 | + # schemas. |
| 146 | + # |
| 147 | + # Note: |
| 148 | + # This is mostly duplicated code from `dev-prelude-haskell` |
| 149 | + let |
| 150 | + project = { lib, ... }: { |
| 151 | + src = config.packages.lbf-plutus-haskell; |
| 152 | + |
| 153 | + name = "lbf-plutus-haskell"; |
| 154 | + |
| 155 | + inherit (config.settings.haskell) index-state compiler-nix-name; |
| 156 | + |
| 157 | + extraHackage = [ |
| 158 | + "${config.packages.lbr-prelude-haskell-src}" |
| 159 | + "${config.packages.lbf-prelude-haskell}" |
| 160 | + "${config.packages.lbr-plutus-haskell-src}" |
| 161 | + "${config.packages.lbf-plutus-haskell}" |
| 162 | + ]; |
| 163 | + |
| 164 | + modules = [ |
| 165 | + (_: { |
| 166 | + packages = { |
| 167 | + allComponent.doHoogle = true; |
| 168 | + allComponent.doHaddock = true; |
| 169 | + |
| 170 | + # Enable strict compilation |
| 171 | + lbf-plutus.configureFlags = [ "-f-dev" ]; |
| 172 | + }; |
| 173 | + }) |
| 174 | + ]; |
| 175 | + |
| 176 | + shell = { |
| 177 | + |
| 178 | + withHoogle = true; |
| 179 | + |
| 180 | + exactDeps = true; |
| 181 | + |
| 182 | + nativeBuildInputs = config.settings.shell.tools |
| 183 | + ++ [ |
| 184 | + # We include both the Prelude and Plutus |
| 185 | + # frontend. Perhaps, we should _only_ include the |
| 186 | + # Plutus frontend, but it doesn't hurt to include both. |
| 187 | + config.packages.lbf-prelude-to-haskell |
| 188 | + config.packages.lbf-plutus-to-haskell |
| 189 | + ]; |
| 190 | + |
| 191 | + additional = ps: [ ps.lbf-plutus ]; |
| 192 | + |
| 193 | + tools = { |
| 194 | + cabal = { }; |
| 195 | + haskell-language-server = { }; |
| 196 | + }; |
| 197 | + |
| 198 | + shellHook = lib.mkForce config.settings.shell.hook; |
| 199 | + }; |
| 200 | + }; |
| 201 | + hsNixFlake = (pkgs.haskell-nix.cabalProject' [ |
| 202 | + inputs.mlabs-tooling.lib.mkHackageMod |
| 203 | + inputs.mlabs-tooling.lib.moduleMod |
| 204 | + project |
| 205 | + ]).flake { }; |
| 206 | + in |
| 207 | + hsNixFlake.devShell; |
| 208 | + }; |
60 | 209 | };
|
61 | 210 | }
|
62 | 211 |
|
0 commit comments