generated from nix-community/nur-packages-template
-
Notifications
You must be signed in to change notification settings - Fork 5
/
flake.nix
432 lines (332 loc) · 12.2 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
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
{
description = "Geospatial packages repository";
nixConfig = {
extra-substituters = [ "https://geonix.cachix.org" ];
extra-trusted-public-keys = [ "geonix.cachix.org-1:iyhIXkDLYLXbMhL3X3qOLBtRF8HEyAbhPXjjPeYsCl0=" ];
bash-prompt = "\\[\\033[1m\\][geonix]\\[\\033\[m\\]\\040\\w >\\040";
};
inputs = {
nixpkgs.url = "github:NixOS/nixpkgs/nixos-24.05";
nixgl = {
url = "github:nix-community/nixGL";
inputs.nixpkgs.follows = "nixpkgs";
};
flake-utils.url = "github:numtide/flake-utils";
flake-compat = {
url = "github:edolstra/flake-compat";
flake = false;
};
};
outputs = { self, nixpkgs, nixgl, flake-utils, ... }:
flake-utils.lib.eachSystem [ "x86_64-linux" ]
(system:
let
pkgs = nixpkgs.legacyPackages.${system};
in
{
# Each new package must be added to:
# * flake.nix: packages
# * flake.nix: python-packages.all-packages or postgresql-packages.all-packages
# * overrides.nix
# * pkgs/<PKG>/nixpkgs/files.txt
#
### PACKAGES ###
#
packages =
let
inherit (nixpkgs.lib) forEach genAttrs mapAttrs';
inherit (nixpkgs.lib.attrsets) attrValues filterAttrs mergeAttrsList;
pythonVersions = [
"python3" # default Python version
"python310"
"python311"
];
forAllPythonVersions = f: genAttrs pythonVersions (python: f python);
postgresqlVersions = [
"postgresql" # default PostgreSQL version
"postgresql_12"
"postgresql_13"
"postgresql_14"
"postgresql_15"
"postgresql_16"
];
forAllPostgresqlVersions = f: genAttrs postgresqlVersions (postgresql: f postgresql);
# Function: prefix packages and remove `__toString` attribute
prefixPackages = packages: prefix:
builtins.removeAttrs
(mapAttrs'
(
name: value: { name = "${prefix}-" + name; value = value; }
)
packages
)
[ "${prefix}-__toString" ];
# Core libs
gdal = pkgs.callPackage ./pkgs/gdal {
inherit geos libgeotiff libspatialite proj tiledb;
useJava = false;
};
gdal-minimal = pkgs.callPackage ./pkgs/gdal {
inherit geos libgeotiff libspatialite proj tiledb;
useMinimalFeatures = true;
};
gdal-master = (pkgs.callPackage ./pkgs/gdal/master.nix {
inherit gdal;
}).master;
_gdal = gdal;
geos = pkgs.callPackage ./pkgs/geos { };
libgeotiff = pkgs.callPackage ./pkgs/libgeotiff {
inherit proj;
};
librttopo = pkgs.callPackage ./pkgs/librttopo {
inherit geos;
};
libspatialindex = pkgs.callPackage ./pkgs/libspatialindex/package.nix { };
libspatialite = pkgs.callPackage ./pkgs/libspatialite {
inherit geos librttopo proj;
};
pdal = pkgs.callPackage ./pkgs/pdal {
inherit gdal libgeotiff proj tiledb;
};
proj = pkgs.callPackage ./pkgs/proj { };
# Python packages
python-packages = forAllPythonVersions (python:
let
py = pkgs.${python};
in
rec {
fiona = py.pkgs.callPackage ./pkgs/fiona {
inherit gdal;
};
gdal = py.pkgs.toPythonModule (_gdal);
geopandas = py.pkgs.callPackage ./pkgs/geopandas {
inherit pyogrio pyproj shapely;
};
owslib = py.pkgs.callPackage ./pkgs/owslib {
inherit pyproj;
};
psycopg = (py.pkgs.psycopg.overrideAttrs (_: {
# Disable flaky tests.
# Remove in nixos 24.11.
# https://github.com/NixOS/nixpkgs/pull/344310/commits/e4212a9b2d5814a3548e38160e8b2eaa526b2c84
dontUsePytestCheck = true;
})).override {
inherit shapely;
};
pyogrio = py.pkgs.callPackage ./pkgs/pyogrio {
inherit gdal;
};
pyproj = py.pkgs.callPackage ./pkgs/pyproj {
inherit proj shapely;
};
pyqt5 = py.pkgs.pyqt5.override {
withLocation = true;
withSerialPort = true;
};
pystac = py.pkgs.callPackage ./pkgs/pystac { };
rasterio = py.pkgs.callPackage ./pkgs/rasterio {
inherit gdal shapely;
};
shapely = py.pkgs.callPackage ./pkgs/shapely {
inherit geos;
};
# all packages (single Python version)
all-packages = pkgs.symlinkJoin {
name = "all-${python}-packages";
paths = [
fiona
gdal
geopandas
owslib
psycopg
pyogrio
pyproj
pyqt5
pystac
rasterio
shapely
];
};
__toString = self: python;
});
# Postgresql packages
postgresql-packages = forAllPostgresqlVersions (postgresql:
let
pg = pkgs.${postgresql};
in
rec {
postgis = pkgs.callPackage ./pkgs/postgis/postgis.nix {
inherit geos proj;
gdalMinimal = gdal-minimal;
postgresql = pg;
jitSupport = false;
};
# all packages (single Postgresql version)
all-packages = pkgs.symlinkJoin {
name = "all-${postgresql}-packages";
paths = [
postgis
];
};
__toString = self: postgresql;
});
# PG_Featureserv
pg_featureserv = pkgs.callPackage ./pkgs/pg_featureserv { };
# PG_Tileserv
pg_tileserv = pkgs.callPackage ./pkgs/pg_tileserv { };
# TileDB
tiledb = pkgs.callPackage ./pkgs/tiledb { };
# GRASS
grass = pkgs.callPackage ./pkgs/grass {
inherit gdal geos pdal proj;
};
grass-plugins =
let
plugins = import ./pkgs/grass/plugins-list.nix;
in
mapAttrs'
(
name: value: {
name = "grass-plugin-${name}";
value = pkgs.callPackage ./pkgs/grass/plugins.nix {
name = name;
plugin = value;
inherit grass;
geopkgs-python3 = python-packages.python3;
};
}
)
plugins;
# QGIS
qgis-python =
let
packageOverrides = final: prev: {
pyqt5 = python-packages.python3.pyqt5;
owslib = python-packages.python3.owslib;
gdal = python-packages.python3.gdal;
};
in
pkgs.python3.override { inherit packageOverrides; self = qgis-python; };
qgis-unwrapped = pkgs.libsForQt5.callPackage ./pkgs/qgis/unwrapped.nix {
inherit geos gdal libspatialindex libspatialite pdal proj;
python3 = qgis-python;
};
qgis = pkgs.callPackage ./pkgs/qgis { qgis-unwrapped = qgis-unwrapped; };
# QGIS-LTR
qgis-ltr-unwrapped = pkgs.libsForQt5.callPackage ./pkgs/qgis/unwrapped-ltr.nix {
inherit geos gdal libspatialindex libspatialite pdal proj;
python3 = qgis-python;
};
qgis-ltr = pkgs.callPackage ./pkgs/qgis/ltr.nix { qgis-unwrapped = qgis-ltr-unwrapped; };
# QGIS plugins
qgis-plugins =
let
plugins = import ./pkgs/qgis/qgis-plugins-list.nix;
in
mapAttrs'
(
name: value: {
name = "qgis-plugin-${name}";
value = pkgs.callPackage ./pkgs/qgis/plugins.nix { name = name; plugin = value; };
}
)
plugins;
qgis-ltr-plugins =
let
plugins = import ./pkgs/qgis/qgis-ltr-plugins-list.nix;
in
mapAttrs'
(
name: value: {
name = "qgis-ltr-plugin-${name}";
value = pkgs.callPackage ./pkgs/qgis/plugins.nix { name = name; plugin = value; };
}
)
plugins;
# nixGL
nixGL = nixgl.packages.${system}.nixGLIntel;
# all-packages (meta package containing all packages)
all-packages = pkgs.symlinkJoin {
name = "all-packages";
paths = attrValues (filterAttrs (n: v: n != "all-packages") self.packages.${system});
};
in
flake-utils.lib.filterPackages system
{
inherit
# Core libs
gdal
gdal-minimal
gdal-master
geos
libgeotiff
librttopo
libspatialindex
libspatialite
pdal
proj
pg_featureserv
pg_tileserv
tiledb
# Applications
grass
grass-plugins
qgis
qgis-unwrapped
qgis-ltr
qgis-ltr-unwrapped
# Meta packages
all-packages
# nixGL
nixGL;
}
# GRASS plugins
// grass-plugins
# QGIS plugins
// qgis-plugins
// qgis-ltr-plugins
# Add Python packages in all versions
// mergeAttrsList (forEach (builtins.attrValues python-packages) (p: prefixPackages p "${p}"))
# Add Postgresql packages in all versions
// mergeAttrsList (forEach (builtins.attrValues postgresql-packages) (p: prefixPackages p "${p}"));
#
### APPS ##
#
apps = rec {
qgis = {
type = "app";
program = "${self.packages.${system}.qgis}/bin/qgis";
};
qgis-ltr = {
type = "app";
program = "${self.packages.${system}.qgis-ltr}/bin/qgis";
};
default = qgis;
};
#
### SHELLS ###
#
devShells = import ./shells.nix { inherit self system pkgs; };
#
### CHECKS ###
#
checks = import ./checks.nix { inherit self system nixpkgs pkgs; };
}) // {
#
### OVERLAYS ###
#
overlays = {
x86_64-linux = _: _: {
geonix = self.packages.x86_64-linux;
};
};
#
### LIB ###
#
lib = import ./lib { };
#
### OVERRIDES ###
#
overrides = ./overrides.nix;
};
}