-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathflake.nix
178 lines (150 loc) · 5.57 KB
/
flake.nix
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
{
description = "LIGO Nix Flake";
inputs = {
nixpkgs.url = "github:nixos/nixpkgs";
flake-utils.url = "github:numtide/flake-utils";
treefmt = {
url = "github:numtide/treefmt-nix";
inputs.nixpkgs.follows = "nixpkgs";
};
build-yarn-package = {
url = "github:serokell/nix-npm-buildpackage";
inputs.nixpkgs.follows = "nixpkgs";
};
# haskell
stackage = {
url = "github:input-output-hk/stackage.nix";
flake = false;
};
hackage = {
url = "github:input-output-hk/hackage.nix";
flake = false;
};
haskell-nix = {
url = "github:input-output-hk/haskell.nix";
inputs.nixpkgs.follows = "nixpkgs";
inputs.hackage.follows = "hackage";
inputs.stackage.follows = "stackage";
};
ocaml-overlay = {
url = "github:nix-ocaml/nix-overlays";
inputs.nixpkgs.follows = "nixpkgs";
};
# Also doesn't belong here, but required to avoid nix's bad UX with submodules
tezos-ligo = {
url = "gitlab:ligolang/tezos-ligo/v21-ligo";
flake = false;
};
grace = {
url = "github:johnyob/grace";
flake = false;
};
lltz = {
url = "github:trilitech/lltz";
flake = false;
};
};
outputs = inputs:
with inputs;
flake-utils.lib.eachDefaultSystem (
system: let
lib = nixpkgs.legacyPackages.${system}.lib;
pkgs = import nixpkgs {
inherit system;
overlays = [
ocaml-overlay.overlays.default
(import ./nix/overlay.nix)
(_: prev:
with prev; {
ocamlPackages = ocaml-ng.ocamlPackages_4_14;
coqPackages = coqPackages_8_13;
ocamlformat = ocaml-ng.ocamlPackages_4_14.ocamlformat_0_21_0;
})
];
};
tree-sitter-typescript = pkgs.callPackage ./nix/tree-sitter-typescript.nix {};
ligo = pkgs.callPackage ./nix/ligo.nix {inherit tezos-ligo tree-sitter-typescript grace lltz;};
pkgs-extended = pkgs.extend (lib.composeManyExtensions [
build-yarn-package.overlays.default
haskell-nix.overlay
(import ./nix/haskell-overlay.nix)
]);
ligo-syntaxes = ./tools/vscode/syntaxes;
ligo-webide = pkgs-extended.callPackage ./nix/webide.nix {inherit ligo-syntaxes;};
ligo-debugger = pkgs-extended.callPackage ./nix/debugger.nix {};
fmt = treefmt.lib.evalModule pkgs {
projectRootFile = "dune-project";
programs.ocamlformat.enable = true;
programs.alejandra.enable = true;
settings.global.excludes = ["_build" "result" ".direnv" "vendors/*" "vendored-dune/*"];
};
# Wrap stack to work with our haskell.nix integration.
# - no-nix: we don't want stack's nix integration
# --system-ghc: use the existing GHC on PATH (provided by haskell.nix)
# --no-install-ghc : don't try to install GHC if no matching GHC found on PATH
stack-wrapped = pkgs.symlinkJoin {
name = "stack"; # will be available as the usual `stack` in terminal
paths = [pkgs.stack];
buildInputs = [pkgs.makeWrapper];
postBuild = ''
wrapProgram $out/bin/stack \
--add-flags "\
--no-nix \
--system-ghc \
--no-install-ghc \
"
'';
};
haskellShell = name: drv:
drv.passthru.project.shellFor {
inherit name;
# FIXME: https://github.com/input-output-hk/haskell.nix/issues/1885
# Adding [exactDeps = true] to avoid the build failure, this ensures
# that cabal doesn't choose alternate plans, so that *all* dependencies
# are provided by nix.
exactDeps = true;
buildInputs = [stack-wrapped];
};
in {
packages = {
inherit (ligo-webide) ligo-webide-backend ligo-webide-frontend;
inherit ligo-debugger;
ligo = ligo;
default = ligo;
};
devShells = with ligo-webide; rec {
default = pkgs.mkShell {
name = "ligo-dev-shell";
inputsFrom = [ligo];
buildInputs = with pkgs; [
alejandra
shellcheck
ocamlformat
ocamlPackages.utop
ocamlPackages.ocaml-lsp
ocamlPackages.merlin
];
shellHook = ''
# This is a hack to work around the hack used in the dune files
export TREE_SITTER="${ligo.TREE_SITTER}";
export TREE_SITTER_TYPESCRIPT="${ligo.TREE_SITTER_TYPESCRIPT}";
export MERLIN_PATH="${pkgs.ocamlPackages.merlin}";
'';
};
webide-frontend = pkgs.mkShell {
name = "ligo-webide-frontend-shell";
inputsFrom = [ligo-webide-frontend];
NODE_OPTIONS = "--openssl-legacy-provider";
};
webide-backend = haskellShell "ligo-webide-backend-shell" ligo-webide-backend;
webide = pkgs.mkShell {
name = "ligo-webide-shell";
inputsFrom = [webide-frontend webide-backend];
NODE_OPTIONS = "--openssl-legacy-provider";
};
debugger = haskellShell "ligo-debugger-shell" ligo-debugger;
};
formatter = fmt.config.build.wrapper;
}
);
}