-
Notifications
You must be signed in to change notification settings - Fork 21
Expand file tree
/
Copy pathflake.nix
More file actions
158 lines (142 loc) · 4.6 KB
/
Copy pathflake.nix
File metadata and controls
158 lines (142 loc) · 4.6 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
151
152
153
154
155
156
157
158
{
description = "Jolt, a Clojure implementation on Chez Scheme";
inputs = {
nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable";
makes = {
url = "github:makeplus/makes/d14cb578c2f04e6f9d00e01c7c4e416a9baf94e9";
flake = false;
};
self.submodules = true;
};
outputs =
{
self,
nixpkgs,
makes,
}:
let
# Intel macOS is deferred: releases cross-build x86_64-macos from the
# arm64 runner, and Nix has no equivalent cross path here to validate.
systems = [
"x86_64-linux"
"aarch64-darwin"
];
forAllSystems = f: nixpkgs.lib.genAttrs systems (system: f nixpkgs.legacyPackages.${system});
mkJolt =
pkgs:
let
version = self.shortRev or "dev";
runtimePath = pkgs.lib.makeBinPath [
pkgs.git
pkgs.unzip
];
opensslLibraryPath = pkgs.lib.makeLibraryPath [ pkgs.openssl ];
cacertFile = "${pkgs.cacert}/etc/ssl/certs/ca-bundle.crt";
in
pkgs.stdenv.mkDerivation {
pname = "jolt";
inherit version;
src = self;
strictDeps = true;
nativeBuildInputs = [
pkgs.chez
pkgs.makeWrapper
pkgs.pkg-config
pkgs.xxd
];
buildInputs = [
pkgs.lz4
pkgs.zlib
pkgs.ncurses
pkgs.openssl
]
++ pkgs.lib.optionals pkgs.stdenv.hostPlatform.isLinux [ pkgs.libuuid ]
++ pkgs.lib.optionals pkgs.stdenv.hostPlatform.isDarwin [ pkgs.libiconv ];
# Flake sources contain no .git directory, so build-jolt.ss cannot
# derive the version with git describe.
JOLT_VERSION = version;
dontConfigure = true;
buildPhase = ''
runHook preBuild
scheme --script host/chez/build-jolt.ss release target/release/jolt
runHook postBuild
'';
installPhase = ''
runHook preInstall
mkdir -p "$out/bin"
install -m755 target/release/jolt "$out/bin/jolt"
runHook postInstall
'';
# jolt.deps invokes git and unzip; jolt.mvn-http dlopens OpenSSL at
# fetch time through the JOLT_OPENSSL_LIBDIR seam (its macOS built-in
# candidates are Homebrew paths, so no loader-path variable could
# cover Darwin). Pin all of them to the Nix package closure.
postFixup = ''
wrapProgram "$out/bin/jolt" \
--prefix PATH : "${runtimePath}" \
--set-default JOLT_OPENSSL_LIBDIR "${opensslLibraryPath}" \
--set-default SSL_CERT_FILE "${cacertFile}"
'';
meta = {
description = "Clojure implementation on Chez Scheme";
homepage = "https://jolt-lang.net";
license = pkgs.lib.licenses.epl20;
mainProgram = "jolt";
};
};
in
{
packages = forAllSystems (
pkgs:
let
jolt = mkJolt pkgs;
in
{
inherit jolt;
default = jolt;
}
);
apps = forAllSystems (pkgs: {
default = {
type = "app";
program = "${self.packages.${pkgs.stdenv.hostPlatform.system}.jolt}/bin/jolt";
meta.description = "Run Jolt";
};
});
devShells = forAllSystems (pkgs: {
default = pkgs.mkShell {
packages = [
# Required by makeplus/makes during Makefile initialization.
pkgs.bash
pkgs.which
pkgs.chez
pkgs.stdenv.cc
pkgs.gnumake
pkgs.pkg-config
pkgs.xxd
# Jolt deps.edn support
pkgs.git
pkgs.unzip
pkgs.openssl
# Chez/Jolt native-link dependencies
pkgs.lz4
pkgs.zlib
pkgs.ncurses
]
++ pkgs.lib.optionals pkgs.stdenv.hostPlatform.isLinux [ pkgs.libuuid ]
++ pkgs.lib.optionals pkgs.stdenv.hostPlatform.isDarwin [ pkgs.libiconv ];
# Make uses this locked source-only input instead of cloning makes.
M = makes;
JOLT_CHEZ = "${pkgs.chez}/bin/scheme";
CHEZ = "${pkgs.chez}/bin/scheme";
JOLT_OPENSSL_LIBDIR = pkgs.lib.makeLibraryPath [ pkgs.openssl ];
shellHook = ''
echo "Jolt development environment"
printf 'Chez: '
printf '(display (scheme-version)) (newline)\n' | scheme -q
'';
};
});
formatter = forAllSystems (pkgs: pkgs.nixfmt);
};
}