-
Notifications
You must be signed in to change notification settings - Fork 4
/
flake.nix
189 lines (168 loc) · 5.54 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
179
180
181
182
183
184
185
186
187
188
189
{
description = "Packages and development environments for ddnnife";
inputs = {
nixpkgs.url = "github:NixOS/nixpkgs/nixos-24.11";
fenix = {
url = "github:nix-community/fenix";
inputs.nixpkgs.follows = "nixpkgs";
};
crane = {
url = "github:ipetkov/crane/v0.19.3";
inputs.nixpkgs.follows = "nixpkgs";
};
d4 = {
url = "github:SoftVarE-Group/d4v2/mt-kahypar";
inputs.nixpkgs.follows = "nixpkgs";
};
};
outputs =
{
self,
nixpkgs,
fenix,
crane,
d4,
...
}:
let
lib = nixpkgs.lib;
# All supported build systems, the Windows build is cross-compiled.
systems = [
"aarch64-darwin"
"aarch64-linux"
"x86_64-darwin"
"x86_64-linux"
];
# Determines the build system from the given package set.
# Can be used for pointing to Windows cross-builds.
buildSystem =
pkgs:
if pkgs.stdenv.hostPlatform.isWindows then pkgs.stdenv.buildPlatform.system else pkgs.stdenv.system;
# If building for Windows, appends -windows, otherwise nothing.
windowsSuffix = pkgs: name: if pkgs.stdenv.hostPlatform.isWindows then "${name}-windows" else name;
# A simple README explaining how to setup the built directories to run the binaries.
documentation =
pkgs:
pkgs.stdenv.mkDerivation {
name = "ddnnife-documentation";
src = ./doc;
installPhase = ''
mkdir $out
cp ${pkgs.stdenv.system}.md $out/README.md
'';
};
# The d4-enabled binaries with all dependencies.
bundled-d4 =
pkgs:
let
system = buildSystem pkgs;
windowsSuffix' = windowsSuffix pkgs;
in
pkgs.buildEnv {
name = "ddnnife";
paths = [
self.packages.${system}."${windowsSuffix' "ddnnife"}-d4"
d4.packages.${system}.${windowsSuffix' "dependencies"}
(documentation pkgs)
];
};
in
{
formatter = lib.genAttrs systems (system: nixpkgs.legacyPackages.${system}.nixfmt-rfc-style);
packages = lib.genAttrs systems (
system:
let
pkgs = nixpkgs.legacyPackages.${system};
pkgs-windows = pkgs.pkgsCross.mingwW64;
defaultAttrs = {
buildPkgs = pkgs;
inherit fenix;
inherit crane;
component = "ddnnife_bin";
};
staticAttrs.hostPkgs = pkgs.pkgsStatic;
windowsAttrs.hostPkgs = pkgs-windows;
d4Attrs = defaultAttrs // {
d4 = true;
mt-kahypar = d4.packages.${system}.mt-kahypar;
};
libAttrs = {
name = "libddnnife";
component = "ddnnife";
library = true;
test = false;
};
in
{
default = self.packages.${system}.ddnnife-d4;
ddnnife = import ./nix/ddnnife.nix defaultAttrs;
ddnnife-static = import ./nix/ddnnife.nix (defaultAttrs // staticAttrs);
ddnnife-d4 = import ./nix/ddnnife.nix d4Attrs;
ddnnife-d4-bundled = bundled-d4 pkgs;
ddnnife-windows = import ./nix/ddnnife.nix (defaultAttrs // windowsAttrs);
ddnnife-windows-d4 = import ./nix/ddnnife.nix (
d4Attrs // windowsAttrs // { mt-kahypar = d4.packages.${system}.mt-kahypar-windows; }
);
ddnnife-windows-d4-bundled = bundled-d4 pkgs-windows;
libddnnife = import ./nix/ddnnife.nix (defaultAttrs // libAttrs);
libddnnife-d4 = import ./nix/ddnnife.nix (d4Attrs // libAttrs);
dependencies-d4 = d4.packages.${system}.dependencies;
dependencies-d4-windows = d4.packages.${system}.dependencies-windows;
bindgen = import ./nix/ddnnife.nix (
defaultAttrs
// {
name = "bindgen";
component = "ddnnife_bindgen";
test = false;
}
);
python = import ./nix/ddnnife.nix (
defaultAttrs
// {
pythonLib = true;
component = "ddnnife";
test = false;
}
);
documentation = import ./nix/ddnnife.nix (
defaultAttrs
// {
documentation = true;
component = "ddnnife";
}
);
container = pkgs.dockerTools.buildLayeredImage {
name = "ddnnife";
contents = [ self.packages.${system}.ddnnife-d4 ];
config = {
Entrypoint = [ "/bin/ddnnife" ];
Labels = {
"org.opencontainers.image.source" = "https://github.com/SoftVarE-Group/d-dnnf-reasoner";
"org.opencontainers.image.description" = "A d-DNNF reasoner";
"org.opencontainers.image.licenses" = "LGPL-3.0-or-later";
};
};
};
}
);
checks = lib.genAttrs systems (
system:
let
defaultAttrs = {
buildPkgs = nixpkgs.legacyPackages.${system};
inherit fenix;
inherit crane;
};
d4Attrs = defaultAttrs // {
d4 = true;
mt-kahypar = d4.packages.${system}.mt-kahypar;
};
in
{
format = import ./nix/ddnnife.nix (defaultAttrs // { format = true; });
lint = import ./nix/ddnnife.nix (d4Attrs // { lint = true; });
deny = import ./nix/ddnnife.nix (defaultAttrs // { deny = true; });
}
);
};
}