From 880bd89c4d0983f5fbfb87802f6ba2ade7763cc6 Mon Sep 17 00:00:00 2001 From: Jonas Heinrich Date: Sun, 26 May 2024 12:28:29 +0200 Subject: [PATCH 1/3] nixos/stalwart-mail: package and configure webadmin --- nixos/modules/services/mail/stalwart-mail.nix | 8 +++++++- pkgs/by-name/st/stalwart-mail/package.nix | 2 ++ 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/nixos/modules/services/mail/stalwart-mail.nix b/nixos/modules/services/mail/stalwart-mail.nix index fe433f9a2662130..aabe46d607a8c5d 100644 --- a/nixos/modules/services/mail/stalwart-mail.nix +++ b/nixos/modules/services/mail/stalwart-mail.nix @@ -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"; }; }; diff --git a/pkgs/by-name/st/stalwart-mail/package.nix b/pkgs/by-name/st/stalwart-mail/package.nix index 045143f15b796aa..c2a1d339caea7ff 100644 --- a/pkgs/by-name/st/stalwart-mail/package.nix +++ b/pkgs/by-name/st/stalwart-mail/package.nix @@ -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; }; From 579b775ed887fb55b72e9043ca1ae5371a9f12cb Mon Sep 17 00:00:00 2001 From: Jonas Heinrich Date: Thu, 5 Sep 2024 08:28:29 +0200 Subject: [PATCH 2/3] stalwart-mail.webadmin: init at 0.1.13 --- pkgs/by-name/st/stalwart-mail/webadmin.nix | 70 ++++++++++++++++++++++ 1 file changed, 70 insertions(+) create mode 100644 pkgs/by-name/st/stalwart-mail/webadmin.nix diff --git a/pkgs/by-name/st/stalwart-mail/webadmin.nix b/pkgs/by-name/st/stalwart-mail/webadmin.nix new file mode 100644 index 000000000000000..62db1c422ac4d60 --- /dev/null +++ b/pkgs/by-name/st/stalwart-mail/webadmin.nix @@ -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 ]; + }; +} From ef0d15f8d3f5f8c11ba4af0faddbf78d43383a41 Mon Sep 17 00:00:00 2001 From: Jonas Heinrich Date: Thu, 5 Sep 2024 08:32:42 +0200 Subject: [PATCH 3/3] wasm-bingen-cli: 0.2.92 -> 0.2.93 --- pkgs/by-name/wa/wasm-bindgen-cli/package.nix | 49 +++++++++++++++++++ .../tools/wasm-bindgen-cli/default.nix | 42 ---------------- pkgs/top-level/all-packages.nix | 5 -- 3 files changed, 49 insertions(+), 47 deletions(-) create mode 100644 pkgs/by-name/wa/wasm-bindgen-cli/package.nix delete mode 100644 pkgs/development/tools/wasm-bindgen-cli/default.nix diff --git a/pkgs/by-name/wa/wasm-bindgen-cli/package.nix b/pkgs/by-name/wa/wasm-bindgen-cli/package.nix new file mode 100644 index 000000000000000..517b2813478f7c3 --- /dev/null +++ b/pkgs/by-name/wa/wasm-bindgen-cli/package.nix @@ -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"; + }; +} diff --git a/pkgs/development/tools/wasm-bindgen-cli/default.nix b/pkgs/development/tools/wasm-bindgen-cli/default.nix deleted file mode 100644 index 3b0a6c1b53ebc2a..000000000000000 --- a/pkgs/development/tools/wasm-bindgen-cli/default.nix +++ /dev/null @@ -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 { }; -} diff --git a/pkgs/top-level/all-packages.nix b/pkgs/top-level/all-packages.nix index 7b893ed3ad6da7a..103b9dce1b2c14e 100644 --- a/pkgs/top-level/all-packages.nix +++ b/pkgs/top-level/all-packages.nix @@ -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 {