-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathflake.nix
148 lines (124 loc) · 4.18 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
{
description = "fida-contracts";
nixConfig = {
extra-substituters = [
"https://cache.iog.io"
"https://public-plutonomicon.cachix.org"
"https://cache.sc.iog.io"
];
extra-trusted-public-keys = [
"hydra.iohk.io:f/Ea+s+dFdN+3Y/G+FDgSq+a5NEWhJGzdjvKNGv0/EQ="
"public-plutonomicon.cachix.org-1:3AKJMhCLn32gri1drGuaZmFrmnue+KkKrhhubQk/CWc="
"cache.sc.iog.io:b4YIcBabCEVKrLQgGW8Fylz4W8IvvfzRc+hy0idqrWU="
];
};
inputs = {
cardano-transaction-lib.url = "github:Plutonomicon/cardano-transaction-lib/b7e8d396711f95e7a7b755a2a7e7089df712aaf5";
haskell-nix.url = "github:input-output-hk/haskell.nix/9af167fb4343539ca99465057262f289b44f55da";
nixpkgs.follows = "cardano-transaction-lib/nixpkgs";
iohk-nix.follows = "cardano-transaction-lib/plutip/iohk-nix";
CHaP.follows = "cardano-transaction-lib/plutip/CHaP";
plutip.follows = "cardano-transaction-lib/plutip";
flake-compat.url = "https://flakehub.com/f/edolstra/flake-compat/1.tar.gz";
};
outputs = { self, nixpkgs, haskell-nix, iohk-nix, CHaP, plutip, ... }:
let
nixpkgsFor = system:
import nixpkgs {
inherit system;
overlays = [
(import "${iohk-nix}/overlays/crypto")
haskell-nix.overlay
];
inherit (haskell-nix) config;
};
hsProjectFor = system:
let
pkgs = nixpkgsFor system;
in
pkgs.haskell-nix.cabalProject {
src = ./.;
inputMap = {
"https://input-output-hk.github.io/cardano-haskell-packages" = CHaP;
};
compiler-nix-name = "ghc8107";
modules = plutip.haskellModules;
shell = {
exactDeps = true;
nativeBuildInputs = with pkgs; [
# Shell utils
bashInteractive
git
cabal-install
ghcid
# Lint / Format
hlint
haskellPackages.cabal-fmt
haskellPackages.fourmolu
nixpkgs-fmt
haskellPackages.hasktags
];
tools.haskell-language-server = { };
};
};
formatCheckFor = system:
let
pkgs = nixpkgsFor system;
in
pkgs.runCommand "format-check"
{
nativeBuildInputs = self.devShells.${system}.hs.nativeBuildInputs;
} ''
export LC_CTYPE=C.UTF-8
export LC_ALL=C.UTF-8
export LANG=C.UTF-8
export IN_NIX_SHELL='pure'
make format-check lint
mkdir $out
'';
hlswFor = system:
let
pkgs = nixpkgsFor system;
in
pkgs.writeShellApplication {
name = "haskell-language-server-wrapper";
runtimeInputs = self.devShells.${system}.hs.nativeBuildInputs;
text = ''
haskell-language-server "$@"
'';
};
supportedSystems = [ "x86_64-linux" "x86_64-darwin" "aarch64-darwin" ];
perSystem = nixpkgs.lib.genAttrs supportedSystems;
in
{
project = perSystem hsProjectFor;
flake = perSystem (system: self.project.${system}.flake { });
packages = perSystem (system: self.flake.${system}.packages);
check = perSystem (system:
(nixpkgsFor system).runCommand "combined-check"
{
nativeBuildInputs = builtins.attrValues self.checks.${system}
++ builtins.attrValues self.flake.${system}.packages
++ self.devShells.${system}.hs.nativeBuildInputs;
} "touch $out");
checks = perSystem (system: self.flake.${system}.checks // {
formatCheck = formatCheckFor system;
});
devShells = perSystem (system: rec {
hs = self.flake.${system}.devShell;
hlsw = hlswFor system;
pkgs = nixpkgsFor system;
default = (nixpkgsFor system).mkShell {
inputsFrom = [ hs ];
shellHook = ''
export PATH=${hlsw}/bin:$PATH
${hs.shellHook}
'';
};
hoogle = self.project.${system}.shellFor {
additional = ps: with ps; [ cardano-api ];
withHoogle = true;
};
});
};
}