Skip to content

Commit 935cdd6

Browse files
committed
Exposes lbf-nix
1 parent 366113b commit 935cdd6

File tree

25 files changed

+676
-3065
lines changed

25 files changed

+676
-3065
lines changed

docs/plutarch/build.nix

Lines changed: 8 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,15 @@
11
{ inputs, ... }:
22
{
3-
perSystem = { pkgs, config, ... }:
3+
perSystem = { config, ... }:
44
let
5-
project = { lib, ... }: {
5+
hsFlake = config.lbf-nix.haskellPlutusFlake {
66
src = ./.;
77

88
name = "plutarch-example";
99

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

12-
extraHackage = [
12+
dependencies = [
1313
# Load Plutarch support
1414
"${config.packages.lbf-prelude-plutarch}"
1515
"${config.packages.lbf-plutus-plutarch}"
@@ -22,49 +22,18 @@
2222
"${inputs.plutarch}/plutarch-extra"
2323
];
2424

25-
modules = [
26-
(_: {
27-
packages = {
28-
allComponent.doHoogle = true;
29-
allComponent.doHaddock = true;
30-
31-
# Enable strict compilation
32-
plutarch-example.configureFlags = [ "-f-dev" ];
33-
};
34-
})
35-
];
36-
37-
shell = {
38-
39-
withHoogle = true;
40-
41-
exactDeps = true;
42-
43-
nativeBuildInputs = config.settings.shell.tools ++ [ config.packages.lbf-plutus-to-plutarch ];
44-
45-
tools = {
46-
cabal = { };
47-
haskell-language-server = { };
48-
};
49-
50-
shellHook = lib.mkForce config.settings.shell.hook;
51-
};
25+
devShellTools = config.settings.shell.tools;
26+
devShellHook = config.settings.shell.hook;
5227
};
53-
hsNixFlake = (pkgs.haskell-nix.cabalProject' [
54-
inputs.mlabs-tooling.lib.mkHackageMod
55-
inputs.mlabs-tooling.lib.moduleMod
56-
project
57-
]).flake { };
58-
5928
in
6029

6130
{
62-
devShells.dev-plutarch-example = hsNixFlake.devShell;
31+
devShells.dev-plutarch-example = hsFlake.devShell;
6332

6433
packages = {
65-
plutarch-example-cli = hsNixFlake.packages."plutarch-example:exe:plutarch-example";
34+
plutarch-example-cli = hsFlake.packages."plutarch-example:exe:plutarch-example";
6635

67-
lbf-plutarch-example-api = config.overlayAttrs.lbf-nix.lbfPlutarch {
36+
lbf-plutarch-example-api = config.lbf-nix.lbfPlutarch {
6837
name = "lbf-plutarch-example-api";
6938
src = ./api;
7039
files = [ "Example.lbf" ];

extras/build.nix

Lines changed: 49 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,52 @@
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-
rustFlake = import ./flake-rust.nix pkgs;
13-
haskellData = import ./haskell-data.nix pkgs;
14-
haskellFlake = import ./flake-haskell.nix pkgs;
15-
haskellPlutusFlake = import ./flake-haskell-plutus.nix inputs.cardano-haskell-packages pkgs;
1+
{ config, inputs, flake-parts-lib, lib, ... }: {
2+
3+
# Makes a system agnostic option (dunno why I needed this).
4+
options.lbf-nix = lib.mkOption {
5+
type = lib.types.anything; # probably not the best type
6+
default = { };
7+
};
8+
9+
# Makes it available in the system agnostic `lib` argument.
10+
config._module.args.lib = config.flake.lib // {
11+
inherit (config) lbf-nix;
12+
};
13+
14+
# Sets the above set option to system ones.
15+
config.lbf-nix = lib.genAttrs config.systems (system: (config.perSystem { inherit system; }).lbf-nix);
16+
17+
# Makes `lib.x86_64-linux.xyz` available
18+
config.flake.lib = config.lbf-nix;
19+
20+
options = {
21+
22+
# Makes a per system `lbf-nix` option.
23+
perSystem = flake-parts-lib.mkPerSystemOption
24+
({ pkgs, config, ... }: {
25+
26+
options.lbf-nix = lib.mkOption {
27+
type = lib.types.anything;
28+
default = { };
29+
};
30+
31+
# Sets a per system `lbf-nix` option.
32+
config = {
33+
lbf-nix = {
34+
# NOTE(bladyjoker): If you need to add a function the export externally and use internally via config.lbf-nix, add it here.
35+
purescriptFlake = import ./flake-purescript.nix pkgs;
36+
rustFlake = import ./flake-rust.nix pkgs;
37+
haskellData = import ./haskell-data.nix pkgs;
38+
haskellFlake = import ./flake-haskell.nix pkgs;
39+
haskellPlutusFlake = import ./flake-haskell-plutus.nix inputs.cardano-haskell-packages pkgs;
40+
};
41+
42+
# Makes it available in the per system `lib` argument.
43+
_module.args.lib = lib // {
44+
inherit (config) lbf-nix;
45+
};
46+
1647
};
17-
};
1848

19-
};
49+
});
50+
51+
};
2052
}

extras/lbf-nix/build.nix

Lines changed: 11 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,4 @@
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-
];
1+
_: {
62
perSystem = { pkgs, config, ... }:
73
let
84
lbg-haskell = "${config.packages.lbg-haskell}/bin/lbg-haskell";
@@ -12,18 +8,16 @@
128
in
139
{
1410

15-
overlayAttrs = {
16-
lbf-nix = {
17-
lbfBuild = import ./lbf-build.nix pkgs config.packages.lbf;
18-
lbfHaskell = import ./lbf-haskell.nix pkgs config.packages.lbf lbg-haskell;
19-
lbfPreludeHaskell = import ./lbf-prelude-hs.nix pkgs config.packages.lbf lbg-haskell;
20-
lbfPlutusHaskell = import ./lbf-plutus-hs-plutustx.nix pkgs config.packages.lbf lbg-haskell;
21-
lbfPlutarch' = import ./lbf-plutarch.nix pkgs config.packages.lbf lbg-plutarch;
22-
lbfPlutarch = import ./lbf-plutus-plutarch.nix pkgs config.packages.lbf lbg-plutarch;
23-
lbfPurescript = import ./lbf-purescript.nix pkgs config.packages.lbf lbg-purescript;
24-
lbfPreludePurescript = import ./lbf-prelude-purescript.nix pkgs config.packages.lbf lbg-purescript;
25-
lbfPlutusPurescript = import ./lbf-plutus-purescript.nix pkgs config.packages.lbf lbg-purescript;
26-
};
11+
lbf-nix = {
12+
lbfBuild = import ./lbf-build.nix pkgs config.packages.lbf;
13+
lbfHaskell = import ./lbf-haskell.nix pkgs config.packages.lbf lbg-haskell;
14+
lbfPreludeHaskell = import ./lbf-prelude-hs.nix pkgs config.packages.lbf lbg-haskell;
15+
lbfPlutusHaskell = import ./lbf-plutus-hs-plutustx.nix pkgs config.packages.lbf lbg-haskell;
16+
lbfPlutarch' = import ./lbf-plutarch.nix pkgs config.packages.lbf lbg-plutarch;
17+
lbfPlutarch = import ./lbf-plutus-plutarch.nix pkgs config.packages.lbf lbg-plutarch;
18+
lbfPurescript = import ./lbf-purescript.nix pkgs config.packages.lbf lbg-purescript;
19+
lbfPreludePurescript = import ./lbf-prelude-purescript.nix pkgs config.packages.lbf lbg-purescript;
20+
lbfPlutusPurescript = import ./lbf-plutus-purescript.nix pkgs config.packages.lbf lbg-purescript;
2721
};
2822

2923
};

0 commit comments

Comments
 (0)