forked from IntersectMBO/formal-ledger-specifications
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathflake.nix
More file actions
150 lines (135 loc) · 4.29 KB
/
flake.nix
File metadata and controls
150 lines (135 loc) · 4.29 KB
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
# flake.nix
{
description = "Formal Ledger Specifications";
inputs = {
nixpkgs.url = "github:NixOs/nixpkgs";
flake-utils.url = "github:numtide/flake-utils";
agda-nix = {
url = "github:input-output-hk/agda.nix";
inputs.nixpkgs.follows = "nixpkgs";
};
fls-agda = {
url = "./build-tools/agda";
inputs.nixpkgs.follows = "nixpkgs";
};
fls-shake = {
url = "./build-tools/shake";
inputs.nixpkgs.follows = "nixpkgs";
};
};
outputs =
{ self, flake-utils, ... }@inputs:
let
systems = [
"x86_64-linux"
"aarch64-darwin"
];
overlay-formal-ledger = final: prev: {
agdaPackages = prev.agdaPackages.overrideScope (
afinal: aprev: {
formal-ledger = afinal.callPackage ./build-tools/nix/formal-ledger.nix { };
}
);
};
perSystem = flake-utils.lib.eachSystem systems (
system:
let
nixpkgs = import inputs.nixpkgs {
inherit system;
overlays = [
# it's important to apply this overlay first
# (see https://github.com/NixOS/nixpkgs/issues/447012)
inputs.fls-agda.overlays.default
inputs.agda-nix.overlays.default
overlay-formal-ledger
];
};
agdaWithPackages = nixpkgs.agda.withPackages (
builtins.filter (p: p ? isAgdaDerivation) nixpkgs.agdaPackages.formal-ledger.buildInputs
);
fls-shake = inputs.fls-shake.packages.${system}.default.override (_: {
fls-agda = agdaWithPackages;
});
mkDerivation =
args:
let
default = {
version = "0.1";
meta = args.meta or { };
buildInputs = (args.buildInputs or [ ]) ++ [
agdaWithPackages
fls-shake
nixpkgs.agdaPackages.formal-ledger
];
copyAgdaBuild = ''
cp -r "${nixpkgs.agdaPackages.formal-ledger}/_build" .
find _build -type d -print0 | xargs -0 chmod 755
find _build -type f -print0 | xargs -0 chmod 644
'';
preBuildPhases = (args.preBuildPhases or [ ]) ++ [ "copyAgdaBuild" ];
};
in
nixpkgs.stdenv.mkDerivation (args // default);
pkgs = {
formal-ledger = nixpkgs.agdaPackages.formal-ledger;
hs-src = nixpkgs.callPackage ./build-tools/nix/hs-src.nix { inherit mkDerivation; };
html = nixpkgs.callPackage ./build-tools/nix/html.nix { inherit mkDerivation; };
mkdocs = nixpkgs.callPackage ./build-tools/nix/mkdocs.nix { inherit mkDerivation; };
};
in
{
packages = pkgs // {
default = pkgs.formal-ledger;
inherit agdaWithPackages;
};
devShells = with nixpkgs; {
default = mkShell {
inputsFrom = builtins.attrValues pkgs;
};
# Minimal environment for CI builds (see GH actions)
ci = mkShell {
packages = [
fls-shake
];
};
# Complete documentation pipeline (mkdocs)
mkdocs = mkShell {
inputsFrom = [
pkgs.mkdocs
];
};
};
hydraJobs =
let
jobs = {
inherit agdaWithPackages;
formal-ledger = nixpkgs.agdaPackages.formal-ledger;
}
// pkgs;
in
jobs
// {
required = nixpkgs.releaseTools.aggregate {
name = "${system}-required";
constituents = with nixpkgs.lib; collect isDerivation jobs;
};
};
}
);
in
perSystem
// {
hydraJobs = perSystem.hydraJobs // {
required =
let
nixpkgs = import inputs.nixpkgs {
system = builtins.head systems;
};
in
nixpkgs.releaseTools.aggregate {
name = "required";
constituents = map (system: perSystem.hydraJobs.${system}.required) systems;
};
};
};
}