-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathflake.nix
129 lines (118 loc) · 4.34 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
{
description = "PureScript implementation of the Marlowe smart contract language";
inputs = {
flake-utils.url = "github:numtide/flake-utils";
nixpkgs.url = "github:NixOS/nixpkgs/nixpkgs-unstable";
pre-commit-hooks = {
url = "github:cachix/pre-commit-hooks.nix";
inputs.nixpkgs.follows = "nixpkgs";
};
easy-purescript-nix = {
url = "github:justinwoo/easy-purescript-nix";
flake = false;
};
marloweSpec.url = "github:input-output-hk/marlowe";
nixLsp.url = "github:oxalica/nil";
gitignore = {
url = "github:hercules-ci/gitignore.nix";
inputs.nixpkgs.follows = "nixpkgs";
};
};
outputs = { self, nixpkgs, pre-commit-hooks, flake-utils, easy-purescript-nix, nixLsp, gitignore, marloweSpec }:
let
inherit (flake-utils.lib) eachSystem system;
supportedSystems = [ system.x86_64-linux system.x86_64-darwin ];
base = { evalSystem ? null }: eachSystem supportedSystems
(system:
let evalSystem' = if evalSystem == null then system else evalSystem; in
let
evalSystem = evalSystem';
overlays = [ nixLsp.overlays.nil ];
pkgs = import nixpkgs { inherit system overlays; };
inherit (gitignore.lib) gitignoreSource;
inherit (pkgs) git writeShellScriptBin mkShell nodePackages;
easy-ps = import easy-purescript-nix { inherit pkgs; };
src = gitignoreSource ./.;
writeShellScriptBinInRepoRoot = name: script: writeShellScriptBin name ''
cd `${git}/bin/git rev-parse --show-toplevel`
${script}
'';
formatting = import ./nix/formatting.nix {
inherit writeShellScriptBinInRepoRoot pkgs easy-ps;
};
pre-commit-check = pre-commit-hooks.lib.${system}.run {
inherit src;
hooks = {
nixpkgs-fmt = {
enable = true;
excludes = [ ".*spago-packages.nix$" ];
};
prettier = formatting.prettier-hook;
inherit (formatting) purs-tidy-hook dhall-hook;
};
};
purescript-marlowe = import ./nix/purescript-marlowe.nix {
inherit pkgs src easy-ps writeShellScriptBinInRepoRoot marloweSpecDriver;
};
marloweSpecDriver = marloweSpec.packages."${system}"."marlowe-spec-test:exe:marlowe-spec";
packages = {
default = purescript-marlowe.marlowe;
generateSpagoPackages = purescript-marlowe.generateSpagoPackages;
generateNpmPackages = purescript-marlowe.generateNpmPackages;
};
in
{
inherit packages;
hydraJobs = packages;
devShells.default = mkShell {
buildInputs = [
marloweSpecDriver
pkgs.nil
pkgs.nodejs
nodePackages.prettier
nodePackages.bower
nodePackages.node2nix
] ++
(with easy-ps; [
dhall-simple
purs
psa
spago
spago2nix
purs-tidy
purescript-language-server
]) ++
(with purescript-marlowe; [
build
clean
clean-build
test
generateSpagoPackages
marlowe-spec-client
build-docs
serve-docs
]) ++
(with formatting; [
fix-purs-tidy
fix-nix-fmt
fix-prettier
]
);
inherit (pre-commit-check) shellHook;
};
}
);
hydraSystem = "x86_64-linux";
pkgsHydra = nixpkgs.legacyPackages.${hydraSystem};
baseHydra = base { evalSystem = hydraSystem; };
in
base { } // {
hydraJobs = baseHydra.hydraJobs // {
forceNewEval = pkgsHydra.writeText "forceNewEval" (self.rev or self.lastModified);
required = pkgsHydra.releaseTools.aggregate {
name = "purescript-marlowe";
constituents = builtins.concatMap (system: map (x: "${x}.${system}") (builtins.attrNames baseHydra.hydraJobs)) supportedSystems;
};
};
};
}