Repository navigation
Expand file tree
/
Copy pathflake.nix
More file actions
96 lines (81 loc) · 3.25 KB
/
Copy pathflake.nix
File metadata and controls
96 lines (81 loc) · 3.25 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
{
description = "speedata Publisher: database publishing software";
inputs = {
nixpkgs.url = "github:nixos/nixpkgs/nixpkgs-unstable";
flake-utils.url = "github:numtide/flake-utils";
};
outputs =
{
self,
nixpkgs,
flake-utils,
}:
flake-utils.lib.eachDefaultSystem (
system:
let
pkgs = nixpkgs.legacyPackages.${system};
inherit (pkgs) lib;
version = lib.head (
builtins.match ".*publisher_version=([^\n]*).*" (builtins.readFile ./version)
);
luahbtex = pkgs.texlivePackages.luahbtex;
platform = pkgs.stdenv.hostPlatform;
goos = if platform.isDarwin then "darwin" else platform.parsed.kernel.name;
goarch = platform.go.GOARCH or (if platform.isAarch64 then "arm64" else "amd64");
in
{
packages = rec {
default = speedata-publisher;
speedata-publisher = pkgs.buildGoModule {
pname = "speedata-publisher";
inherit version;
src = self;
modRoot = "src/go";
vendorHash = "sha256-c1DvuhUESQVDSnfv+Q7/BvXzwwc8w6a+KxfFTWLFjEU=";
buildInputs = [ pkgs.lua5_3 ];
# `sphelper distcustom` does the whole build: sp (compiled with
# dest=custom, so libdir/srcdir point at the final store paths),
# libsplib.so and luaglue.so, plus the share/sw directory layout.
# LUATEX_BIN is left unset: instead of shipping the prebuilt
# sdluatex we symlink luahbtex from TeX Live, which sp falls
# back to (and drives via --ini --lua=sdini.lua).
buildPhase = ''
runHook preBuild
root=$(cd ../.. && pwd)
go build -o sphelper-bin speedatapublisher/sphelper/sphelper
export SP_BUILDDIR_BIN=$out/bin SP_DESTDIR_BIN=$out/bin
export SP_BUILDDIR_SHARE=$out/share SP_DESTDIR_SHARE=$out/share
export SP_BUILDDIR_SW=$out/sw SP_DESTDIR_SW=$out/sw
export CGO_CFLAGS="-I${pkgs.lua5_3}/include"
${lib.optionalString platform.isDarwin ''export CGO_LDFLAGS="-undefined dynamic_lookup"''}
${lib.optionalString (!platform.isDarwin) ''export CC_${goarch}_${goos}=$CC''}
./sphelper-bin --basedir "$root" distcustom ${goos}/${goarch}
runHook postBuild
'';
installPhase = ''
runHook preInstall
for f in libsplib.so luaglue.so; do
test -f "$out/share/lib/$f" || { echo "$f missing in $out/share/lib" >&2; exit 1; }
done
ln -s ${luahbtex}/bin/luahbtex $out/bin/luahbtex
runHook postInstall
'';
doCheck = false;
meta = {
description = "Database publishing software with XML layout descriptions";
homepage = "https://www.speedata.de/";
license = lib.licenses.agpl3Only;
mainProgram = "sp";
};
};
};
apps.default = {
type = "app";
program = "${self.packages.${system}.default}/bin/sp";
};
devShells.default = pkgs.mkShell {
buildInputs = [ self.packages.${system}.default ];
};
}
);
}