nixos/stalwart-mail: package and configure webadmin (#314820)

This commit is contained in:
Yt 2024-09-06 01:03:27 +00:00 committed by GitHub
commit fcc6387b76
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
6 changed files with 128 additions and 48 deletions

View File

@ -73,8 +73,14 @@ in {
resolver.public-suffix = lib.mkDefault [
"file://${pkgs.publicsuffix-list}/share/publicsuffix/public_suffix_list.dat"
];
config.resource = {
config.resource = let
hasHttpListener = builtins.any (listener: listener.protocol == "http") (lib.attrValues cfg.settings.server.listener);
in {
spam-filter = lib.mkDefault "file://${cfg.package}/etc/stalwart/spamfilter.toml";
} // lib.optionalAttrs (
(builtins.hasAttr "listener" cfg.settings.server) && hasHttpListener
) {
webadmin = lib.mkDefault "file://${cfg.package.webadmin}/webadmin.zip";
};
};

View File

@ -15,6 +15,7 @@
nix-update-script,
nixosTests,
rocksdb_8_11,
callPackage,
}:
let
@ -144,6 +145,7 @@ rustPlatform.buildRustPackage {
doCheck = !(stdenv.isLinux && stdenv.isAarch64);
passthru = {
webadmin = callPackage ./webadmin.nix { };
update-script = nix-update-script { };
tests.stalwart-mail = nixosTests.stalwart-mail;
};

View File

@ -0,0 +1,70 @@
{
lib,
rustPlatform,
fetchFromGitHub,
trunk-ng,
tailwindcss,
fetchNpmDeps,
nodejs,
npmHooks,
llvmPackages,
wasm-bindgen-cli,
binaryen,
zip,
}:
rustPlatform.buildRustPackage rec {
pname = "webadmin";
version = "0.1.13";
src = fetchFromGitHub {
owner = "stalwartlabs";
repo = "webadmin";
rev = "refs/tags/v${version}";
hash = "sha256-QtQAcbyTSAj56QZky7eyNS15pnetLVN1Z4cN5pxlJFc=";
};
npmDeps = fetchNpmDeps {
inherit src;
name = "${pname}-npm-deps";
hash = "sha256-na1HEueX8w7kuDp8LEtJ0nD1Yv39cyk6sEMpS1zix2s=";
};
cargoHash = "sha256-CWDwVVea+cdsoIbQdQ3HDiVwYuMSplWZSUXTweibu9s=";
postPatch = ''
# Using local tailwindcss for compilation
substituteInPlace Trunk.toml --replace-fail "npx tailwindcss" "tailwindcss"
'';
nativeBuildInputs = [
binaryen
llvmPackages.bintools-unwrapped
nodejs
npmHooks.npmConfigHook
tailwindcss
trunk-ng
wasm-bindgen-cli
zip
];
NODE_PATH = "$npmDeps";
buildPhase = ''
trunk-ng build --offline --verbose --release
'';
installPhase = ''
cd dist
mkdir -p $out
zip -r $out/webadmin.zip *
'';
meta = with lib; {
description = "Secure & modern all-in-one mail server Stalwart (webadmin module)";
homepage = "https://github.com/stalwartlabs/webadmin";
changelog = "https://github.com/stalwartlabs/mail-server/blob/${version}/CHANGELOG";
license = licenses.agpl3Only;
maintainers = with maintainers; [ onny ];
};
}

View File

@ -0,0 +1,49 @@
{
lib,
rustPlatform,
fetchCrate,
nix-update-script,
nodejs_latest,
pkg-config,
openssl,
stdenv,
curl,
darwin,
version ? "0.2.93",
hash ? "sha256-DDdu5mM3gneraM85pAepBXWn3TMofarVR4NbjMdz3r0=",
cargoHash ? "sha256-birrg+XABBHHKJxfTKAMSlmTVYLmnmqMDfRnmG6g/YQ=",
}:
rustPlatform.buildRustPackage rec {
pname = "wasm-bindgen-cli";
inherit version hash cargoHash;
src = fetchCrate { inherit pname version hash; };
nativeBuildInputs = [ pkg-config ];
buildInputs =
[ openssl ]
++ lib.optionals stdenv.isDarwin [
curl
darwin.apple_sdk.frameworks.Security
];
nativeCheckInputs = [ nodejs_latest ];
# tests require it to be ran in the wasm-bindgen monorepo
doCheck = false;
passthru.updateScript = nix-update-script { };
meta = {
homepage = "https://rustwasm.github.io/docs/wasm-bindgen/";
license = with lib.licenses; [
asl20 # or
mit
];
description = "Facilitating high-level interactions between wasm modules and JavaScript";
maintainers = with lib.maintainers; [ rizary ];
mainProgram = "wasm-bindgen";
};
}

View File

@ -1,42 +0,0 @@
{ lib
, rustPlatform
, fetchCrate
, nix-update-script
, nodejs
, pkg-config
, openssl
, stdenv
, curl
, Security
, version ? "0.2.93"
, hash ? "sha256-DDdu5mM3gneraM85pAepBXWn3TMofarVR4NbjMdz3r0="
, cargoHash ? "sha256-birrg+XABBHHKJxfTKAMSlmTVYLmnmqMDfRnmG6g/YQ="
}:
rustPlatform.buildRustPackage rec {
pname = "wasm-bindgen-cli";
inherit version hash cargoHash;
src = fetchCrate {
inherit pname version hash;
};
nativeBuildInputs = [ pkg-config ];
buildInputs = [ openssl ] ++ lib.optionals stdenv.isDarwin [ curl Security ];
nativeCheckInputs = [ nodejs ];
# tests require it to be ran in the wasm-bindgen monorepo
doCheck = false;
meta = with lib; {
homepage = "https://rustwasm.github.io/docs/wasm-bindgen/";
license = with licenses; [ asl20 /* or */ mit ];
description = "Facilitating high-level interactions between wasm modules and JavaScript";
maintainers = with maintainers; [ rizary ];
mainProgram = "wasm-bindgen";
};
passthru.updateScript = nix-update-script { };
}

View File

@ -13781,11 +13781,6 @@ with pkgs;
wasm-text-gen = nodePackages."@webassemblyjs/wasm-text-gen-1.11.1";
wast-refmt = nodePackages."@webassemblyjs/wast-refmt-1.11.1";
wasm-bindgen-cli = callPackage ../development/tools/wasm-bindgen-cli {
inherit (darwin.apple_sdk.frameworks) Security;
nodejs = nodejs_latest;
};
wasm-tools = callPackage ../tools/misc/wasm-tools { };
wasmedge = callPackage ../development/tools/wasmedge {