1
{
2
pkgs,
3
lib,
4
beamPackages,
5
mdex,
6
autumn,
7
erlang,
8
elixir,
9
rust,
10
heroicons,
11
esbuild,
12
tailwindcss_4,
13
...
14
}:
15
let
16
mixNixDeps = import ./deps.nix {
17
inherit lib beamPackages;
18
overrides = final: prev: {
19
inherit mdex autumn;
20
21
lazy_html = prev.lazy_html.overrideAttrs (
22
prevAttrs:
23
let
24
lexborVersion = "2.4.0";
25
lexbor = pkgs.fetchFromGitHub {
26
owner = "lexbor";
27
repo = "lexbor";
28
tag = "v${lexborVersion}";
29
hash = "sha256-wsm+2L2ar+3LGyBXl39Vp9l1l5JONWvO0QbI87TDfWM=";
30
};
31
in
32
{
33
nativeBuildInputs = prevAttrs.nativeBuildInputs ++ (with pkgs; [ cmake ]);
34
35
prePatch = ''
36
# ensure the version is in sync.
37
grep -q '@lexbor_version "${lexborVersion}"' mix.exs
38
mkdir -p _build/c/third_party/lexbor
39
cp -r ${lexbor} _build/c/third_party/lexbor/${lexborVersion}
40
chmod -R u+w _build/c/third_party/lexbor/${lexborVersion}
41
'';
42
43
patches = [
44
./lazy_html-mix.exs.patch
45
];
46
}
47
);
48
49
fine = prev.fine.overrideAttrs {
50
patches = [
51
./fine-lib-fine.ex.patch
52
];
53
};
54
};
55
};
56
nodeDeps = (pkgs.callPackage ./node2nix-default.nix { }).nodeDependencies;
57
in
58
beamPackages.mixRelease rec {
59
pname = "kv";
60
src = lib.fileset.toSource rec {
61
root = ../.;
62
fileset = lib.fileset.unions [
63
(root + /assets)
64
(root + /config)
65
(root + /lib)
66
(root + /mix.exs)
67
(root + /mix.lock)
68
(root + /priv)
69
(root + /rel)
70
(root + /test)
71
];
72
};
73
version = "0.1.0";
74
inherit mixNixDeps;
75
76
nativeBuildInputs = [ pkgs.makeWrapper ];
77
buildInputs = [
78
elixir
79
rust
80
esbuild
81
tailwindcss_4
82
];
83
84
postConfigure = ''
85
ln -s ${heroicons} deps/heroicons
86
ln -s ${nodeDeps}/lib/node_modules assets/node_modules
87
'';
88
89
# Deploy assets before creating release
90
preInstall = ''
91
# https://github.com/phoenixframework/phoenix/issues/2690
92
mix do deps.loadpaths --no-deps-check, assets.deploy
93
'';
94
95
postInstall = ''
96
wrapProgram "$out/bin/kv" \
97
--run '
98
if test -n "$KV_SNAME"; then
99
export RELEASE_NODE="$KV_SNAME"
100
export RELEASE_DISTRIBUTION="sname"
101
else
102
export RELEASE_DISTRIBUTION="name"
103
fi
104
'
105
106
ln -s $out/lib/kv-*/priv $out/priv
107
echo >>$out/releases/${version}/vm.args "-start_epmd false"
108
echo >>$out/releases/${version}/remote.vm.args "-start_epmd false"
109
'';
110
111
KV_ESBUILD = "${esbuild}/bin/esbuild";
112
KV_TAILWINDCSS = "${tailwindcss_4}/bin/tailwindcss";
113
114
passthru = {
115
inherit erlang elixir;
116
};
117
}
118