Repository navigation
Expand file tree
/
Copy pathflake.nix
More file actions
187 lines (183 loc) · 5.66 KB
/
Copy pathflake.nix
File metadata and controls
187 lines (183 loc) · 5.66 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
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
{
description = "dev env";
inputs = {
nixpkgs.url = "https://flakehub.com/f/NixOS/nixpkgs/0.1"; # tracks nixpkgs unstable branch
devshell.url = "github:numtide/devshell";
devshell.inputs.nixpkgs.follows = "nixpkgs";
devenv.url = "github:ramblurr/nix-devenv";
devenv.inputs.nixpkgs.follows = "nixpkgs";
clj-nix.url = "github:jlesquembre/clj-nix";
clj-nix.inputs.nixpkgs.follows = "nixpkgs";
};
outputs =
inputs@{
self,
clj-nix,
devenv,
devshell,
...
}:
let
prepareWritableCljCache = ''
deps_cache="''${JAVA_TOOL_OPTIONS#-Duser.home=}"
export HOME="$(mktemp -d)"
cp -R -L "$deps_cache/.m2" "$HOME/.m2"
cp -R -L "$deps_cache/.gitlibs" "$HOME/.gitlibs"
cp -R -L "$deps_cache/.clojure" "$HOME/.clojure"
chmod -R u+w "$HOME"
export JAVA_TOOL_OPTIONS="-Duser.home=$HOME"
'';
in
devenv.lib.mkFlake ./. {
inherit inputs;
treefmtConfig = {
programs = {
nixfmt.enable = true;
cljfmt.enable = true;
prettier.enable = true;
mdformat.plugins =
ps: with ps; [
mdformat-gfm
mdformat-gfm-alerts
];
};
};
withOverlays = [
devshell.overlays.default
devenv.overlays.default
clj-nix.overlays.default
];
packages =
let
mkLlxPackage =
pkgs:
let
root = toString ./.;
gitRev =
if self ? rev then
self.rev
else if self ? dirtyRev then
self.dirtyRev
else
"dirty";
projectSrc = pkgs.lib.cleanSourceWith {
src = ./.;
filter =
path: _type:
let
rel = pkgs.lib.removePrefix (root + "/") (toString path);
base = builtins.baseNameOf path;
in
!(
base == ".git"
|| rel == "result"
|| pkgs.lib.hasPrefix "node_modules/" rel
|| pkgs.lib.hasPrefix "target/" rel
|| pkgs.lib.hasPrefix ".shadow-cljs/" rel
|| pkgs.lib.hasPrefix ".cpcache/" rel
|| pkgs.lib.hasPrefix "tmp/" rel
);
};
in
pkgs.mkCljLib {
inherit projectSrc;
name = "com.outskirtslabs/llx";
version = "0.0.1";
nativeBuildInputs = [
pkgs.coreutils
];
GIT_REV = gitRev;
JAVA_HOME = pkgs.jdk25.home;
buildCommand = ''
export JAVA_HOME="${pkgs.jdk25.home}"
export JAVA_CMD="${pkgs.jdk25}/bin/java"
${prepareWritableCljCache}
clojure -M:dev:kaocha :unit
clojure -T:build jar
'';
};
in
{
default = mkLlxPackage;
};
checks =
let
mkLlxPackage = pkgs: self.packages.${pkgs.system}.default;
mkCljsCheck =
pkgs:
let
root = toString ./.;
projectSrc = pkgs.lib.cleanSourceWith {
src = ./.;
filter =
path: _type:
let
rel = pkgs.lib.removePrefix (root + "/") (toString path);
base = builtins.baseNameOf path;
in
!(
base == ".git"
|| rel == "result"
|| pkgs.lib.hasPrefix "node_modules/" rel
|| pkgs.lib.hasPrefix "target/" rel
|| pkgs.lib.hasPrefix ".shadow-cljs/" rel
|| pkgs.lib.hasPrefix ".cpcache/" rel
|| pkgs.lib.hasPrefix "tmp/" rel
);
};
npmDeps = pkgs.fetchNpmDeps {
src = projectSrc;
hash = "sha256-loXK2ZmTWxCnP/ym4F+5ZK8pWLAunrTTSmrjwy4wyWc=";
};
in
pkgs.mkCljLib {
inherit projectSrc;
name = "com.outskirtslabs/llx-cljs-tests";
version = "0.0.1";
nativeBuildInputs = [
pkgs.coreutils
pkgs.nodejs
pkgs.npmHooks.npmConfigHook
];
inherit npmDeps;
JAVA_HOME = pkgs.jdk25.home;
buildCommand = ''
export JAVA_HOME="${pkgs.jdk25.home}"
export JAVA_CMD="${pkgs.jdk25}/bin/java"
export PATH="${pkgs.nodejs}/bin:$PATH"
${prepareWritableCljCache}
# start funnel in the background (required by kaocha-cljs2)
clojure -M:funnel &
FUNNEL_PID=$!
sleep 2
clojure -M:dev:kaocha :cljs
kill $FUNNEL_PID 2>/dev/null || true
'';
installPhase = ''
mkdir -p $out
echo "cljs tests passed" > $out/result.txt
'';
};
in
{
default = mkLlxPackage;
cljs = mkCljsCheck;
};
devShell =
pkgs:
pkgs.devshell.mkShell {
imports = [
devenv.capsules.base
devenv.capsules.clojure
];
# https://numtide.github.io/devshell
commands = [
];
packages = [
pkgs.deps-lock
pkgs.jdk25
pkgs.nodejs
];
};
};
}