Unverified Commit fcc6387b authored by Yt's avatar Yt Committed by GitHub
Browse files

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

parents 6aeb2233 ef0d15f8
Loading
Loading
Loading
Loading
+7 −1
Original line number Diff line number Diff line
@@ -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";
      };
    };

+2 −0
Original line number Diff line number Diff line
@@ -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;
  };
+70 −0
Original line number Diff line number Diff line
{
  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 −0
Original line number Diff line number Diff line
{ 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="
{
  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;
  };
  src = fetchCrate { inherit pname version hash; };

  nativeBuildInputs = [ pkg-config ];

  buildInputs = [ openssl ] ++ lib.optionals stdenv.isDarwin [ curl Security ];
  buildInputs =
    [ openssl ]
    ++ lib.optionals stdenv.isDarwin [
      curl
      darwin.apple_sdk.frameworks.Security
    ];

  nativeCheckInputs = [ nodejs ];
  nativeCheckInputs = [ nodejs_latest ];

  # tests require it to be ran in the wasm-bindgen monorepo
  doCheck = false;

  meta = with lib; {
  passthru.updateScript = nix-update-script { };

  meta = {
    homepage = "https://rustwasm.github.io/docs/wasm-bindgen/";
    license = with licenses; [ asl20 /* or */ mit ];
    license = with lib.licenses; [
      asl20 # or
      mit
    ];
    description = "Facilitating high-level interactions between wasm modules and JavaScript";
    maintainers = with maintainers; [ rizary ];
    maintainers = with lib.maintainers; [ rizary ];
    mainProgram = "wasm-bindgen";
  };

  passthru.updateScript = nix-update-script { };
}
+0 −5
Original line number Diff line number Diff line
@@ -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 {
Loading