btrbk: add mainProgram
[NixPkgs.git] / pkgs / by-name / st / stalwart-mail / webadmin.nix
blobd757c9dde44a09ce9cf822af7f7cad4dd97f2f80
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,
13   binaryen,
14   zip,
17 rustPlatform.buildRustPackage rec {
18   pname = "webadmin";
19   version = "0.1.17";
21   src = fetchFromGitHub {
22     owner = "stalwartlabs";
23     repo = "webadmin";
24     rev = "refs/tags/v${version}";
25     hash = "sha256-kMfdCb2dwoVd9G1uZw2wcfaAAPt6obFfWQbbXG/MDB4=";
26   };
28   npmDeps = fetchNpmDeps {
29     inherit src;
30     name = "${pname}-npm-deps";
31     hash = "sha256-na1HEueX8w7kuDp8LEtJ0nD1Yv39cyk6sEMpS1zix2s=";
32   };
34   cargoHash = "sha256-0Urr0MsmenFqg25lZAzg7LgJ/NkZHINoOWtPad7G6GE=";
36   postPatch = ''
37     # Using local tailwindcss for compilation
38     substituteInPlace Trunk.toml --replace-fail "npx tailwindcss" "tailwindcss"
39   '';
41   nativeBuildInputs = [
42     binaryen
43     llvmPackages.bintools-unwrapped
44     nodejs
45     npmHooks.npmConfigHook
46     tailwindcss
47     trunk
48     # needs to match with wasm-bindgen version in upstreams Cargo.lock
49     (wasm-bindgen-cli.override {
50       version = "0.2.93";
51       hash = "sha256-DDdu5mM3gneraM85pAepBXWn3TMofarVR4NbjMdz3r0=";
52       cargoHash = "sha256-birrg+XABBHHKJxfTKAMSlmTVYLmnmqMDfRnmG6g/YQ=";
53     })
54     zip
55   ];
57   NODE_PATH = "$npmDeps";
59   buildPhase = ''
60     trunk build --offline --frozen --release
61   '';
63   installPhase = ''
64     cd dist
65     mkdir -p $out
66     zip -r $out/webadmin.zip *
67   '';
69   passthru = {
70     updateScript = nix-update-script { };
71   };
73   meta = with lib; {
74     description = "Secure & modern all-in-one mail server Stalwart (webadmin module)";
75     homepage = "https://github.com/stalwartlabs/webadmin";
76     changelog = "https://github.com/stalwartlabs/mail-server/blob/${version}/CHANGELOG";
77     license = licenses.agpl3Only;
78     maintainers = with maintainers; [ onny ];
79   };