treewide: use `addBinToPathHook`, minor cleanups (#379187)
[NixPkgs.git] / pkgs / by-name / st / stalwart-mail / webadmin.nix
blob81d86a11b16932d3902d2173d85002f5b2c8174b
2   lib,
3   rustPlatform,
4   fetchFromGitHub,
5   trunk,
6   tailwindcss,
7   fetchNpmDeps,
8   nix-update-script,
9   nodejs,
10   npmHooks,
11   llvmPackages,
12   wasm-bindgen-cli_0_2_93,
13   binaryen,
14   zip,
17 rustPlatform.buildRustPackage rec {
18   pname = "webadmin";
19   version = "0.1.20";
21   src = fetchFromGitHub {
22     owner = "stalwartlabs";
23     repo = "webadmin";
24     tag = "v${version}";
25     hash = "sha256-0/XiYFQDqcpRS9DXPyKQwoifnEd2YxFiyDbV12zd2RU=";
26   };
28   npmDeps = fetchNpmDeps {
29     inherit src;
30     name = "${pname}-npm-deps";
31     hash = "sha256-na1HEueX8w7kuDp8LEtJ0nD1Yv39cyk6sEMpS1zix2s=";
32   };
34   useFetchCargoVendor = true;
35   cargoHash = "sha256-rXpyPLe28YgUkDJNBEA0HGSpmcHOik9em1uwLuYAU8I=";
37   postPatch = ''
38     # Using local tailwindcss for compilation
39     substituteInPlace Trunk.toml --replace-fail "npx tailwindcss" "tailwindcss"
40   '';
42   nativeBuildInputs = [
43     binaryen
44     llvmPackages.bintools-unwrapped
45     nodejs
46     npmHooks.npmConfigHook
47     tailwindcss
48     trunk
49     # needs to match with wasm-bindgen version in upstreams Cargo.lock
50     wasm-bindgen-cli_0_2_93
52     zip
53   ];
55   NODE_PATH = "$npmDeps";
57   buildPhase = ''
58     trunk build --offline --frozen --release
59   '';
61   installPhase = ''
62     cd dist
63     mkdir -p $out
64     zip -r $out/webadmin.zip *
65   '';
67   passthru = {
68     updateScript = nix-update-script { };
69   };
71   meta = {
72     description = "Secure & modern all-in-one mail server Stalwart (webadmin module)";
73     homepage = "https://github.com/stalwartlabs/webadmin";
74     changelog = "https://github.com/stalwartlabs/webadmin/blob/${src.tag}/CHANGELOG.md";
75     license = lib.licenses.agpl3Only;
76     maintainers = with lib.maintainers; [ onny ];
77   };