Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Merged
merged 3 commits into from
Sep 6, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion nixos/modules/services/mail/stalwart-mail.nix
Original file line number Diff line number Diff line change
Expand Up @@ -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";
};
};

Expand Down
2 changes: 2 additions & 0 deletions pkgs/by-name/st/stalwart-mail/package.nix
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
nix-update-script,
nixosTests,
rocksdb_8_11,
callPackage,
}:

let
Expand Down Expand Up @@ -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;
};
Expand Down
70 changes: 70 additions & 0 deletions pkgs/by-name/st/stalwart-mail/webadmin.nix
Original file line number Diff line number Diff line change
@@ -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 ];
};
}
49 changes: 49 additions & 0 deletions pkgs/by-name/wa/wasm-bindgen-cli/package.nix
Original file line number Diff line number Diff line change
@@ -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";
};
}
42 changes: 0 additions & 42 deletions pkgs/development/tools/wasm-bindgen-cli/default.nix

This file was deleted.

5 changes: 0 additions & 5 deletions pkgs/top-level/all-packages.nix
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down