1{
2 lib,
3 nixosTests,
4 fetchFromGitHub,
5 beamPackages,
6 gitMinimal,
7 pnpm_9,
8 nodejs,
9 tailwindcss_3,
10 esbuild,
11
12 mixReleaseName ? "domain", # "domain" "web" or "api"
13}:
14
15beamPackages.mixRelease rec {
16 pname = "firezone-server-${mixReleaseName}";
17 version = "0-unstable-2025-03-15";
18
19 src = "${
20 fetchFromGitHub {
21 owner = "firezone";
22 repo = "firezone";
23 rev = "09fb5f927410503b0d6e7fc6cf6a2ba06cb5a281";
24 hash = "sha256-1CZBFhOwX0DfXykPQ9tzn4tHg2tSnByXEPtlZleHK5k=";
25
26 # This is necessary to allow sending mails via SMTP, as the default
27 # SMTP adapter is current broken: https://github.com/swoosh/swoosh/issues/785
28 postFetch = ''
29 ${lib.getExe gitMinimal} -C $out apply ${./0000-add-mua.patch}
30 '';
31 }
32 }/elixir";
33
34 pnpmDeps = pnpm_9.fetchDeps {
35 inherit pname version;
36 src = "${src}/apps/web/assets";
37 fetcherVersion = 1;
38 hash = "sha256-ejyBppFtKeyVhAWmssglbpLleOnbw9d4B+iM5Vtx47A=";
39 };
40 pnpmRoot = "apps/web/assets";
41
42 preBuild = ''
43 cat >> config/config.exs <<EOF
44 config :tailwind, path: "${lib.getExe tailwindcss_3}"
45 config :esbuild, path: "${lib.getExe esbuild}"
46 EOF
47
48 cat >> config/runtime.exs <<EOF
49 config :tzdata, :data_dir, System.fetch_env!("TZDATA_DIR")
50 EOF
51 '';
52
53 postBuild = ''
54 pushd apps/web
55 # for external task you need a workaround for the no deps check flag
56 # https://github.com/phoenixframework/phoenix/issues/2690
57 mix do deps.loadpaths --no-deps-check, assets.deploy
58 mix do deps.loadpaths --no-deps-check, phx.digest priv/static
59 popd
60 '';
61
62 nativeBuildInputs = [
63 pnpm_9
64 pnpm_9.configHook
65 nodejs
66 ];
67
68 inherit mixReleaseName;
69
70 mixFodDeps = beamPackages.fetchMixDeps {
71 pname = "mix-deps-${pname}-${version}";
72 inherit src version;
73 hash = "sha256-2Y9u5+o8+RG+c8Z6V7Vex5K1odI7a/WYj5fC0xWbVRo=";
74 };
75
76 passthru.tests = {
77 inherit (nixosTests) firezone;
78 };
79
80 meta = {
81 description = "Backend server for the Firezone zero-trust access platform";
82 homepage = "https://github.com/firezone/firezone";
83 license = lib.licenses.elastic20;
84 maintainers = with lib.maintainers; [
85 oddlama
86 patrickdag
87 ];
88 mainProgram = mixReleaseName;
89 platforms = lib.platforms.linux;
90 };
91}